All of lore.kernel.org
 help / color / mirror / Atom feed
* [meta-virtualization][PATCH] libvirt: re-add ptest support for meson build system
@ 2026-05-29  2:39 Haitao Liu
  2026-06-12 18:48 ` Bruce Ashfield
  0 siblings, 1 reply; 2+ messages in thread
From: Haitao Liu @ 2026-05-29  2:39 UTC (permalink / raw)
  To: meta-virtualization

libvirt has switched its build system from Makefile to meson, so the
original run-ptest which relied on "make -C tests -k check-TESTS" no
longer works. Re-add ptest support based on the meson build system:

- Rewrite run-ptest to directly execute the compiled test binaries
  instead of invoking make.
- Patch meson.build at configure time to replace absolute build/source
  paths with the ptest install paths, removing the need for separate
  path-stripping patches.
- Install test binaries and their required data files into the ptest
  directory.

Test results on genericx86-64:

  All 120 tests passed (0 failures, 0 skips).

root@genericx86-64:/usr/lib/libvirt/ptest# ./run-ptest
PASS: chxml2xmltest
PASS: nssguestlinktest
PASS: virbuftest
PASS: viracpitest
PASS: esxutilstest
PASS: ssh
PASS: storagepoolxml2xmltest
PASS: commandtest
...
...
PASS: nwfilterebiptablestest
PASS: cputest

=== Test Summary ===
PASS: 120
FAIL: 0
SKIP: 0
TOTAL: 120

Signed-off-by: Haitao Liu <haitao.liu@windriver.com>
---
 recipes-extended/libvirt/libvirt/run-ptest | 32 ++++++++++++++-
 recipes-extended/libvirt/libvirt_git.bb    | 45 ++++++++++++++++++++--
 2 files changed, 73 insertions(+), 4 deletions(-)

diff --git a/recipes-extended/libvirt/libvirt/run-ptest b/recipes-extended/libvirt/libvirt/run-ptest
index a434b186..dd1f94d3 100644
--- a/recipes-extended/libvirt/libvirt/run-ptest
+++ b/recipes-extended/libvirt/libvirt/run-ptest
@@ -1,3 +1,33 @@
 #!/bin/sh
 
-make -C tests -k check-TESTS
+PTEST_DIR="/usr/lib/libvirt/ptest/tests"
+export LD_LIBRARY_PATH="${PTEST_DIR}:${LD_LIBRARY_PATH}"
+PASS=0
+FAIL=0
+SKIP=0
+
+run_test() {
+    tname="$1"
+    tpath="$2"
+    "$tpath" >/dev/null 2>&1
+    rc=$?
+    case $rc in
+        0)  echo "PASS: $tname"; PASS=$((PASS + 1)) ;;
+        77) echo "SKIP: $tname"; SKIP=$((SKIP + 1)) ;;
+        *)  echo "FAIL: $tname"; FAIL=$((FAIL + 1)) ;;
+    esac
+}
+
+# Skip run-ptest (self), commandhelper and qemucapsprobe are middleware
+# used by other test cases, not test cases themselves.
+for t in $(find ${PTEST_DIR} -maxdepth 1 -type f -executable ! -name "*.so" ! -name "run-ptest" ! -name "commandhelper" ! -name "qemucapsprobe"); do
+    run_test "$(basename $t)" "$t"
+done
+
+# Summary
+echo ""
+echo "=== Test Summary ==="
+echo "PASS: $PASS"
+echo "FAIL: $FAIL"
+echo "SKIP: $SKIP"
+echo "TOTAL: $((PASS + FAIL + SKIP))"
diff --git a/recipes-extended/libvirt/libvirt_git.bb b/recipes-extended/libvirt/libvirt_git.bb
index 34a1ff21..d1d957cc 100644
--- a/recipes-extended/libvirt/libvirt_git.bb
+++ b/recipes-extended/libvirt/libvirt_git.bb
@@ -34,17 +34,16 @@ PV = "v${LIBVIRT_VERSION}+git"
 SRC_URI = "gitsm://github.com/libvirt/libvirt.git;name=libvirt;protocol=https;branch=master \
            file://libvirtd.sh \
            file://libvirtd.conf \
+           file://run-ptest \
            file://dnsmasq.conf \
            file://hook_support.py \
            file://gnutls-helper.py;subdir=${BP} \
            file://libvirt-qemu.conf \
            file://0001-prevent-gendispatch.pl-generating-build-path-in-code.patch \
-           file://0001-messon.build-remove-build-path-information-to-avoid-.patch \
-           file://0001-tests-meson-clear-absolute-directory-paths.patch \
            file://0001-qemu_nbdkit.c-use-llu-to-print-time_t.patch \
           "
 
-inherit meson gettext update-rc.d pkgconfig systemd useradd perlnative
+inherit meson gettext update-rc.d pkgconfig systemd useradd perlnative ptest
 USERADD_PACKAGES = "${PN}"
 GROUPADD_PARAM:${PN} = "-r qemu; -r kvm; -r libvirt; -r virtlogin"
 USERADD_PARAM:${PN} = "-r -g qemu -G kvm qemu"
@@ -188,6 +187,46 @@ CVE_STATUS[CVE-2023-3750] = "fixed-version: Fixed in 9.6.0, NVD tracks this as v
 # Enable the Python tool support
 require libvirt-python.inc
 
+do_configure:prepend() {
+      sed -i \
+        -e "s|meson.current_build_dir()|'${PTEST_PATH}/tests'|g" \
+        -e "s|meson.project_build_root()|'${PTEST_PATH}'|g" \
+        -e "s|meson.current_source_dir()|'${PTEST_PATH}/datas/tests'|g" \
+        -e "s|meson.project_source_root()|'${PTEST_PATH}/datas'|g" \
+        ${S}/tests/meson.build ${S}/scripts/rpcgen/tests/meson.build ${S}/tests/schemas/meson.build
+}
+
+# Guard abs_top_builddir/abs_top_srcdir defines with #ifndef to avoid
+# -Werror redefinition conflict when tests pass them via -D compile flags.
+do_configure:append() {
+      sed -i '/^#define abs_top_builddir/c\#ifndef abs_top_builddir\n#define abs_top_builddir " "\n#endif' ${B}/meson-config.h
+      sed -i '/^#define abs_top_srcdir/c\#ifndef abs_top_srcdir\n#define abs_top_srcdir " "\n#endif' ${B}/meson-config.h
+}
+
+
+do_install_ptest() {
+       install -d ${D}${PTEST_PATH}/tests
+       install -d ${D}${PTEST_PATH}/datas/tests
+        # The virshtest expects virsh at ${PTEST_PATH}/tests/tools/virsh, but it is
+        # installed to /usr/bin/virsh by libvirt-virsh. Create a symlink to satisfy
+        # the test's expected path.
+       install -d ${D}${PTEST_PATH}/tools 
+       ln -sf /usr/bin/virsh ${D}${PTEST_PATH}/tools/virsh 
+       find ${B}/tests/  -type f -executable -print -maxdepth 1 | xargs -i cp {} ${D}${PTEST_PATH}/tests -rf
+       cd ${S}/tests && find . -mindepth 1 -maxdepth 1 -type d | xargs -i cp {} ${D}${PTEST_PATH}/datas/tests -a
+       install -m 0755 ${B}/scripts/rpcgen/tests/test_demo ${D}${PTEST_PATH}/tests
+       install -m 0644 ${S}/scripts/rpcgen/tests/*.bin ${D}${PTEST_PATH}/datas/tests
+       install -D -m 0644 -t ${D}${PTEST_PATH}/datas/examples/xml/test/  ${S}/examples/xml/test/*.xml
+       install -D -m 0644 -t ${D}${PTEST_PATH}/datas/examples/xml/storage/ ${S}/examples/xml/storage/*.xml
+       install -D -m 0644 -t ${D}${PTEST_PATH}/datas/src/conf/schemas/ ${S}/src/conf/schemas/*.rng
+       install -D -m 0644 -t ${D}${PTEST_PATH}/datas/src/nwfilter/xml/ ${S}/src/nwfilter/xml/*.xml
+       install -D -m 0644 -t ${D}${PTEST_PATH}/tests/schemas/ ${B}/tests/schemas/*.rng
+       install -m 0644 ${S}/tests/openvzutilstest.conf ${D}${PTEST_PATH}/datas/tests
+       install -d ${D}${PTEST_PATH}/datas/src/network
+}
+
+RDEPENDS:${PN}-ptest += " ${PN}-virsh"
+
 do_compile() {
 	cd ${B}/src
 	# There may be race condition, but without creating these directories
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-06-12 18:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-29  2:39 [meta-virtualization][PATCH] libvirt: re-add ptest support for meson build system Haitao Liu
2026-06-12 18:48 ` Bruce Ashfield

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.