[PATCH 0/2] test: Link qemuhotplugmock with test_utils_qemu and test_utils

This is an alternative version to: https://listman.redhat.com/archives/libvir-list/2022-April/230092.html Michal Prívozník (2): test: Link qemuhotplugmock with test_utils_qemu and test_utils tests: Deduplicate some WITH_* checks tests/meson.build | 94 +++++++++++++++++++++-------------------------- 1 file changed, 41 insertions(+), 53 deletions(-) -- 2.35.1

As of ad81aa8ad07 the qemuhotplugmock.c calls testQemuPrepareHostBackendChardevOne() which is implemented in testutilsqemu.c. However, the mock is not linked with testutilsqemu static library which makes some tools (valgrind particularly) unhappy because the resulting mock library has unresolved symbol. The fix is simple, link mock library with test_utils_qemu_lib and also with test_utils_lib since testutils.c calls some functions from testutils.c. Since these two libraries are declared only after mock_libs[], I had to move the line that declares qemuhotplugmock after those two. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- tests/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/meson.build b/tests/meson.build index fd78d8a2fd..8d613d23f2 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -107,7 +107,6 @@ if conf.has('WITH_QEMU') mock_libs += [ { 'name': 'qemucaps2xmlmock' }, { 'name': 'qemucpumock' }, - { 'name': 'qemuhotplugmock' }, { 'name': 'qemuxml2argvmock' }, { 'name': 'virhostidmock' }, ] @@ -178,6 +177,7 @@ if conf.has('WITH_QEMU') mock_libs += [ { 'name': 'qemucapsprobemock', 'link_with': [ test_qemu_driver_lib ] }, + { 'name': 'qemuhotplugmock', 'link_with': [ test_utils_qemu_lib, test_utils_lib ] }, ] else test_qemu_driver_lib = [] -- 2.35.1

When constructing mock_libs array it is firstly initialized to a static set of mocks followed by couple of WITH_* checks to append driver specific mocks. These checks are then repeated when filling some other variables (e.g. supplementary helpers, libraries, tests, etc.). Dissolve the former in the latter since we are already doing that, partially, for qemu (qemucapsprobemock and qemuhotplugmock) Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- tests/meson.build | 92 +++++++++++++++++++++-------------------------- 1 file changed, 40 insertions(+), 52 deletions(-) diff --git a/tests/meson.build b/tests/meson.build index 8d613d23f2..9b9fcaa622 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -84,40 +84,6 @@ if host_machine.system() == 'linux' ] endif -if conf.has('WITH_BHYVE') - mock_libs += [ - { 'name': 'bhyveargv2xmlmock' }, - { 'name': 'bhyvexml2argvmock' }, - ] -endif - -if conf.has('WITH_LIBXL') - mock_libs += [ - { 'name': 'xlmock', 'sources': [ 'libxlmock.c' ], 'deps': [ libxl_dep ] }, - ] -endif - -if conf.has('WITH_NSS') - mock_libs += [ - { 'name': 'nssmock' }, - ] -endif - -if conf.has('WITH_QEMU') - mock_libs += [ - { 'name': 'qemucaps2xmlmock' }, - { 'name': 'qemucpumock' }, - { 'name': 'qemuxml2argvmock' }, - { 'name': 'virhostidmock' }, - ] -endif - -if conf.has('WITH_SECDRIVER_SELINUX') - mock_libs += [ - { 'name': 'securityselinuxhelper' }, - ] -endif - # build libraries used by tests @@ -139,6 +105,10 @@ if conf.has('WITH_LIBXL') link_whole: [ libxl_driver_imp ], link_with: [ libvirt_lib ], ) + + mock_libs += [ + { 'name': 'xlmock', 'sources': [ 'libxlmock.c' ], 'deps': [ libxl_dep ] }, + ] else test_utils_xen_lib = [] test_xen_driver_lib = [] @@ -176,8 +146,12 @@ if conf.has('WITH_QEMU') ) mock_libs += [ + { 'name': 'qemucaps2xmlmock' }, { 'name': 'qemucapsprobemock', 'link_with': [ test_qemu_driver_lib ] }, + { 'name': 'qemucpumock' }, { 'name': 'qemuhotplugmock', 'link_with': [ test_utils_qemu_lib, test_utils_lib ] }, + { 'name': 'qemuxml2argvmock' }, + { 'name': 'virhostidmock' }, ] else test_qemu_driver_lib = [] @@ -192,24 +166,6 @@ test_file_wrapper_lib = static_library( ) tests_deps = [] -foreach mock : mock_libs - tests_deps += shared_library( - mock['name'], - mock.get('sources', [ '@0@.c'.format(mock['name']) ]), - override_options: [ - 'b_asneeded=false', - 'b_lundef=false', - ], - dependencies: [ - tests_dep, - mock.get('deps', []), - ], - link_with: [ - libvirt_lib, - mock.get('link_with', []), - ], - ) -endforeach # build helpers used by tests @@ -367,6 +323,11 @@ if conf.has('WITH_BHYVE') { 'name': 'bhyvexml2argvtest', 'link_with': [ bhyve_driver_impl ] }, { 'name': 'bhyvexml2xmltest', 'link_with': [ bhyve_driver_impl ] }, ] + + mock_libs += [ + { 'name': 'bhyveargv2xmlmock' }, + { 'name': 'bhyvexml2argvmock' }, + ] endif if conf.has('WITH_ESX') @@ -428,6 +389,10 @@ if conf.has('WITH_NSS') 'link_with': [ nss_libvirt_guest_impl ], }, ] + + mock_libs += [ + { 'name': 'nssmock' }, + ] endif if conf.has('WITH_NWFILTER') @@ -506,6 +471,10 @@ if conf.has('WITH_SECDRIVER_SELINUX') ] endif endif + + mock_libs += [ + { 'name': 'securityselinuxhelper' }, + ] endif if conf.has('WITH_STORAGE') @@ -556,6 +525,25 @@ if conf.has('WITH_YAJL') ] endif +foreach mock : mock_libs + tests_deps += shared_library( + mock['name'], + mock.get('sources', [ '@0@.c'.format(mock['name']) ]), + override_options: [ + 'b_asneeded=false', + 'b_lundef=false', + ], + dependencies: [ + tests_dep, + mock.get('deps', []), + ], + link_with: [ + libvirt_lib, + mock.get('link_with', []), + ], + ) +endforeach + foreach data : tests test_sources = '@0@.c'.format(data['name']) test_bin = executable( -- 2.35.1

