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 <phrdina(a)redhat.com>
---
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 3cdeedb2308..3bc1a791a16 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
@@ -357,16 +357,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 ca6e5b5f74d..5cbd3cd2077 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 a1cd093e4e2..3f53f635fc2 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;
--
2.26.2