diff --git a/meson.build b/meson.build index b86f376..9ad0e43 100644 --- a/meson.build +++ b/meson.build @@ -177,5 +177,7 @@ output += ' PAM module: ' + pam_dep.found().to_string() output += ' Manuals: ' + get_option('man').to_string() output += ' GTK Doc: ' + get_option('gtk_doc').to_string() output += ' XML Linter ' + xmllint.found().to_string() +output += '\nTest setup:\n' +output += ' With address sanitizer: ' + address_sanitizer.to_string() message('\n'+'\n'.join(output)+'\n') diff --git a/tests/LSAN-leaks-suppress.txt b/tests/LSAN-leaks-suppress.txt new file mode 100644 index 0000000..a5fc940 --- /dev/null +++ b/tests/LSAN-leaks-suppress.txt @@ -0,0 +1,4 @@ +leak:initialize_device +leak:usbi_alloc_device +leak:libusb-1.0.so.* +leak:PyMem_RawMalloc diff --git a/tests/meson.build b/tests/meson.build index 610acbc..289958a 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -16,6 +16,8 @@ python_tests = [ # } ] +address_sanitizer = get_option('b_sanitize') == 'address' + tests = [ 'fprintd', 'test_fprintd_utils', @@ -81,16 +83,36 @@ foreach pt: python_tests endforeach endforeach +timeout_multiplier = 1 +test_envs = [ + 'G_SLICE=always-malloc', + 'MALLOC_CHECK_=2', +] + +if address_sanitizer + timeout_multiplier = 3 + test_envs += [ + 'ADDRESS_SANITIZER=true', + 'ASAN_OPTIONS=@0@'.format(':'.join([ + 'abort_on_error=true', + 'symbolize=true', + ])), + 'LSAN_OPTIONS=@0@'.format(':'.join([ + 'exitcode=0', + 'strict_string_checks=true', + 'suppressions=@0@'.format( + files(meson.current_source_dir() / 'LSAN-leaks-suppress.txt')[0]), + ])), + ] +endif + add_test_setup('default_setup', is_default: true, - env: [ - 'G_SLICE=always-malloc', - 'MALLOC_CHECK_=2', - 'MALLOC_PERTURB_=55', - ], + env: test_envs, + timeout_multiplier: timeout_multiplier ) -if find_program('valgrind', required: false).found() +if not address_sanitizer and find_program('valgrind', required: false).found() glib_share = glib_dep.get_pkgconfig_variable('prefix') / 'share' / glib_dep.name() glib_suppressions = glib_share + '/valgrind/glib.supp' add_test_setup('valgrind', diff --git a/tests/pam/meson.build b/tests/pam/meson.build index f738f00..15a9e57 100644 --- a/tests/pam/meson.build +++ b/tests/pam/meson.build @@ -4,11 +4,16 @@ tests = [ 'test_pam_fprintd', ] -preloaded_libs = [ - 'pam_wrapper' -] +preloaded_libs = [] pam_tests_ld_preload = [] +if address_sanitizer + # ASAN has to be the first in list + preloaded_libs += 'asan' +endif + +preloaded_libs += 'pam_wrapper' + foreach libname: preloaded_libs lib = run_command(meson.get_compiler('c'), '-print-file-name=lib@0@.so'.format(libname)