From ecfaecb7e30b2ddbddc33ad28e96343fcb0a6f58 Mon Sep 17 00:00:00 2001 From: Tomasz Gromadzki Date: Thu, 7 Dec 2023 22:36:39 +0100 Subject: [PATCH] common: check if Valgrind was enabled during biuld time Test is skipped if any Valgrind tool is required and Valgrind was not enabled during build (VALGRIND=0) Signed-off-by: Tomasz Gromadzki --- src/test/RUNTESTS.py | 8 ++++++-- src/test/unittest/unittest.sh | 11 +++++++++++ src/test/unittest/valgrind.py | 8 ++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/test/RUNTESTS.py b/src/test/RUNTESTS.py index da27e155918..ccf4355f9aa 100755 --- a/src/test/RUNTESTS.py +++ b/src/test/RUNTESTS.py @@ -121,7 +121,9 @@ def run_tests(self): continue except futils.Skip as s: - self.msg.print('{}: SKIP: {}'.format(t, s)) + self.msg.print('{}: {}SKIP{}: {}'. + format(t, futils.Color.YELLOW, + futils.Color.END, s)) except futils.Fail as f: self._test_failed(t, c, f) @@ -130,7 +132,9 @@ def run_tests(self): self._test_passed(t) except futils.Skip as s: - self.msg.print('{}: SKIP: {}'.format(tc, s)) + self.msg.print('{}: {}SKIP{}: {}'. + format(tc, futils.Color.YELLOW, + futils.Color.END, s)) except futils.Fail as f: self._test_failed(tc, c, f) ret = 1 diff --git a/src/test/unittest/unittest.sh b/src/test/unittest/unittest.sh index fcc5d90bfc5..6208c044e4e 100644 --- a/src/test/unittest/unittest.sh +++ b/src/test/unittest/unittest.sh @@ -1475,6 +1475,17 @@ function require_valgrind() { exit 0 fi fi + + # Check if Valgrind is enabled in the test build + disable_exit_on_error + ../valgrind_check/valgrind_check + ret=$? + restore_exit_on_error + if [ $ret -ne 0 ]; then + msg=$(interactive_yellow STDOUT "SKIP:") + echo -e "$UNITTEST_NAME: $msg Valgrind is required but the Valgrind support has been disabled at compile time" + exit 0 + fi } # diff --git a/src/test/unittest/valgrind.py b/src/test/unittest/valgrind.py index abbc9723727..1af65357555 100644 --- a/src/test/unittest/valgrind.py +++ b/src/test/unittest/valgrind.py @@ -200,6 +200,14 @@ def _get_valgrind_exe(self, force_enable): else: raise futils.Skip('Valgrind not found') + try: + _ = sp.check_output('./valgrind_check/valgrind_check', + shell=True, universal_newlines=True, + stderr=sp.STDOUT) + except sp.CalledProcessError: + raise futils.Skip( + 'Valgrind is required but the Valgrind support has been disabled at compile time') # noqa: E501 + valgrind_bin = path.join(path.dirname(out), 'valgrind.bin') if path.isfile(valgrind_bin): return valgrind_bin