]> xenbits.xensource.com Git - libvirt.git/commitdiff
tests: Deduplicate some WITH_* checks
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 14 Apr 2022 10:44:31 +0000 (12:44 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 5 May 2022 11:26:32 +0000 (13:26 +0200)
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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
tests/meson.build

index 6615111056974cdc19d8a18e1c1d1038e21fc083..1871f5e6116a4384c948878c93ae223686ae4a0b 100644 (file)
@@ -99,40 +99,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
 
@@ -154,6 +120,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 = []
@@ -191,8 +161,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 = []
@@ -207,24 +181,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
 
@@ -382,6 +338,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')
@@ -443,6 +404,10 @@ if conf.has('WITH_NSS')
       'link_with': [ nss_libvirt_guest_impl ],
     },
   ]
+
+  mock_libs += [
+    { 'name': 'nssmock' },
+  ]
 endif
 
 if conf.has('WITH_NWFILTER')
@@ -521,6 +486,10 @@ if conf.has('WITH_SECDRIVER_SELINUX')
       ]
     endif
   endif
+
+  mock_libs += [
+    { 'name': 'securityselinuxhelper' },
+  ]
 endif
 
 if conf.has('WITH_STORAGE')
@@ -571,6 +540,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(