freebsd-dev/sbin/md5/tests/bsd-p-test.SH
Stefan Eßer 884fc5527a sbin/md5: add tests
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.
2021-06-25 08:51:40 +02:00

25 lines
402 B
Bash

#!/bin/sh
exitcode=0
testloop () {
opt=$1
sum=$2
for algorithm in sha512; do
for f in %%TESTSBASE%%/sbin/md5/*.inp; do
outbase=%%TESTSBASE%%/sbin/md5/$(basename $f .inp)
$algorithm$sum $opt -p < $f > $outbase.out
diff $outbase.$algorithm$sum-p.chk $outbase.out || exitcode=1
done
done
}
testloop "" ""
testloop -q ""
testloop -qr ""
testloop "" sum
testloop -q sum
exit $exitcode