test: py: Fix test failure when ASan is enabled
When the address sanitizer is enabled, the Python unit tests fail due to the link order runtime check as the Python interpreter is (generally) not linked to ASan. Fix this by LD_PRELOAD'ing the ASan runtime. We have to disable the leak detector as the Python interpreter itself leaks memory, which would result in test failures. 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 Python test disabled when ASan is enabled and libcamera is compiled with clang. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
This commit is contained in:
parent
121b5de329
commit
d48e15d571
1 changed files with 16 additions and 1 deletions
|
@ -4,14 +4,29 @@ if not pycamera_enabled
|
||||||
subdir_done()
|
subdir_done()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# If ASan is enabled, the link order runtime check will fail as Python is not
|
||||||
|
# linked to ASan. LD_PRELOAD the ASan runtime if available, or skip the test
|
||||||
|
# otherwise.
|
||||||
|
|
||||||
|
if asan_runtime_missing
|
||||||
|
warning('Unable to get path to ASan runtime, Python test disabled')
|
||||||
|
subdir_done()
|
||||||
|
endif
|
||||||
|
|
||||||
pymod = import('python')
|
pymod = import('python')
|
||||||
py3 = pymod.find_installation('python3')
|
py3 = pymod.find_installation('python3')
|
||||||
|
|
||||||
pypathdir = meson.project_build_root() / 'src' / 'py'
|
pypathdir = meson.project_build_root() / 'src' / 'py'
|
||||||
|
py_env = ['PYTHONPATH=' + pypathdir]
|
||||||
|
|
||||||
|
if asan_enabled
|
||||||
|
# Disable leak detection as the Python interpreter is full of leaks.
|
||||||
|
py_env += ['LD_PRELOAD=' + asan_runtime, 'ASAN_OPTIONS=detect_leaks=0']
|
||||||
|
endif
|
||||||
|
|
||||||
test('pyunittests',
|
test('pyunittests',
|
||||||
py3,
|
py3,
|
||||||
args : files('unittests.py'),
|
args : files('unittests.py'),
|
||||||
env : ['PYTHONPATH=' + pypathdir],
|
env : py_env,
|
||||||
suite : 'pybindings',
|
suite : 'pybindings',
|
||||||
is_parallel : false)
|
is_parallel : false)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue