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