mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-12 14:59:44 +03:00
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>
29 lines
775 B
Meson
29 lines
775 B
Meson
# SPDX-License-Identifier: CC0-1.0
|
|
|
|
if not is_variable('v4l2_compat')
|
|
subdir_done()
|
|
endif
|
|
|
|
# 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 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,
|
|
suite : 'v4l2_compat',
|
|
timeout : 60)
|