4 # Copyright (C) 2000, 2003, 2005, 2006 Free Software Foundation, Inc.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 $PERL -e 1 > /dev/null 2>&1 || {
25 echo 1>&2 "$0: configure didn't find a usable version of Perl," \
26 "so can't run this test"
30 exec $PERL -w -I$srcdir/.. -MCoreutils -- - <<\EOF
34 (my $program_name = $0) =~ s|.*/||;
36 # Turn off localisation of executable's ouput.
37 @ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
39 my $sha_degenerate = "da39a3ee5e6b4b0d3255bfef95601890afd80709";
43 ['s1', {IN=> {f=> ''}},
44 {OUT=>"$sha_degenerate f\n"}],
45 ['s2', {IN=> {f=> 'a'}},
46 {OUT=>"86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 f\n"}],
47 ['s3', {IN=> {f=> 'abc'}},
48 {OUT=>"a9993e364706816aba3e25717850c26c9cd0d89d f\n"}],
50 {IN=> {f=> 'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'}},
51 {OUT=>"84983e441c3bd26ebaae4aa1f95129e5e54670f1 f\n"}],
52 ['s5', {IN=> {f=> 'abcdefghijklmnopqrstuvwxyz'}},
53 {OUT=>"32d10c7b8cf96570ca04ce37f2a19d84240d3a89 f\n"}],
54 ['s6', {IN=> {f=> join ('', 'A'..'Z', 'a'..'z', '0'..'9')}},
55 {OUT=>"761c457bf73b14d27e9e9265c46f4b4dda11f940 f\n"}],
56 ['s7', {IN=> {f=> '1234567890' x 8}},
57 {OUT=>"50abf5706a150990a08b2c5ea40fa0e585554732 f\n"}],
58 ['million-a', {IN=> {f=> 'a' x 1000000}},
59 {OUT=>"34aa973cd4c4daa4f61eeb2bdbad27316534016f f\n"}],
60 ['bs-sha', {IN=> {".\\foo"=> ''}},
61 {OUT=>"\\$sha_degenerate .\\\\foo\n"}],
62 # The sha1sum and md5sum drivers share a lot of code.
63 # Ensure that sha1sum does *not* share the part that makes
64 # md5sum accept BSD format.
65 ['check-bsd', '--check', {IN=> {'f.md5' => "MD5 (f) = $sha_degenerate\n"}},
67 {ERR=>"sha1sum: f.md5: no properly formatted "
68 . "SHA1 checksum lines found\n"},
70 ['check-bsd2', '--check',
71 {IN=> {'f.sha1' => "SHA1 (f) = $sha_degenerate\n"}},
72 {AUX=> {f=> ''}}, {OUT=>"f: OK\n"}],
73 ['check-bsd3', '--check', '--status',
74 {IN=> {'f.sha1' => "SHA1 (f) = $sha_degenerate\n"}},
75 {AUX=> {f=> 'bar'}}, {EXIT=> 1}],
78 # Insert the `--text' argument for each test.
82 splice @$t, 1, 0, '--text' unless @$t[1] =~ /--check/;
85 my $save_temps = $ENV{DEBUG};
86 my $verbose = $ENV{VERBOSE};
88 my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n";
89 my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose);