summaryrefslogtreecommitdiffstats
path: root/tests/shell/helpers/nft-valgrind-wrapper.sh
blob: 98bbdf43570eca57fc8155a16e51cb37c6b26ac0 (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
28
29
30
31
#!/bin/bash -e

SUFFIX="$(date "+%H%M%S.%6N").$$"

rc=0
libtool \
	--mode=execute \
	valgrind \
		--log-file="$NFT_TEST_TESTTMPDIR/valgrind.$SUFFIX.%p.log" \
		--trace-children=yes \
		--leak-check=full \
		--show-leak-kinds=all \
		--num-callers=100 \
		--error-exitcode=122 \
		--vgdb-prefix="$_NFT_TEST_VALGRIND_VGDB_PREFIX-$SUFFIX" \
		$NFT_TEST_VALGRIND_OPTS \
		"$NFT_REAL" \
		"$@" \
	|| rc=$?

if [ "$rc" -eq 122 ] ; then
	shopt -s nullglob
	FILES=( "$NFT_TEST_TESTTMPDIR/valgrind.$SUFFIX."*".log" )
	shopt -u nullglob
	(
		printf '%s\n' "args: $*"
		printf '%s\n' "${FILES[*]}"
	) >> "$NFT_TEST_TESTTMPDIR/rc-failed-valgrind"
fi

exit $rc