Sindbad~EG File Manager

Current Path : /usr/tests/sbin/md5/
Upload File :
Current File : /usr/tests/sbin/md5/bsd-s-test

#!/bin/sh

exitcode=0

testloop () {
	opt=$1
	sum=$2
	field=$3

	while read algorithm; do
		n=0
		for f in /usr/tests/sbin/md5/*.inp; do
			n=$((n + 1))
			read text < $f
			hash=$($algorithm$sum $opt -s "$text" | cut -d= -f$field)
			hash=$(echo $hash | cut -w -f1)
			expected=$(head -$n /usr/tests/sbin/md5/$algorithm.digest | tail -1 | cut -w -f4)
			[ "$hash" = "$expected" ] || exitcode=1
		done
	done < /usr/tests/sbin/md5/algorithms.txt
}

testloop "" "" 2
testloop -q "" 1
testloop -r "" 1
testloop -qr "" 1
testloop "" sum 1
testloop -q sum 1

exit $exitcode

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists