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/test-wrapper.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'tests/shell/helpers/test-wrapper.sh') diff --git a/tests/shell/helpers/test-wrapper.sh b/tests/shell/helpers/test-wrapper.sh index f8b27b1e..405e70c8 100755 --- a/tests/shell/helpers/test-wrapper.sh +++ b/tests/shell/helpers/test-wrapper.sh @@ -78,13 +78,18 @@ if [ "$rc_dump" -ne 0 ] ; then echo "$DUMPFILE" > "$NFT_TEST_TESTTMPDIR/rc-failed-dump" fi +rc_valgrind=0 +[ -f "$NFT_TEST_TESTTMPDIR/rc-failed-valgrind" ] && rc_valgrind=122 + rc_tainted=0 if [ "$tainted_before" != "$tainted_after" ] ; then echo "$tainted_after" > "$NFT_TEST_TESTTMPDIR/rc-failed-tainted" rc_tainted=123 fi -if [ "$rc_tainted" -ne 0 ] ; then +if [ "$rc_valgrind" -ne 0 ] ; then + rc_exit="$rc_valgrind" +elif [ "$rc_tainted" -ne 0 ] ; then rc_exit="$rc_tainted" elif [ "$rc_test" -ge 118 -a "$rc_test" -le 124 ] ; then # Special exit codes are reserved. Coerce them. @@ -101,9 +106,9 @@ fi # We always write the real exit code of the test ($rc_test) to one of the files # rc-{ok,skipped,failed}, depending on which it is. # -# Note that there might be other rc-failed-{dump,tainted} files with additional -# errors. Note that if such files exist, the overall state will always be -# failed too (and an "rc-failed" file exists). +# Note that there might be other rc-failed-{dump,tainted,valgrind} files with +# additional errors. Note that if such files exist, the overall state will +# always be failed too (and an "rc-failed" file exists). # # On failure, we also write the combined "$rc_exit" code from "test-wrapper.sh" # to "rc-failed-exit" file. -- cgit v1.2.3