aboutsummaryrefslogtreecommitdiff
path: root/tests/sha1sum.test
blob: e3cf2a22766a749703cb3b8dc3d58c9f6f9b670f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash

[ -f testing.sh ] && . testing.sh
echo $CMDNAME
#testing "name" "command" "result" "infile" "stdin"

# These tests are based on RFC3174 which were based on FIPS PUB 180-1

if [ "$CMDNAME" == sha1sum ]; then
  ABC=a9993e364706816aba3e25717850c26c9cd0d89d
  ABCLONG=84983e441c3bd26ebaae4aa1f95129e5e54670f1
  MILNUL=34aa973cd4c4daa4f61eeb2bdbad27316534016f
  DIGITS=dea356a2cddd90c7a7ecedc5ebb563934f460452
  DEF=589c22335a381f122d129225f5c0ba3056ed5811
elif [ "$CMDNAME" == sha256sum ]; then
  ABC=ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad
  ABCLONG=248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1
  MILNUL=cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0
  DIGITS=594847328451bdfa85056225462cc1d867d877fb388df0ce35f25ab5562bfbb5
  DEF=cb8379ac2098aa165029e3938a51da0bcecfc008fd6795f401178647f96c5b34
fi
testcmd "abc" "" "$ABC  -\n" "" "abc"
testcmd "longer str" "" "$ABCLONG  -\n"\
        "" "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
testing "a million nulls" \
        'dd if=/dev/zero bs=1000 count=1000 2>/dev/null|tr \\0 a|$CMDNAME' \
        "$MILNUL  -\n" "" ""

testing "digits" 'for i in `seq 1 80`; do echo -n 01234567 ; done | $CMDNAME' \
        "$DIGITS  -\n" "" ""

echo -n "def" > file2
testcmd "file" "input" "$ABC  input\n" "abc" ""
testcmd "file1 file2" "input file2" "$ABC  input\n$DEF  file2\n" "abc" ""
testcmd "file1 file2 -" "input file2 -" "$ABC  input\n$DEF  file2\n$ABC  -\n" \
        "abc" "abc"
rm -f file2