global: convert indentation-TABs to spaces
[coreutils.git] / tests / misc / sha1sum
blob3f09abaaed67c9793e4135d19788b28bfda5ceff
1 #!/usr/bin/perl
2 # Test "sha1sum".
4 # Copyright (C) 2000, 2003, 2005-2009 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 3 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, see <http://www.gnu.org/licenses/>.
19 use strict;
21 my $prog = 'sha1sum';
23 # Turn off localization of executable's output.
24 @ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
26 my $sha_degenerate = "da39a3ee5e6b4b0d3255bfef95601890afd80709";
28 my @Tests =
30 ['s1', {IN=> {f=> ''}},
31 {OUT=>"$sha_degenerate f\n"}],
32 ['s2', {IN=> {f=> 'a'}},
33 {OUT=>"86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 f\n"}],
34 ['s3', {IN=> {f=> 'abc'}},
35 {OUT=>"a9993e364706816aba3e25717850c26c9cd0d89d f\n"}],
36 ['s4',
37 {IN=> {f=> 'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'}},
38 {OUT=>"84983e441c3bd26ebaae4aa1f95129e5e54670f1 f\n"}],
39 ['s5', {IN=> {f=> 'abcdefghijklmnopqrstuvwxyz'}},
40 {OUT=>"32d10c7b8cf96570ca04ce37f2a19d84240d3a89 f\n"}],
41 ['s6', {IN=> {f=> join ('', 'A'..'Z', 'a'..'z', '0'..'9')}},
42 {OUT=>"761c457bf73b14d27e9e9265c46f4b4dda11f940 f\n"}],
43 ['s7', {IN=> {f=> '1234567890' x 8}},
44 {OUT=>"50abf5706a150990a08b2c5ea40fa0e585554732 f\n"}],
45 ['million-a', {IN=> {f=> 'a' x 1000000}},
46 {OUT=>"34aa973cd4c4daa4f61eeb2bdbad27316534016f f\n"}],
47 ['bs-sha', {IN=> {".\\foo"=> ''}},
48 {OUT=>"\\$sha_degenerate .\\\\foo\n"}],
49 # The sha1sum and md5sum drivers share a lot of code.
50 # Ensure that sha1sum does *not* share the part that makes
51 # md5sum accept BSD format.
52 ['check-bsd', '--check', {IN=> {'f.md5' => "MD5 (f) = $sha_degenerate\n"}},
53 {AUX=> {f=> ''}},
54 {ERR=>"sha1sum: f.md5: no properly formatted "
55 . "SHA1 checksum lines found\n"},
56 {EXIT=> 1}],
57 ['check-bsd2', '--check',
58 {IN=> {'f.sha1' => "SHA1 (f) = $sha_degenerate\n"}},
59 {AUX=> {f=> ''}}, {OUT=>"f: OK\n"}],
60 ['check-bsd3', '--check', '--status',
61 {IN=> {'f.sha1' => "SHA1 (f) = $sha_degenerate\n"}},
62 {AUX=> {f=> 'bar'}}, {EXIT=> 1}],
63 ['bsd-segv', '--check', {IN=> {'z' => "SHA1 ("}}, {EXIT=> 1},
64 {ERR=> "$prog: z: no properly formatted SHA1 checksum lines found\n"}],
67 # Insert the `--text' argument for each test.
68 my $t;
69 foreach $t (@Tests)
71 splice @$t, 1, 0, '--text' unless @$t[1] =~ /--check/;
74 my $save_temps = $ENV{DEBUG};
75 my $verbose = $ENV{VERBOSE};
77 my $fail = run_tests ($prog, $prog, \@Tests, $save_temps, $verbose);
78 exit $fail;