-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.sh
executable file
·42 lines (30 loc) · 940 Bytes
/
test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
#
# Low-budget test against system implementations...
set -eou pipefail
cd "`dirname "$0"`"
make
temp=$(mktemp)
iterations=1000
binaries=(ripemd160 md4 md5 sha1 sha256 sha512 blake2)
system_equivs=("openssl dgst -r -ripemd160" "openssl dgst -r -md4" md5sum sha1sum sha256sum sha512sum b2sum)
for i in ${!binaries[@]}; do
binary=${binaries[i]}
system_equiv=${system_equivs[i]}
if [ ! -e "${binary}" ] || [ "`which $system_equiv`" = "" ]; then
echo "Missing dependency. Test can't continue!"
exit
fi
echo "Testing ${binary} against ${system_equiv}"
result=$(
for i in `seq 0 $iterations`; do
head -c $i /dev/urandom > "$temp"; ./${binary} "$temp" | awk '{print $2}'; ${system_equiv} "$temp";
done | awk '{print $1}' | uniq -u
)
if [ "$result" = "" ]; then
echo "passed"
else
echo "FAILED"
fi
done
rm -f "$temp"