diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2022-12-22 01:04:07 +0200 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2022-12-24 03:29:43 +0200 |
commit | 121b5de3295636e618296a018ac0baf1b0732bda (patch) | |
tree | 42bc4533a4c0828800295c09fe3e0223f4d782db /test/v4l2_compat/meson.build | |
parent | 9f06cd50cce95ffb5bdcf57b5a162a400212d2c0 (diff) |
test: v4l2_compat: Enable test with ASan
When libcamera is compiled with the address sanitizer enabled, the
v4l2_compat test generates failures in the link order runtime check, as
the host v4l2-ctl and v4l2-compliance tools are not (generally) linked
to ASan. For this reason, the test is disabled, which sadly shrinks test
coverage.
Fix this by loading the ASan runtime using LD_PRELOAD. This needs to be
done from within the v4l2_compat_test.py Python script, as the Python
interpreter itself leaks memory and would cause test failures if run
with ASan.
To LD_PRELOAD the ASan runtime, the path to the binary needs to be
known. gcc gives us a generic way to get the path, but that doesn't work
with clang as the ASan runtime file name depends on the clang version
and target architecture. We thus have to keep the v4l2_compat test
disabled when ASan is enabled and libcamera is compiled with clang.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Diffstat (limited to 'test/v4l2_compat/meson.build')
-rw-r--r-- | test/v4l2_compat/meson.build | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/test/v4l2_compat/meson.build b/test/v4l2_compat/meson.build index 10c46752..2691eacf 100644 --- a/test/v4l2_compat/meson.build +++ b/test/v4l2_compat/meson.build @@ -4,19 +4,26 @@ if not is_variable('v4l2_compat') subdir_done() endif -# If ASan is enabled, the link order runtime check will fail as v4l2-ctl and -# v4l2-compliance are not linked to ASan. Skip the test in that case. -# -# TODO: Find a way to LD_PRELOAD the ASan dynamic library instead, in a -# cross-platform way with support for both gcc and clang. +# If ASan is enabled but the ASan runtime shared library is missing, +# v4l2_compat_test.py won't be able to LD_PRELOAD it, resulting in a link order +# runtime check failure as v4l2-ctl and v4l2-compliance are not linked to ASan. +# Skip the test in that case. -if get_option('b_sanitize').contains('address') +if asan_runtime_missing + warning('Unable to get path to ASan runtime, v4l2_compat test disabled') subdir_done() endif v4l2_compat_test = files('v4l2_compat_test.py') +v4l2_compat_args = [] + +if asan_enabled + v4l2_compat_args += ['-s', asan_runtime] +endif + +v4l2_compat_args += [v4l2_compat] test('v4l2_compat_test', v4l2_compat_test, - args : v4l2_compat, + args : v4l2_compat_args, suite : 'v4l2_compat', timeout : 60) |