blob: cca26dc64221b7e41123db9118ebccf629db25ae [file] [log] [blame]
Denys Vlasenkoe8ee8622010-10-16 21:26:47 +02001#!/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
14if ! test "$1"; then
15 set -- md5sum efe30c482e0b687e0cca0612f42ca29b
16fi
17
18sum="$1"
19expected="$2"
20
Denys Vlasenko26777aa2010-11-22 23:49:10 +010021test -f "$bindir/.config" && . "$bindir/.config"
22
23test x"$CONFIG_FEATURE_FANCY_HEAD" != x"y" \
24&& { echo "SKIPPED: $sum"; exit 0; }
25
Denys Vlasenkob0056ea2016-07-11 19:51:08 +020026FAILCOUNT=0
27
Denys Vlasenko273abcb2010-10-16 22:43:34 +020028text="The quick brown fox jumps over the lazy dog"
29text=`yes "$text" | head -c 9999`
Denys Vlasenkoe8ee8622010-10-16 21:26:47 +020030
31result=`(
Denys Vlasenkoe8ee8622010-10-16 21:26:47 +020032n=0
33while test $n -le 999; do
Denys Vlasenko273abcb2010-10-16 22:43:34 +020034 echo "$text" | head -c $n | "$sum"
Michael Tokarevafa63b22013-11-10 22:01:38 +010035 n=$(($n+1))
Denys Vlasenkoe8ee8622010-10-16 21:26:47 +020036done | "$sum"
Denys Vlasenkoe8ee8622010-10-16 21:26:47 +020037)`
Denys Vlasenkob0056ea2016-07-11 19:51:08 +020038if test x"$result" != x"$expected -"; then
39 echo "FAIL: $sum (r:$result exp:$expected)"
40 : $((FAILCOUNT++))
41else
Michael Tokarevafa63b22013-11-10 22:01:38 +010042 echo "PASS: $sum"
Denys Vlasenkoe8ee8622010-10-16 21:26:47 +020043fi
44
Denys Vlasenkob0056ea2016-07-11 19:51:08 +020045# GNU compat: -c EMPTY must fail (exitcode 1)!
46>EMPTY
47if "$sum" -c EMPTY 2>/dev/null; then
48 echo "FAIL: $sum -c EMPTY"
49 : $((FAILCOUNT++))
50else
51 echo "PASS: $sum -c EMPTY"
52fi
53rm EMPTY
54
55exit $FAILCOUNT