mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 03:25:20 +00:00
tests: Link some mocks with libtest_qemu_driver.so
I've noticed some tests fail to run under valgrind with the following error: $ valgrind --leak-check=full --trace-children=yes ./qemuxmlconftest valgrind: symbol lookup error: libvirt.git/_build/tests/libdomaincapsmock.so: undefined symbol: virQEMUCapsGet But without valgrind the test passes just fine. While we usually don't want to change our code just to adhere to random tools, in this case we ought to make an exception because valgrind helps us to detect memory leaks. NB, the --trace-children=yes is needed whenever a test re-executes itself, i.e. when it uses mocks. Otherwise we'd just get (boring) result for the first invocation of main() which does nothing more than sets up the environment and calls exec(). When running the test binary without valgrind I can see the libtest_qemu_driver.so being loaded even after exec: $ LD_DEBUG=libs ./qemuxmlconftest 2>&1 | grep -e libtest_qemu_driver.so -e virQEMUCapsGet 6439: find library=libtest_qemu_driver.so [0]; searching 6439: trying file=libvirt.git/_build/tests/../src/libtest_qemu_driver.so 6439: trying file=libvirt.git/_build/tests/glibc-hwcaps/x86-64-v3/libtest_qemu_driver.so 6439: trying file=libvirt.git/_build/tests/glibc-hwcaps/x86-64-v2/libtest_qemu_driver.so 6439: trying file=libvirt.git/_build/tests/libtest_qemu_driver.so 6439: calling init: libvirt.git/_build/tests/libtest_qemu_driver.so 6439: find library=libtest_qemu_driver.so [0]; searching 6439: trying file=libvirt.git/_build/tests/libtest_qemu_driver.so 6439: calling init: libvirt.git/_build/tests/libtest_qemu_driver.so 6439: calling fini: libvirt.git/_build/tests/libtest_qemu_driver.so [0] But running the same under valgrind: $ LD_DEBUG=libs valgrind --leak-check=full --trace-children=yes ./qemuxmlconftest 2>&1 | grep -e libtest_qemu_driver.so -e virQEMUCapsGet 6515: find library=libtest_qemu_driver.so [0]; searching 6515: trying file=libvirt.git/_build/tests/../src/libtest_qemu_driver.so 6515: trying file=libvirt.git/_build/tests/glibc-hwcaps/x86-64-v3/libtest_qemu_driver.so 6515: trying file=libvirt.git/_build/tests/glibc-hwcaps/x86-64-v2/libtest_qemu_driver.so 6515: trying file=libvirt.git/_build/tests/libtest_qemu_driver.so 6515: calling init: libvirt.git/_build/tests/libtest_qemu_driver.so 6515: libvirt.git/_build/tests/libdomaincapsmock.so: error: symbol lookup error: undefined symbol: virQEMUCapsGet (fatal) valgrind: symbol lookup error: libvirt.git/_build/tests/libdomaincapsmock.so: undefined symbol: virQEMUCapsGet To me, it looks like valgrind forced linker to lookup symbols "sooner", as individual libraries are loaded. But I must admit I have no idea how valgrind does that (or if that's even valgrind's 'fault'). But fix is pretty simple: link mocks that rely on symbols from the QEMU driver with the QEMU driver, well, its test suite suitable version (libtest_qemu_driver.so). Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
eaac07755a
commit
8b133e82fc
@ -73,7 +73,6 @@ endif
|
|||||||
# * deps - additional dependencies (optional, default [])
|
# * deps - additional dependencies (optional, default [])
|
||||||
|
|
||||||
mock_libs = [
|
mock_libs = [
|
||||||
{ 'name': 'domaincapsmock' },
|
|
||||||
{ 'name': 'vircgroupmock' },
|
{ 'name': 'vircgroupmock' },
|
||||||
{ 'name': 'virdnsmasqmock' },
|
{ 'name': 'virdnsmasqmock' },
|
||||||
{ 'name': 'virfilecachemock' },
|
{ 'name': 'virfilecachemock' },
|
||||||
@ -175,7 +174,7 @@ if conf.has('WITH_QEMU')
|
|||||||
{ 'name': 'qemucaps2xmlmock' },
|
{ 'name': 'qemucaps2xmlmock' },
|
||||||
{ 'name': 'qemucapsprobemock', 'link_with': [ test_qemu_driver_lib ] },
|
{ 'name': 'qemucapsprobemock', 'link_with': [ test_qemu_driver_lib ] },
|
||||||
{ 'name': 'qemucpumock' },
|
{ 'name': 'qemucpumock' },
|
||||||
{ 'name': 'qemuhotplugmock', 'link_with': [ test_utils_qemu_lib, test_utils_lib ] },
|
{ 'name': 'qemuhotplugmock', 'link_with': [ test_qemu_driver_lib, test_utils_qemu_lib, test_utils_lib ] },
|
||||||
{ 'name': 'qemuxml2argvmock' },
|
{ 'name': 'qemuxml2argvmock' },
|
||||||
{ 'name': 'virhostidmock' },
|
{ 'name': 'virhostidmock' },
|
||||||
]
|
]
|
||||||
@ -185,6 +184,11 @@ else
|
|||||||
test_utils_qemu_monitor_lib = []
|
test_utils_qemu_monitor_lib = []
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
mock_libs += [
|
||||||
|
# domaincapsmock has some code guarded with WITH_QEMU
|
||||||
|
{ 'name': 'domaincapsmock', 'link_with': [ test_qemu_driver_lib ] },
|
||||||
|
]
|
||||||
|
|
||||||
test_file_wrapper_lib = static_library(
|
test_file_wrapper_lib = static_library(
|
||||||
'test_file_wrapper',
|
'test_file_wrapper',
|
||||||
[ 'virfilewrapper.c' ],
|
[ 'virfilewrapper.c' ],
|
||||||
|
Loading…
Reference in New Issue
Block a user