On 4/25/22 12:37, Michal Privoznik wrote:
This is an alternative version to:
https://listman.redhat.com/archives/libvir-list/2022-April/230092.html
Michal Prívozník (2): test: Link qemuhotplugmock with test_utils_qemu and test_utils tests: Deduplicate some WITH_* checks
tests/meson.build | 94 +++++++++++++++++++++-------------------------- 1 file changed, 41 insertions(+), 53 deletions(-)
Polite ping. Michal

On a Monday in 2022, Michal Privoznik wrote:
This is an alternative version to:
https://listman.redhat.com/archives/libvir-list/2022-April/230092.html
Michal Prívozník (2): test: Link qemuhotplugmock with test_utils_qemu and test_utils tests: Deduplicate some WITH_* checks
tests/meson.build | 94 +++++++++++++++++++++-------------------------- 1 file changed, 41 insertions(+), 53 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

On Thu, May 05, 2022 at 01:20:54PM +0200, Ján Tomko wrote:
On a Monday in 2022, Michal Privoznik wrote:
This is an alternative version to:
https://listman.redhat.com/archives/libvir-list/2022-April/230092.html
Michal Prívozník (2): test: Link qemuhotplugmock with test_utils_qemu and test_utils tests: Deduplicate some WITH_* checks
tests/meson.build | 94 +++++++++++++++++++++-------------------------- 1 file changed, 41 insertions(+), 53 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This series appears to have broken clang asan builds on Ubuntu 20.04 https://gitlab.com/libvirt/libvirt/-/jobs/2417680559 With regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

On 5/6/22 12:06, Daniel P. Berrangé wrote:
On Thu, May 05, 2022 at 01:20:54PM +0200, Ján Tomko wrote:
On a Monday in 2022, Michal Privoznik wrote:
This is an alternative version to:
https://listman.redhat.com/archives/libvir-list/2022-April/230092.html
Michal Prívozník (2): test: Link qemuhotplugmock with test_utils_qemu and test_utils tests: Deduplicate some WITH_* checks
tests/meson.build | 94 +++++++++++++++++++++-------------------------- 1 file changed, 41 insertions(+), 53 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This series appears to have broken clang asan builds on Ubuntu 20.04
Yep, I've posted fix earlier today: https://listman.redhat.com/archives/libvir-list/2022-May/230750.html Michal
participants (4)
-
Daniel P. Berrangé
-
Ján Tomko
-
Michal Privoznik
-
Michal Prívozník