aboutsummaryrefslogtreecommitdiff
path: root/tests/scripts/run-xfail
blob: 35bcc759ef790c93a85e45faef0a8f8d8a14a41d (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
#!/bin/sh
NAME="$1"
EMSG="$2"

try_vg() {
	if [ "x$VALGRIND" != "x0" ] && which valgrind > /dev/null >&1; then
		eval "valgrind -q --leak-check=full --error-exitcode=169 $1"
	else
		eval "$1"
	fi

	RETVAL=$?
	return "$RETVAL"
}

I=0
while :; do
	if try_vg "../fwd $NAME/$NAME.fwd" \
		1> "reports/$NAME/gen.c"   \
		2> "reports/$NAME/run-$I"
	then
		# success was not expected
		echo "SUCC" > reports/$NAME/OK
		exit 0
	fi

	if [ "$RETVAL" = 169 ]; then
		echo "VALGRIND" > reports/$NAME/OK

		# don't return on an error so that makefile continues running
		# other tests that are maybe failing, and reports the status
		# after all tests have been run
		exit 0
	fi

	# correctly handled coverage exception, continue to next run
	# here we check for the special 'internal error' which should be
	# reported if the error was handled gracefully, otherwise since the
	# error message is not the one we expected and not a covsrv error, we
	# don't know what it is and could end up in an infinite loop if we don't
	# stop here.
	if grep 'COVSRV: EXIT' "reports/$NAME/gen.c" > /dev/null \
	&& grep 'internal error:' "reports/$NAME/run-$I" > /dev/null; then
		I=$((I+1))
		continue
	fi

	if grep "$EMSG" "reports/$NAME/run-$I" > /dev/null; then
		# we exited with the expected error message and without leaking
		# memory, presume covsrv is happy as well
		echo "OK" > reports/$NAME/OK
		exit 0
	fi

	# incorrectly handled coverage exception, stop run
	echo "MEMERR" > reports/$NAME/OK
	exit 0
done