[meta-virtualization][wrynose][PATCH 2/2] openvswitch: re-enable ptest

Haitao Liu <[email protected]> Mon, 1 Jun 2026 17:01:45 +0800
Newsgroups org.yoctoproject.lists.meta-virtualization
Message-ID <[email protected]>
Ptest support was disabled in commit 816d4c6e0e7c due to breakage in
source handling that prevented proper installation of test files.

Fix the ptest installation by:
  - Copying test binaries from the build directory, preserving subdirectory
    structure (e.g., oss-fuzz/) for optional test components
  - Installing *.at test definitions and *.py test scripts from the source tree
  - Fixing PYTHONPATH in atlocal to use runtime paths instead of build paths
  - Symlinking schema files already provided by the main package to avoid
    file duplication

Re-enable ptest now that installation works correctly.

Test results on genericx86-64:

PASS: checkpatch - catastrophic backtracking
PASS: checkpatch - Unicode code
PASS: appctl-bashcomp - complex completion check 4
PASS: appctl-bashcomp - complex completion check 2
PASS: checkpatch - check misuse APIs
PASS: checkpatch - whitespace around cast
PASS: checkpatch - comments
PASS: checkpatch - check egrep / fgrep
PASS: checkpatch - file contents checks - bare return
PASS: checkpatch - subject
PASS: appctl-bashcomp - negative test
...
...
...
PASS: drop-stats - bridge sampling
PASS: drop-stats - sampling action
PASS: ovsdb-idl - Check Python IDL reconnects to leader - Python3 (leader only)
PASS: monitor-cond-change with many sessions pending

2658 tests were successful.
89 tests were skipped.

Signed-off-by: Haitao Liu <[email protected]>
---
 .../openvswitch/openvswitch_git.bb            | 59 ++++++++++++++++++-
 1 file changed, 56 insertions(+), 3 deletions(-)

diff --git a/recipes-networking/openvswitch/openvswitch_git.bb b/recipes-networking/openvswitch/openvswitch_git.bb
index 8dcb7ca4..a6b72b86 100644
--- a/recipes-networking/openvswitch/openvswitch_git.bb
+++ b/recipes-networking/openvswitch/openvswitch_git.bb
@@ -20,7 +20,6 @@ FILESEXTRAPATHS:append := "${THISDIR}/${PN}-git:"
 
 SRCREV = "7921d9c6924b8934ea1de9481891ac1172649280"
 SRC_URI += "git://github.com/openvswitch/ovs.git;protocol=https;branch=branch-3.7 \
-            file://openvswitch-add-ptest-71d553b995d0bd527d3ab1e9fbaf5a2ae34de2f3.patch \
             file://run-ptest \
             file://disable_m4_check.patch \
             file://systemd-update-tool-paths.patch \
@@ -50,6 +49,60 @@ inherit ptest
 EXTRA_OEMAKE += "TEST_DEST=${D}${PTEST_PATH} TEST_ROOT=${PTEST_PATH}"
 
 do_install_ptest() {
-	echo "disabled: oe_runmake test-install"
-}
 
