From 830a9977c0f93600aa13312e921636cbb35147d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 13 Feb 2025 20:17:42 +0100 Subject: [PATCH] build: Support running tests with memory sanitizers When memory sanitizers are set, tests may fail because we are indirectly LD_PRELOAD'ing (through umockdev). While we could ensure that sanitizer libraries are loaded first, it's just something we don't care because we don't want to test the launcher wrappers themselves. So, let's just ignore the link order and live with it --- meson.build | 6 ++++++ tests/meson.build | 15 +++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/meson.build b/meson.build index b73876f..c6a9691 100644 --- a/meson.build +++ b/meson.build @@ -21,6 +21,12 @@ datadir = prefix / get_option('datadir') cc = meson.get_compiler('c') cpp = meson.get_compiler('cpp') host_system = host_machine.system() + +libfprint_sanitizers = get_option('b_sanitize').split(',') +if libfprint_sanitizers == ['none'] + libfprint_sanitizers = [] +endif + glib_min_version = '2.68' glib_version_def = 'GLIB_VERSION_@0@_@1@'.format( diff --git a/tests/meson.build b/tests/meson.build index b99bd22..df47631 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -332,7 +332,7 @@ test('udev-hwdb', env: envs) gdb = find_program('gdb', required: false) -if gdb.found() +if gdb.found() and libfprint_sanitizers.length() == 0 libfprint_wrapper = [ gdb.full_path(), '-batch', @@ -347,8 +347,19 @@ if gdb.found() ]) endif +if ('address' in libfprint_sanitizers or + 'undefined' in libfprint_sanitizers or + 'leak' in libfprint_sanitizers) + add_test_setup('sanitizers', + is_default: true, + timeout_multiplier: 3, + env: [ + 'ASAN_OPTIONS=verify_asan_link_order=0', + ]) +endif + valgrind = find_program('valgrind', required: false) -if valgrind.found() +if valgrind.found() and libfprint_sanitizers.length() == 0 glib_share = glib_dep.get_variable(pkgconfig: 'prefix') / 'share' / glib_dep.name() glib_suppressions = glib_share + '/valgrind/glib.supp' libfprint_suppressions = '@0@/@1@'.format(meson.project_source_root(),