[glib: 1/2] build: Use add_test_setup() to allow tests to be run under valgrind
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 1/2] build: Use add_test_setup() to allow tests to be run under valgrind
- Date: Mon, 20 Jun 2022 11:09:58 +0000 (UTC)
commit f5baecdb362efb6afc3f2cfa6baad3cd324267f8
Author: Philip Withnall <pwithnall endlessos org>
Date: Thu Jun 16 11:01:04 2022 +0100
build: Use add_test_setup() to allow tests to be run under valgrind
This means we can specify the standard options for testing GLib under
valgrind consistently, so that developers can use `meson test
--setup=valgrind` to run them.
Port the existing valgrind CI to use them (this will not change its
functional behaviour).
Suggested by Marco Trevisan at
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2717#note_1478891.
Signed-off-by: Philip Withnall <pwithnall endlessos org>
.gitlab-ci.yml | 3 +--
meson.build | 24 ++++++++++++++++++++++++
2 files changed, 25 insertions(+), 2 deletions(-)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 6673c237b6..7e7f6cbdc0 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -225,8 +225,7 @@ valgrind:
# See https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2710
- ulimit -Sn 1024
- bash -x ./.gitlab-ci/run-tests.sh
- --wrap "valgrind --tool=memcheck --error-exitcode=1 --track-origins=yes --leak-check=full
--leak-resolution=high --num-callers=50 --show-leak-kinds=definite,possible --show-error-list=yes
--suppressions=${CI_PROJECT_DIR}/tools/glib.supp"
- --no-suite no-valgrind
+ --setup valgrind
--no-suite slow
# FIXME: Remove this when we have zero valgrind leaks.
# https://gitlab.gnome.org/GNOME/glib/issues/333
diff --git a/meson.build b/meson.build
index ee0a6234c4..7f4bae4a0d 100644
--- a/meson.build
+++ b/meson.build
@@ -102,6 +102,30 @@ installed_tests_template_tap = files('tests/template-tap.test.in')
# Don’t build the tests unless we can run them (either natively, in an exe wrapper, or by installing them
for later use)
build_tests = get_option('tests') and (meson.can_run_host_binaries() or installed_tests_enabled)
+# Allow the tests to be easily run under valgrind using --setup=valgrind
+valgrind = find_program('valgrind', required: false)
+if valgrind.found()
+ suppression_file = files('tools' / 'glib.supp')
+
+ add_test_setup('valgrind',
+ exclude_suites: [ 'no-valgrind' ],
+ exe_wrapper: [
+ valgrind,
+ '--tool=memcheck',
+ '--error-exitcode=1',
+ '--track-origins=yes',
+ '--leak-check=full',
+ '--leak-resolution=high',
+ '--num-callers=50',
+ '--show-leak-kinds=definite,possible',
+ '--show-error-list=yes',
+ '--suppressions=@0@'.format(meson.project_source_root() /
+ '@0@'.format(suppression_file[0])),
+ ],
+ timeout_multiplier: 10,
+ )
+endif
+
add_project_arguments('-D_GNU_SOURCE', language: 'c')
if host_system == 'qnx'
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]