+    install -d ${D}${PTEST_PATH}/tests/
+
+    install -m 0644 ${B}/tests/atlocal ${B}/tests/atconfig ${D}${PTEST_PATH}/tests/
+
+    # Copy test binaries into the ptest directory, preserving subdirectory structure.
+    # Use -maxdepth 2 because subdirectories like oss-fuzz/ are not enabled by default;
+    # when enabled, their binaries (e.g., ./oss-fuzz/oss) need to be copied as well.
+    cd ${B}/tests && find . -maxdepth 2 -type f -executable | xargs -I {} cp --parents {} ${D}${PTEST_PATH}/tests/
+    cd ${S}/tests && find . -maxdepth 1 -name '*.at' | xargs -I {} cp --parents {} ${D}${PTEST_PATH}/tests/
+    cd ${S}/tests && find . -maxdepth 1 -type f -executable | xargs -I {} cp --parents {} ${D}${PTEST_PATH}/tests/
+
+    cd ${S}/tests && find . -maxdepth 1 -name '*.py' -exec install -m 0755 {} ${D}${PTEST_PATH}/tests/ \;
+
+    install -D -m 0644 ${S}/vswitchd/vswitch.ovsschema ${D}${PTEST_PATH}/vswitchd/vswitch.ovsschema
+
+    install -D -m 0755 ${S}/utilities/checkpatch.py ${D}${PTEST_PATH}/utilities/checkpatch.py
+    install -D -m 0644 ${S}/utilities/ovs-pcap.in ${D}${PTEST_PATH}/utilities/ovs-pcap.in
+    install -D -m 0644 ${S}/utilities/ovs-pki.in  ${D}${PTEST_PATH}/utilities/ovs-pki.in
+
+    install -D -m 0644 ${S}/python/test_requirements.txt ${D}${PTEST_PATH}/python/test_requirements.txt
+    install -m 0644 ${S}/tests/idltest.ovsschema ${D}${PTEST_PATH}/tests/
+    install -m 0644 ${S}/tests/idltest2.ovsschema ${D}${PTEST_PATH}/tests/
+    install -m 0644 ${S}/AUTHORS.rst ${D}${PTEST_PATH}/
+    install -D -m 0644 ${S}/build-aux/check-structs ${D}${PTEST_PATH}/build-aux/check-structs
+
+    # Symlink vtep.ovsschema to the path expected by ptest; the actual file is
+    # already installed by the main openvswitch package.
+    install -d ${D}${PTEST_PATH}/vtep
+    ln -sf /usr/share/openvswitch/vtep.ovsschema ${D}${PTEST_PATH}/vtep/vtep.ovsschema
+
+    sed  -i \
+         -e 's|PYTHON=.*|PYTHON="python3"|' \
+         -e 's|PYTHONPATH=.*|PYTHONPATH=/usr/share/openvswitch/python:${PTEST_PATH}/tests:$PYTHONPATH|' \
+         -e 's|EGREP=.*|EGREP='"'"'grep -E'"'"'|g' \
+         -e 's|CFLAGS=.*|CFLAGS='"'"' '"'"'|g' \
+         ${D}${PTEST_PATH}/tests/atlocal
+
+    sed -i \
+        -e "s|^at_testdir=.*|at_testdir='${PTEST_PATH}'|" \
+        -e "s|^abs_builddir=.*|abs_builddir='${PTEST_PATH}'|" \
+        -e "s|^at_srcdir=.*|at_srcdir='${PTEST_PATH}/tests'|" \
+        -e "s|^abs_srcdir=.*|abs_srcdir='${PTEST_PATH}/tests'|" \
+        -e "s|^at_top_srcdir=.*|at_top_srcdir='${PTEST_PATH}'|" \
+        -e "s|^abs_top_srcdir=.*|abs_top_srcdir='${PTEST_PATH}'|" \
+        -e "s|^at_top_build_prefix=.*|at_top_build_prefix='${PTEST_PATH}'|" \
+        -e "s|^abs_top_builddir=.*|abs_top_builddir='${PTEST_PATH}'|" \
+         ${D}${PTEST_PATH}/tests/atconfig
+
+    sed -i \
+        -e "s|ovs-appctl-bashcomp\.bash|/etc/bash_completion.d/ovs-appctl-bashcomp\.bash|g" \
+        -e "s|ovs-vsctl-bashcomp\.bash|/etc/bash_completion.d/ovs-vsctl-bashcomp\.bash|g"   \
+        -e "s|^\(.*config\.log.*\)|#\1|g" \
+         ${D}${PTEST_PATH}/tests/testsuite
+}
+RDEPENDS:${PN}-ptest += " ${PN}-testcontroller"
+RDEPENDS:${PN}-ptest += "python3-packaging python3-setuptools"
-- 
2.34.1