aboutsummaryrefslogtreecommitdiffstats
path: root/test-all
blob: 8bd61dfb3d288042c28c33325cbb60f0defcdca2 (plain) (blame)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash

cd -- "$(dirname "$0")"

all ()
{
	echo patch md5sum rawshake256sum rawshake512sum sha1sum sha224sum sha256sum sha3-224sum \
	     sha3-256sum sha3-384sum sha3-512sum sha384sum sha512-224sum sha512-256sum sha512sum \
	     shake256sum shake512sum cksum true false echo test basename dirname uniq cat yes \
	     tac rev base16 base32 base64 nologin printenv
}

exec 99>&2
exec 2>/dev/null
if test -n "${EPATH}"; then
	for c in $(all); do
	    eval "export $(echo $c | tr '[a-z-]' '[A-Z_]')='$(realpath "$(env PATH="${EPATH}" "$(which which)" $c)")'"
	done
elif test -n "${EXECBOX}"; then
	for c in $(all); do
	    eval "export $(echo $c | tr '[a-z-]' '[A-Z_]')='exec-as $(realpath "${EXECBOX}") $c'"
	done
elif test -n "${IN_PATH}"; then
	for c in $(all); do
	    eval "export $(echo $c | tr '[a-z-]' '[A-Z_]')='$(realpath "$(which $c)")'"
	done
fi
exec 2>&99
exec 99>&-

if test $# = 0; then
	set $(all)
fi

true > result

for t in $@; do
	printf '\033[1mTesting %s ...\033[m\n' "$t"
	./${t}-test/test
	r=$?
	if test $r -ge 2; then
		echo $t >> result
	elif test $r = 1; then
		echo $t '(standards-compliant)' >> result
	fi
	echo
done

test $(wc -l < result) = 0
ret=$?
if ! test $ret = 0; then
	echo
	printf '\033[1mThe following utilities did not pass all tests, or possibility as not found:\033[m\n'
	echo
	cat result
else
	echo
	printf '\033[1mYour system is awesome!\033[m\n'
	echo
fi
rm result
exit $ret