aboutsummaryrefslogtreecommitdiff
path: root/src/templating/dotest.sh
blob: 7b24bcf9f1497b19bad3d091af2b1e8863a128c1 (plain)
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
#!/bin/sh

# Exit, with error message (hard failure)
exit_fail() {
    echo " FAIL: " "$@" >&2
    exit 1
}

mustach=${mustach:-../mustach}
ldd "${mustach}"
echo starting test
if test "$NOVALGRIND" = 1
then
	$mustach "$@" > resu.last || exit_fail "ERROR! mustach command failed ($?)!"
else
	valgrind $mustach "$@" > resu.last 2> vg.last || exit_fail "ERROR! mustach command failed ($?)!"
	sed -i 's:^==[0-9]*== ::' vg.last
	awk '/^ *total heap usage: .* allocs, .* frees,.*/{if($$4-$$6)exit(1)}' vg.last || exit_fail "ERROR! Alloc/Free issue"
fi
if diff -w resu.ref resu.last
then
	echo "result ok"
else
	exit_fail "ERROR! Result differs"
fi
echo
exit 0