From 92abca4c3b8bde5f862bb3b724c3577a25f742af Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 8 Sep 2023 00:07:16 +0200 Subject: tests/shell: fix handling failures with VALGRIND=y With VALGRIND=y, on memleaks the tests did not fail. Fix that by passing "--error-exitcode=122" to valgrind. But just returning 122 from $NFT command may not correctly fail the test. Instead, ensure to write a "rc-failed-valrind" file, which is picked up by "test-wrapper.sh" to properly handle the valgrind failure (and fail with error code 122 itself). Also, accept NFT_TEST_VALGRIND_OPTS variable to a pass additional arguments to valgrind. For example a "--suppressions" file. Also show the special error code [VALGRIND] in "run-test.sh". Signed-off-by: Thomas Haller Signed-off-by: Florian Westphal --- tests/shell/helpers/nft-valgrind-wrapper.sh | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'tests/shell/helpers/nft-valgrind-wrapper.sh') diff --git a/tests/shell/helpers/nft-valgrind-wrapper.sh b/tests/shell/helpers/nft-valgrind-wrapper.sh index 9da50d4d..ad8cc74b 100755 --- a/tests/shell/helpers/nft-valgrind-wrapper.sh +++ b/tests/shell/helpers/nft-valgrind-wrapper.sh @@ -1,6 +1,6 @@ #!/bin/bash -e -SUFFIX="$(date '+%Y%m%d-%H%M%S.%6N')" +SUFFIX="$(date "+%Y%m%d-%H%M%S.%6N.$$")" rc=0 libtool \ @@ -10,8 +10,21 @@ libtool \ --trace-children=yes \ --leak-check=full \ --show-leak-kinds=all \ + --num-callers=100 \ + --error-exitcode=122 \ + $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 -- cgit v1.2.3