mirror of
https://gitlab.com/mishakmak/pam-fprint-grosshack.git
synced 2026-04-08 20:03:34 +02:00
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.
This commit is contained in:
committed by
Bastien Nocera
parent
f401f399a8
commit
184e1bd4d0
@ -177,5 +177,7 @@ output += ' PAM module: ' + pam_dep.found().to_string()
|
|||||||
output += ' Manuals: ' + get_option('man').to_string()
|
output += ' Manuals: ' + get_option('man').to_string()
|
||||||
output += ' GTK Doc: ' + get_option('gtk_doc').to_string()
|
output += ' GTK Doc: ' + get_option('gtk_doc').to_string()
|
||||||
output += ' XML Linter ' + xmllint.found().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')
|
message('\n'+'\n'.join(output)+'\n')
|
||||||
|
|||||||
4
tests/LSAN-leaks-suppress.txt
Normal file
4
tests/LSAN-leaks-suppress.txt
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
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 = [
|
tests = [
|
||||||
'fprintd',
|
'fprintd',
|
||||||
'test_fprintd_utils',
|
'test_fprintd_utils',
|
||||||
@ -81,16 +83,36 @@ foreach pt: python_tests
|
|||||||
endforeach
|
endforeach
|
||||||
endforeach
|
endforeach
|
||||||
|
|
||||||
add_test_setup('default_setup',
|
timeout_multiplier = 1
|
||||||
is_default: true,
|
test_envs = [
|
||||||
env: [
|
|
||||||
'G_SLICE=always-malloc',
|
'G_SLICE=always-malloc',
|
||||||
'MALLOC_CHECK_=2',
|
'MALLOC_CHECK_=2',
|
||||||
'MALLOC_PERTURB_=55',
|
]
|
||||||
],
|
|
||||||
|
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: 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_share = glib_dep.get_pkgconfig_variable('prefix') / 'share' / glib_dep.name()
|
||||||
glib_suppressions = glib_share + '/valgrind/glib.supp'
|
glib_suppressions = glib_share + '/valgrind/glib.supp'
|
||||||
add_test_setup('valgrind',
|
add_test_setup('valgrind',
|
||||||
|
|||||||
@ -4,11 +4,16 @@ tests = [
|
|||||||
'test_pam_fprintd',
|
'test_pam_fprintd',
|
||||||
]
|
]
|
||||||
|
|
||||||
preloaded_libs = [
|
preloaded_libs = []
|
||||||
'pam_wrapper'
|
|
||||||
]
|
|
||||||
pam_tests_ld_preload = []
|
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
|
foreach libname: preloaded_libs
|
||||||
lib = run_command(meson.get_compiler('c'),
|
lib = run_command(meson.get_compiler('c'),
|
||||||
'-print-file-name=lib@0@.so'.format(libname)
|
'-print-file-name=lib@0@.so'.format(libname)
|
||||||
|
|||||||
Reference in New Issue
Block a user