diff mbox series

[meta-networking,kirkstone,4/5] python3-scapy: fix ptests

Message ID 20251027201015.4098472-4-skandigraun@gmail.com
State New
Headers show
Series [meta-perl,kirkstone,1/5] libxml-libxml-perl: fix ptests | expand

Commit Message

Gyorgy Sarvari Oct. 27, 2025, 8:10 p.m. UTC
1. Enable network access during tests by setting a nameserver
2. Add missing tshark dependency
3. Install missing test files

Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
---
 .../recipes-devtools/python/python3-scapy/run-ptest |  7 +++++++
 .../recipes-devtools/python/python3-scapy_2.4.5.bb  | 13 +++++++++++++
 2 files changed, 20 insertions(+)
diff mbox series

Patch

diff --git a/meta-networking/recipes-devtools/python/python3-scapy/run-ptest b/meta-networking/recipes-devtools/python/python3-scapy/run-ptest
index 797d8ecf78..847b69af94 100644
--- a/meta-networking/recipes-devtools/python/python3-scapy/run-ptest
+++ b/meta-networking/recipes-devtools/python/python3-scapy/run-ptest
@@ -1,4 +1,11 @@ 
 #!/bin/sh
+
+if ! nslookup example.com; then
+    mv /etc/resolv.conf /etc/resolv.conf.bak
+    echo "nameserver 8.8.8.8" > /etc/resolv.conf
+    trap "mv /etc/resolv.conf.bak /etc/resolv.conf" INT EXIT
+fi
+
 UTscapy3 -t regression.uts -f text -l -C \
     -o @PTEST_PATH@/scapy_ptest_$(date +%Y%m%d-%H%M%S).log \
     2>&1 | sed -e 's/^passed None/PASS:/' -e 's/^failed None/FAIL:/'
diff --git a/meta-networking/recipes-devtools/python/python3-scapy_2.4.5.bb b/meta-networking/recipes-devtools/python/python3-scapy_2.4.5.bb
index 0f66dfd784..83f6a6026a 100644
--- a/meta-networking/recipes-devtools/python/python3-scapy_2.4.5.bb
+++ b/meta-networking/recipes-devtools/python/python3-scapy_2.4.5.bb
@@ -34,8 +34,21 @@  do_install:append() {
 do_install_ptest() {
     install -m 0644 ${S}/test/regression.uts ${D}${PTEST_PATH}
     sed -i 's,@PTEST_PATH@,${PTEST_PATH},' ${D}${PTEST_PATH}/run-ptest
+    install -D -m 0644 ${S}/test/pcaps/bad_rsn_parsing_overrides_ssid.pcap ${D}${PYTHON_SITEPACKAGES_DIR}/test/pcaps/bad_rsn_parsing_overrides_ssid.pcap
+    install -m 0644 ${S}/test/pcaps/macos.pcapng.gz ${D}${PYTHON_SITEPACKAGES_DIR}/test/pcaps/
+
+    # note1: if ipv6 isn't enabled, skip the related test (add '-K ipv6' argument)
+    # note2: to make this test work, your ISP also must support ipv6 - the test is trying
+    #        to ping google.com through ipv6.
+    if [ "${@oe.utils.all_distro_features(d, 'ipv6', 'true', 'false')}" = "false" ]; then
+        sed -i 's/UTscapy3/UTscapy3 -K ipv6/g' ${D}${PTEST_PATH}/run-ptest
+    fi
 }
 
 RDEPENDS:${PN} = "tcpdump ${PYTHON_PN}-compression ${PYTHON_PN}-cryptography ${PYTHON_PN}-netclient  \
                   ${PYTHON_PN}-netserver ${PYTHON_PN}-pydoc ${PYTHON_PN}-pkgutil ${PYTHON_PN}-shell \
                   ${PYTHON_PN}-threading ${PYTHON_PN}-numbers"
+
+RDEPENDS:${PN}-ptest += "tshark"
+
+FILES:${PN}-ptest += "${PYTHON_SITEPACKAGES_DIR}/test/pcaps"