-
Notifications
You must be signed in to change notification settings - Fork 2
/
exec_test.sh
executable file
·67 lines (52 loc) · 1.12 KB
/
exec_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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
# Usage: exec_test.sh <Action> <Test> [<TestDataType>]
# If CAPNP_TEST_APP returns 127, it indicates that it didn't run that
# test, hence we should skip it.
export STATUS=0
function result_status
{
printf "%s [%s %s]\n\n" "$@"
}
function passed
{
result_status "== PASS" $* >&2
}
function failed
{
result_status "## FAIL" $* >&2
}
function skipped
{
result_status ".. SKIP" $* >&2
}
function run_test
{
${CAPNP_TEST_APP} $1 $2 ; STATUS=$?
}
function decode_result
{
[[ $STATUS == 0 ]] && capnp decode --short test.capnp $1 < actual.bin
}
function check_result
{
[[ $STATUS == 0 ]] && { diff expect/$2.txt actual.txt ; STATUS=$? ;} \
|| cat actual.*
case $STATUS in
0) passed $* ;;
127) skipped $* ;;
*) failed $*
esac
return $STATUS
}
printf "++ TEST [%s %s]\n" $1 $2 >&2
case $1 in
decode)
run_test decode $2 < expect/$2.bin > actual.txt
check_result $1 $2 ;;
encode)
run_test encode $2 > actual.bin \
&& decode_result $3 > actual.txt
check_result $1 $2
esac
rm -f actual.*
exit $STATUS