Skip to content

Commit 87cde0d

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 a6497f6 commit 87cde0d

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 [armhf]|ppc64le|s390x cross compile target"
16+
echo " -x run test with valgrind"
1617
echo ""
1718
echo "configs with meson:"
1819
echo " [default] default settings"
@@ -33,7 +34,9 @@ BUILDTYPE=release
3334
CROSS_TARGET=armhf
3435
CC=${CC:-"gcc"}
3536

36-
while getopts "b:c:m:t:" o; do
37+
use_valgrind=0
38+
39+
while getopts "b:c:m:t:x" o; do
3740
case "${o}" in
3841
b)
3942
BUILDTYPE="${OPTARG}"
@@ -47,6 +50,9 @@ while getopts "b:c:m:t:" o; do
4750
t)
4851
CROSS_TARGET="${OPTARG}"
4952
;;
53+
x)
54+
use_valgrind=1
55+
;;
5056
*)
5157
usage
5258
exit 1
@@ -125,8 +131,17 @@ build_meson() {
125131
}
126132

127133
test_meson() {
128-
"${MESON}" test \
129-
-C "${BUILDDIR}"
134+
local args=(-C "${BUILDDIR}")
135+
136+
if [ "${use_valgrind:-0}" -eq 1 ]; then
137+
if command -v valgrind >/dev/null 2>&1; then
138+
args+=(--wrapper valgrind)
139+
else
140+
echo "Warning: valgrind requested but not found; running without it." >&2
141+
fi
142+
fi
143+
144+
"${MESON}" test "${args[@]}"
130145
}
131146

132147
test_meson_coverage() {

0 commit comments

Comments
 (0)