More missing static
[git/kirr.git] / test-sha1.sh
blob640856af5a6712a05b2530ad0951d84e631d0ec1
1 #!/bin/sh
3 dd if=/dev/zero bs=1048576 count=100 2>/dev/null |
4 /usr/bin/time ./test-sha1 >/dev/null
6 while read expect cnt pfx
7 do
8 case "$expect" in '#'*) continue ;; esac
9 actual=`
11 test -z "$pfx" || echo "$pfx"
12 dd if=/dev/zero bs=1048576 count=$cnt 2>/dev/null |
13 tr '[\0]' '[g]'
14 } | ./test-sha1 $cnt
16 if test "$expect" = "$actual"
17 then
18 echo "OK: $expect $cnt $pfx"
19 else
20 echo >&2 "OOPS: $cnt"
21 echo >&2 "expect: $expect"
22 echo >&2 "actual: $actual"
23 exit 1
25 done <<EOF
26 da39a3ee5e6b4b0d3255bfef95601890afd80709 0
27 3f786850e387550fdab836ed7e6dc881de23001b 0 a
28 5277cbb45a15902137d332d97e89cf8136545485 0 ab
29 03cfd743661f07975fa2f1220c5194cbaff48451 0 abc
30 3330b4373640f9e4604991e73c7e86bfd8da2dc3 0 abcd
31 ec11312386ad561674f724b8cca7cf1796e26d1d 0 abcde
32 bdc37c074ec4ee6050d68bc133c6b912f36474df 0 abcdef
33 69bca99b923859f2dc486b55b87f49689b7358c7 0 abcdefg
34 e414af7161c9554089f4106d6f1797ef14a73666 0 abcdefgh
35 0707f2970043f9f7c22029482db27733deaec029 0 abcdefghi
36 a4dd8aa74a5636728fe52451636e2e17726033aa 1
37 9986b45e2f4d7086372533bb6953a8652fa3644a 1 frotz
38 23d8d4f788e8526b4877548a32577543cbaaf51f 10
39 8cd23f822ab44c7f481b8c92d591f6d1fcad431c 10 frotz
40 f3b5604a4e604899c1233edb3bf1cc0ede4d8c32 512
41 b095bd837a371593048136e429e9ac4b476e1bb3 512 frotz
42 08fa81d6190948de5ccca3966340cc48c10cceac 1200 xyzzy
43 e33a291f42c30a159733dd98b8b3e4ff34158ca0 4090 4G
44 #a3bf783bc20caa958f6cb24dd140a7b21984838d 9999 nitfol
45 EOF
47 exit
49 # generating test vectors
50 # inputs are number of megabytes followed by some random string to prefix.
52 while read cnt pfx
54 actual=`
56 test -z "$pfx" || echo "$pfx"
57 dd if=/dev/zero bs=1048576 count=$cnt 2>/dev/null |
58 tr '[\0]' '[g]'
59 } | sha1sum |
60 sed -e 's/ .*//'
62 echo "$actual $cnt $pfx"
63 done <<EOF
65 0 a
66 0 ab
67 0 abc
68 0 abcd
69 0 abcde
70 0 abcdef
71 0 abcdefg
72 0 abcdefgh
73 0 abcdefghi
75 1 frotz
77 10 frotz
78 512
79 512 frotz
80 1200 xyzzy
81 4090 4G
82 9999 nitfol
83 EOF