Skip to content

Commit

Permalink
common: check if Valgrind was enabled during biuld time
Browse files Browse the repository at this point in the history
Test is skipped if any Valgrind tool is required and
Valgrind was not enabled during build (VALGRIND=0)

Signed-off-by: Tomasz Gromadzki <tomasz.gromadzki@intel.com>
  • Loading branch information
grom72 committed Mar 20, 2024
1 parent 198a4c3 commit 33c2eb5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/test/RUNTESTS.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
11 changes: 11 additions & 0 deletions src/test/unittest/unittest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

#
Expand Down
8 changes: 8 additions & 0 deletions src/test/unittest/valgrind.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 33c2eb5

Please sign in to comment.