884fc5527a
While the correctness of the supported hash algorithms can be tested with the built-in self-test feature, these test cases are meant to detect changes in the output format. A follow-up commit will improve the compatibility with the coreutils versions of the hash programs, and these tests should detect any unintended side-effects of such a change on existing functionality.
24 lines
406 B
Bash
24 lines
406 B
Bash
#!/bin/sh
|
|
|
|
exitcode=0
|
|
|
|
testloop () {
|
|
opt=$1
|
|
|
|
while read algorithm; do
|
|
n=0
|
|
for f in %%TESTSBASE%%/sbin/md5/*.inp; do
|
|
n=$((n + 1))
|
|
expected=$(head -$n %%TESTSBASE%%/sbin/md5/$algorithm.digest | tail -1 | cut -w -f4)
|
|
hash=$($algorithm $opt -c "$expected" $f) || exitcode=1
|
|
done
|
|
done < %%TESTSBASE%%/sbin/md5/algorithms.txt
|
|
}
|
|
|
|
testloop ""
|
|
testloop -q
|
|
testloop -r
|
|
testloop -qr
|
|
|
|
exit $exitcode
|