Denys Vlasenko | e8ee862 | 2010-10-16 21:26:47 +0200 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # Used by {ms5,shaN}sum |
| 3 | |
| 4 | # We pipe texts 0...999 bytes long, {md5,shaN}sum them, |
| 5 | # then {md5,shaN}sum the resulting list. |
| 6 | # Then we compare the result with expected result. |
| 7 | # |
| 8 | # Here are the expected results: |
| 9 | # efe30c482e0b687e0cca0612f42ca29b |
| 10 | # d41337e834377140ae7f98460d71d908598ef04f |
| 11 | # 8e1d3ed57ebc130f0f72508446559eeae06451ae6d61b1e8ce46370cfb8963c3 |
| 12 | # fe413e0f177324d1353893ca0772ceba83fd41512ba63895a0eebb703ef9feac2fb4e92b2cb430b3bda41b46b0cb4ea8307190a5cc795157cfb680a9cd635d0f |
| 13 | |
| 14 | if ! test "$1"; then |
| 15 | set -- md5sum efe30c482e0b687e0cca0612f42ca29b |
| 16 | fi |
| 17 | |
| 18 | sum="$1" |
| 19 | expected="$2" |
| 20 | |
Denys Vlasenko | 26777aa | 2010-11-22 23:49:10 +0100 | [diff] [blame] | 21 | test -f "$bindir/.config" && . "$bindir/.config" |
| 22 | |
| 23 | test x"$CONFIG_FEATURE_FANCY_HEAD" != x"y" \ |
| 24 | && { echo "SKIPPED: $sum"; exit 0; } |
| 25 | |
Denys Vlasenko | 273abcb | 2010-10-16 22:43:34 +0200 | [diff] [blame] | 26 | text="The quick brown fox jumps over the lazy dog" |
| 27 | text=`yes "$text" | head -c 9999` |
Denys Vlasenko | e8ee862 | 2010-10-16 21:26:47 +0200 | [diff] [blame] | 28 | |
| 29 | result=`( |
Denys Vlasenko | e8ee862 | 2010-10-16 21:26:47 +0200 | [diff] [blame] | 30 | n=0 |
| 31 | while test $n -le 999; do |
Denys Vlasenko | 273abcb | 2010-10-16 22:43:34 +0200 | [diff] [blame] | 32 | echo "$text" | head -c $n | "$sum" |
Denys Vlasenko | e8ee862 | 2010-10-16 21:26:47 +0200 | [diff] [blame] | 33 | : $((n++)) |
| 34 | done | "$sum" |
Denys Vlasenko | e8ee862 | 2010-10-16 21:26:47 +0200 | [diff] [blame] | 35 | )` |
| 36 | |
Denys Vlasenko | e8ee862 | 2010-10-16 21:26:47 +0200 | [diff] [blame] | 37 | if test x"$result" = x"$expected -"; then |
| 38 | echo "PASS: $sum" |
| 39 | exit 0 |
| 40 | fi |
| 41 | |
| 42 | echo "FAIL: $sum (r:$result exp:$expected)" |
| 43 | exit 1 |