forked from scarybot/tlsdate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-tests
executable file
·48 lines (44 loc) · 1.04 KB
/
run-tests
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
#!/bin/sh
run_test() {
# Clear the last results
rm -f "$1"/result
[ -x "$1"/setup ] && "$1"/setup
if [ -r "$1"/tlsdated-flags ]; then
flags=$(cat "$1"/tlsdated-flags | sed "s/@TESTDIR@/$1/g")
elif [ -r "$1"/test.conf ]; then
flags="-U -w -p -r -l -s -b -f $1/test.conf -v"
else
flags="-U -w -p -r -l -s -b -f test.conf -v"
fi
# flags are deliberately unquoted here so that they'll be interpolated
(test -x "$1"/input.sh && "$1"/input.sh) |
timeout 8 src/tlsdated $flags -- "$1"/subproc.sh \
>"$1"/run-output 2>"$1"/run-err
[ -x "$1"/teardown ] && "$1"/teardown
}
test_passed() {
f="$t"/result
test -f "$f" && grep -q ok "$f"
}
total=0
passed=0
if ! test -x src/test/emit; then
echo "Make sure src/test/emit has been built (make check)!"
exit 1
fi
for t in tests/*; do
[ ! -d "$t" ] && continue
name="$(basename "$t")"
echo -n "$name: "
run_test "$t"
if test_passed "$t"; then
echo "ok"
passed=$((passed + 1))
else
echo "failed"
fi
total=$((total + 1))
done
echo "Passed: $passed/$total"
[ $passed != $total ]
exit $?