Commit 184e1bd4 authored by Marco Trevisan's avatar Marco Trevisan Committed by Bastien Nocera
Browse files

build: Support running tests with address sanitizer

Make possible to run tests with address sanitizer to quickly check for
memory errors, although we have to disable the error exit code in case of
leaks because we have some which are due to something else down in the stack
(and LSAN suppression files doesn't allow to define the stack to ignore
as we can in valgrind).

However, we'd abort in case of memory errors anyways, so this still helps
to prevent major problems, while still logging the leaks.

In order to run pam module tests with ASAN we need to manually pass the
library to LD_PRELOAD, as we do for the wrapper.
parent f401f399
......@@ -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')
leak:initialize_device
leak:usbi_alloc_device
leak:libusb-1.0.so.*
leak:PyMem_RawMalloc
......@@ -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',
......
......@@ -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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment