diff mbox series

[meta-networking,2/3] python3-scapy: fix ptests

Message ID 20251026205118.2439308-2-skandigraun@gmail.com
State New
Headers show
Series [meta-networking,1/3] lksctp-tools: move ptest from problem-list to slow-list | expand

Commit Message

Gyorgy Sarvari Oct. 26, 2025, 8:51 p.m. UTC
1. Install missing test files
2. Enable network access by setting a nameserver in resolv.conf
   because some tests require this
3. One test tries to ping Google through IPv6 - this test requires
   ipv6 DISTRO_FEATURE. In case ipv6 is not enabled, skip this test
   from the run-ptest script.

NB: the last mentioned test to work  also requires IPv6 support from
your ISP. My ISP is IPv4-only, and I couldn't try it out. The above
comes from my reading of the testcode.

Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
---
 .../include/ptest-packagelists-meta-networking.inc   |  2 +-
 .../recipes-devtools/python/python3-scapy/run-ptest  |  7 +++++++
 .../recipes-devtools/python/python3-scapy_2.6.0.bb   | 12 ++++++++++++
 3 files changed, 20 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/meta-networking/conf/include/ptest-packagelists-meta-networking.inc b/meta-networking/conf/include/ptest-packagelists-meta-networking.inc
index 408b559da2..838aee94d3 100644
--- a/meta-networking/conf/include/ptest-packagelists-meta-networking.inc
+++ b/meta-networking/conf/include/ptest-packagelists-meta-networking.inc
@@ -20,6 +20,7 @@  PTESTS_FAST_META_NETWORKING = "\
     mbedtls \
     openhpi \
     openl2tp \
+    python3-scapy \
     squid \
     tcpdump \
     wolfssl \
@@ -41,7 +42,6 @@  PTESTS_SLOW_META_NETWORKING = "\
 
 PTESTS_PROBLEMS_META_NETWORKING = "\
     nftables \
-    python3-scapy \
 "
 PTESTS_PROBLEMS_META_NETWORKING:append:libc-musl = "\
     libtalloc \
diff --git a/meta-networking/recipes-devtools/python/python3-scapy/run-ptest b/meta-networking/recipes-devtools/python/python3-scapy/run-ptest
index 417e21053c..5c166b7ba0 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
+
 python3 UTscapy.py -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.6.0.bb b/meta-networking/recipes-devtools/python/python3-scapy_2.6.0.bb
index fdef5473ef..2086b018d6 100644
--- a/meta-networking/recipes-devtools/python/python3-scapy_2.6.0.bb
+++ b/meta-networking/recipes-devtools/python/python3-scapy_2.6.0.bb
@@ -30,9 +30,19 @@  do_install:append() {
 }
 
 do_install_ptest() {
+    install -d ${D}${libdir}/test/pcaps
     install -m 0644 ${S}/scapy/tools/UTscapy.py ${D}${PTEST_PATH}
     install -m 0644 ${S}/test/regression.uts ${D}${PTEST_PATH}
+    install -m 0644 ${S}/test/pcaps/bad_rsn_parsing_overrides_ssid.pcap ${D}${libdir}/test/pcaps/
+    install -m 0644 ${S}/test/pcaps/macos.pcapng.gz ${D}${libdir}/test/pcaps/
     sed -i 's,@PTEST_PATH@,${PTEST_PATH},' ${D}${PTEST_PATH}/run-ptest
+
+    # 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/UTscapy.py/UTscapy.py -K ipv6/g' ${D}${PTEST_PATH}/run-ptest
+    fi
 }
 
 RDEPENDS:${PN} = "tcpdump python3-compression python3-cryptography python3-netclient  \
@@ -41,3 +51,5 @@  RDEPENDS:${PN} = "tcpdump python3-compression python3-cryptography python3-netcl
                   python3-difflib"
 RDEPENDS:${PN}-ptest += "python3-json python3-mock python3-multiprocessing \
                          iproute2 tshark"
+
+FILES:${PN}-ptest += "${libdir}/test/"