From 401aa32fdbe605f86891cad0c2bcb6ccce9340a8 Mon Sep 17 00:00:00 2001 From: Pavel Hrdina Date: Thu, 18 Jun 2020 02:01:49 +0200 Subject: [PATCH] meson: tests: built utils static libraries With the old build system we just list the source files directly for each test, but this would not work as expected with Meson. For every binary there is a separate directory with its object files which would mean all the utils sources would be compiled repeatedly for every test using them. Having static libraries ensures that the utils sources are compiled only once. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa Reviewed-by: Neal Gompa --- tests/Makefile.am | 10 +-------- tests/meson.build | 53 +++++++++++++++++++++++++++++++++++++++++++++++ tests/testutils.c | 2 +- 3 files changed, 55 insertions(+), 10 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 011cda7b31..a8fea66f1d 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -137,7 +137,7 @@ test_programs += qemuxml2argvtest qemuxml2xmltest \ qemuvhostusertest \ $(NULL) test_helpers += qemucapsprobe -test_libraries += libqemumonitortestutils.la \ +test_libraries += \ libqemutestdriver.la \ $(NULL) endif WITH_QEMU @@ -352,16 +352,8 @@ libxlxml2domconfigtest_LDADD = libxltestdriver.la \ $(libxl_LDADDS) $(LIBXML_LIBS) endif WITH_LIBXL -QEMUMONITORTESTUTILS_SOURCES = \ - qemumonitortestutils.c \ - qemumonitortestutils.h \ - testutilsqemuschema.h testutilsqemuschema.c \ - $(NULL) - if WITH_QEMU -libqemumonitortestutils_la_SOURCES = $(QEMUMONITORTESTUTILS_SOURCES) - qemu_LDADDS = ../src/libvirt_driver_qemu_impl.la if WITH_DTRACE_PROBES qemu_LDADDS += ../src/libvirt_qemu_probes.lo diff --git a/tests/meson.build b/tests/meson.build index ca6e5b5f74..5cbd3cd207 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -117,3 +117,56 @@ foreach mock : mock_libs ], ) endforeach + + +# build libraries used by tests + +test_utils_lib = static_library( + 'test_utils', + [ 'testutils.c' ], + dependencies: [ tests_dep ], +) + +if conf.has('WITH_LIBXL') + test_utils_xen_lib = static_library( + 'test_utils_xen', + [ 'testutilsxen.c' ], + dependencies: [ tests_dep ], + ) + +else + test_utils_xen_lib = [] +endif + +if conf.has('WITH_LXC') + test_utils_lxc_lib = static_library( + 'test_utils_lxc', + [ 'testutilslxc.c' ], + dependencies: [ tests_dep ], + ) +else + test_utils_lxc_lib = [] +endif + +if conf.has('WITH_QEMU') + test_utils_qemu_lib = static_library( + 'test_utils_qemu', + [ 'testutilsqemu.c' ], + dependencies: [ tests_dep ], + ) + + test_utils_qemu_monitor_lib = static_library( + 'test_utils_qemu_monitor', + [ 'qemumonitortestutils.c', 'testutilsqemuschema.c' ], + dependencies: [ tests_dep ], + ) +else + test_utils_qemu_lib = [] + test_utils_qemu_monitor_lib = [] +endif + +test_file_wrapper_lib = static_library( + 'test_file_wrapper', + [ 'virfilewrapper.c' ], + dependencies: [ tests_dep ], +) diff --git a/tests/testutils.c b/tests/testutils.c index a1cd093e4e..3f53f635fc 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -340,7 +340,7 @@ virTestRewrapFile(const char *filename) script = g_strdup_printf("%s/scripts/test-wrap-argv.py", abs_top_srcdir); - cmd = virCommandNewArgList(PYTHON, script, "--in-place", filename, NULL); + cmd = virCommandNewArgList(PYTHON3, script, "--in-place", filename, NULL); if (virCommandRun(cmd, NULL) < 0) return -1;