Skip to content

Commit 879ecb3

Browse files
committed
build: add valgrind test option to build script
Add the option -x which tells the script to run the tests under valgrind. Signed-off-by: Daniel Wagner <[email protected]>
1 parent c417356 commit 879ecb3

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

scripts/build.sh

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ usage() {
1313
echo " -c [gcc]|clang compiler to use"
1414
echo " -m [meson]|muon use meson or muon"
1515
echo " -t [arm]|ppc64le|s390x cross compile target"
16+
echo " -x run test with valgrind"
1617
echo ""
1718
echo "configs with meson:"
1819
echo " [default] default settings"
@@ -35,7 +36,9 @@ BUILDTYPE=release
3536
CROSS_TARGET=arm
3637
CC=${CC:-"gcc"}
3738

38-
while getopts "b:c:m:t:" o; do
39+
use_valgrind=0
40+
41+
while getopts "b:c:m:t:x" o; do
3942
case "${o}" in
4043
b)
4144
BUILDTYPE="${OPTARG}"
@@ -49,6 +52,9 @@ while getopts "b:c:m:t:" o; do
4952
t)
5053
CROSS_TARGET="${OPTARG}"
5154
;;
55+
x)
56+
use_valgrind=1
57+
;;
5258
*)
5359
usage
5460
exit 1
@@ -144,8 +150,17 @@ build_meson() {
144150
}
145151

146152
test_meson() {
147-
"${MESON}" test \
148-
-C "${BUILDDIR}"
153+
local args=(-C "${BUILDDIR}")
154+
155+
if [ "${use_valgrind:-0}" -eq 1 ]; then
156+
if command -v valgrind >/dev/null 2>&1; then
157+
args+=(--wrapper valgrind)
158+
else
159+
echo "Warning: valgrind requested but not found; running without it." >&2
160+
fi
161+
fi
162+
163+
"${MESON}" test "${args[@]}"
149164
}
150165

151166
test_meson_coverage() {

0 commit comments

Comments
 (0)