Skip to contentSkip to conversation

openl2tp: do not clobber the ptest-runner RRECOMMENDS

PATCH New Khem Raj 1 participant 3 messages Aug 19

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/3 openl2tp: do not clobber the ptest-runner RRECOMMENDS

From: Khem Raj <[email protected]>

ptest.bbclass pulls ptest-runner into the -ptest package with

    RRECOMMENDS:${PN}-ptest += "ptest-runner"

but the recipe then used a hard assignment for its own recommendation, which overwrote that and left openl2tp-ptest recommending only kernel-module-l2tp-ppp. ptest-runner was therefore never installed in the ptest image, and meta-networking-image-ptest-openl2tp skipped the whole run with "Test requires ptest-runner to be installed" instead of executing any test.

Append instead of assigning, so both recommendations survive. The openl2tp ptest now runs and passes.

---
 meta-networking/recipes-protocols/openl2tp/openl2tp_1.8.bb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta-networking/recipes-protocols/openl2tp/openl2tp_1.8.bb +1 -1
index 789ffc86ce..0d3953d35c 100644
@@ -97,4 +97,4 @@ do_install_ptest () {
 
 RDEPENDS:${PN} = "ppp ppp-l2tp bash"
 RDEPENDS:${PN}-ptest += "rpcbind procps-ps tcl"
-RRECOMMENDS:${PN}-ptest = "kernel-module-l2tp-ppp"
+RRECOMMENDS:${PN}-ptest += "kernel-module-l2tp-ppp"
author
#1 lore raw

PATCH 2/3 python3-scapy: fix UnboundLocalError in interact()

From: Khem Raj <[email protected]>

The "Emulate interact()" UTScapy regression test failed:

IPython requested but not found !
Using the default Python shell: History is disabled.
Traceback (most recent call last):
File "/usr/lib/python3.14/site-packages/scapy/main.py", line 857, in interact
banner += "\n"
UnboundLocalError: cannot access local variable banner where it is not associated with a value

scapy.main.interact() only binds "banner" in the branches handling the ipython, ptipython, ptpython and bpython shells. The test asks for ipython, which is not in the image, so scapy falls back to the plain Python shell and leaves "banner" unbound while still running the unconditional "banner += \n" for the caller-supplied mybanner.

The test is correct and the bug is in scapy, which still has it in master, so carry a patch initializing banner from banner_text before the shell-specific chain.

meta-networking-image-ptest-python3-scapy now reports PASSED=319 FAILED=0, up from PASSED=318 FAILED=1.

---
 ...-banner-for-the-default-Python-shell.patch | 44 +++++++++++++++++++
 .../python/python3-scapy_2.7.0.bb             |  1 +
 2 files changed, 45 insertions(+)
 create mode 100644 meta-networking/recipes-devtools/python/python3-scapy/0002-main-initialize-banner-for-the-default-Python-shell.patch
meta-networking/recipes-devtools/python/python3-scapy/0002-main-initialize-banner-for-the-default-Python-shell.patch new file +44 -0
new file mode 100644
index 0000000000..7de0800c31
@@ -0,0 +1,44 @@
+From 3d1f9f8043e239d6313d9b9c02a9d6ead6c32302 Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email protected]>
+Date: Thu, 20 Aug 2026 00:14:29 +0200
+Subject: [PATCH] main: initialize banner for the default Python shell
+
+interact() only assigns the local variable "banner" in the branches that
+handle the ipython, ptipython, ptpython and bpython shells. The plain
+Python shell leaves it unbound, so the unconditional
+
+    banner += "\n"
+
+in the "if mybanner is not None:" block raises
+
+    UnboundLocalError: cannot access local variable 'banner' where it is
+    not associated with a value
+
+This is easy to hit: requesting an interpreter that is not installed
+(e.g. conf.interactive_shell = "ipython" without IPython) falls back to
+conf.interactive_shell = "python", and any caller passing mybanner then
+crashes instead of getting a shell. The mybanneronly path happens to be
+safe only because it assigns banner = "" first.
+
+Initialize banner from banner_text before the shell-specific chain so it
+is always bound.
+
+Upstream-Status: Pending
+
+Signed-off-by: Khem Raj <[email protected]>
+---
+ scapy/main.py | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/scapy/main.py b/scapy/main.py
+index 990f27f..924e6dc 100644
+--- a/scapy/main.py
++++ b/scapy/main.py
+@@ -828,6 +828,7 @@ def interact(mydict=None,
+         # repl.use_ui_colorscheme("scapy")
+
+     # Extend banner text
++    banner = banner_text
+     if conf.interactive_shell in ["ipython", "ptipython"]:
+         import IPython
+         if conf.interactive_shell == "ptipython":
meta-networking/recipes-devtools/python/python3-scapy_2.7.0.bb +1 -0
index c21d2eb0e3..35a4c6fc36 100644
@@ -19,6 +19,7 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=b234ee4d69f5fce4486a80fdaf4a4263"
 SRCREV = "1de09fe85fe5c9d60ea5c6de130374e170b5bc28"
 SRC_URI = "git://github.com/secdev/scapy.git;branch=master;protocol=https;tag=v${PV} \
            file://0001-python3-scapy-skip-ICMP-regression-tests-in-ptest.patch \
+           file://0002-main-initialize-banner-for-the-default-Python-shell.patch \
            file://run-ptest"
 
 UPSTREAM_CHECK_COMMITS = "1"
author
#2 lore raw

PATCH 3/3 python3-scapy: keep UTscapy failure diagnostics in the ptest output

In reply to Khem Raj

From: Khem Raj <[email protected]>

UTscapy writes its detailed report, including the traceback of every failing test, to a file under ${PTEST_PATH}. Under testimage that path only exists inside the ephemeral image, which is discarded as soon as the run finishes, so a failure left nothing behind but a bare

    FAIL: 000.01s Emulate interact()

line and diagnosing it required rebuilding the image by hand.

Pass -F so the report expands only the failed tests, and cat it to stdout when there is one, where ptest-runner records it. A clean run is unaffected.

---
 .../python/python3-scapy/run-ptest                | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
meta-networking/recipes-devtools/python/python3-scapy/run-ptest +13 -2
index 79e435a5ac..058bcea8a0 100644
@@ -6,6 +6,17 @@ if ! nslookup example.com; then
   trap "mv /etc/resolv.conf.bak /etc/resolv.conf" INT EXIT
 fi
 
-python3 UTscapy.py -t regression.uts -f text -l -C -K skipped_ptest \
-    -o @PTEST_PATH@/scapy_ptest_$(date +%Y%m%d-%H%M%S).log \
+UTSCAPY_LOG=@PTEST_PATH@/scapy_ptest_$(date +%Y%m%d-%H%M%S).log
+
+# -F expands only the failed tests in the report, keeping it small while still
+# recording the traceback of anything that failed.
+python3 UTscapy.py -t regression.uts -f text -l -C -F -K skipped_ptest \
+    -o $UTSCAPY_LOG \
     2>&1 | sed -e 's/^passed None/PASS:/' -e 's/^failed None/FAIL:/'
+
+# The report only exists inside the ephemeral test image, so echo the details of
+# any failure to stdout, where ptest-runner records them.
+if grep -qE '^###.*=\[(failed|interrupted)\]' $UTSCAPY_LOG 2>/dev/null; then
+    echo "--- UTscapy failure details ---"
+    cat $UTSCAPY_LOG
+fi