Skip to contentSkip to conversation

libpcap: add ptest support

PATCH Superseded Pratik Farkase 2 participants 5 messages Sep 28 – Sep 30

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libpcap: add ptest support

Build libpcap's upstream testprogs and run the TESTrun harness under ptest. The harness drives filtertest, translatetest and enumeratetest to compile and translate BPF filter expressions against bundled savefiles and compares the results with the embedded expected output. These tests are offline and deterministic and need no capture privileges or network.

---
 .../distro/include/ptest-packagelists.inc     |  1 +
 .../libpcap/files/run-ptest                   | 30 ++++++++++++++
 .../libpcap/libpcap_1.11.0.bb                 | 39 ++++++++++++++++++-
 3 files changed, 68 insertions(+), 2 deletions(-)
 create mode 100644 meta/recipes-connectivity/libpcap/files/run-ptest
meta/conf/distro/include/ptest-packagelists.inc +1 -0
index 7d0a9148bc..3ba103de06 100644
@@ -136,6 +136,7 @@ PTESTS_SLOW = "\
     libevent \
     libgcrypt \
     libmodule-build-perl \
+    libpcap \
     libpng \
     ${@bb.utils.contains('DISTRO_FEATURES', 'seccomp', 'libseccomp', '',d)} \
     lttng-tools \
meta/recipes-connectivity/libpcap/files/run-ptest new file +25 -0
new file mode 100644
index 0000000000..cc0e1862ac
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+cd "$(dirname "$0")/testprogs" || exit 1
+
+FILTERTEST_BIN="./filtertest"
+TRANSLATETEST_BIN="./translatetest"
+ENUMERATETEST_BIN="./enumeratetest"
+CONFIG_H="../config.h"
+export FILTERTEST_BIN TRANSLATETEST_BIN ENUMERATETEST_BIN CONFIG_H
+
+./TESTrun --passed --skipped 2>&1 | awk '
+    /^Passed tests:/  { section = "PASS"; next }
+    /^Skipped tests:/ { section = "SKIP"; next }
+    /^Failed tests:/  { section = "FAIL"; next }
+    /^-+$/            { section = ""; next }
+    section != "" && /^    / {
+        c = index($0, ": ")
+        if (c >= 45) {
+            label = substr($0, 5, c - 5)
+            sub(/[[:space:]]+$/, "", label)
+            if (label != "")
+                print section ": " label
+        }
+    }
+'
meta/recipes-connectivity/libpcap/libpcap_1.11.0.bb +33 -2
index df63ab68b8..ad4e64861d 100644
@@ -10,10 +10,12 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=5eb289217c160e2920d2e35bddc36453 \
                     file://pcap.h;beginline=1;endline=32;md5=39af3510e011f34b8872f120b1dc31d2"
 DEPENDS = "flex-native bison-native"
 
-SRC_URI = "https://www.tcpdump.org/release/${BP}.tar.xz"
+SRC_URI = "https://www.tcpdump.org/release/${BP}.tar.xz \
+           file://run-ptest \
+           "
 SRC_URI[sha256sum] = "9237f5bae9dcf3a91823d9963ec43b7c0e2e3374ef2ad57d92c8cd39530f4723"
 
-inherit autotools binconfig-disabled pkgconfig
+inherit autotools binconfig-disabled pkgconfig ptest
 
 BINCONFIG = "${bindir}/pcap-config"
 
@@ -36,4 +38,33 @@ do_configure:prepend () {
     sed 's|\([ "^'\''I]\+\)/usr/include/|\1${STAGING_INCDIR}/|g' -i ${S}/configure.ac
 }
 
+do_compile_ptest() {
+    oe_runmake -C ${B}/testprogs CFLAGS="${CFLAGS} ${LDFLAGS}" \
+        filtertest translatetest enumeratetest
+}
+
+do_install_ptest() {
+    install -d ${D}${PTEST_PATH}/testprogs
+    install -d ${D}${PTEST_PATH}/tests
+
+    # Perl harness and its helper modules.
+    install -m 0755 ${S}/testprogs/TESTrun ${D}${PTEST_PATH}/testprogs/
+    install -m 0644 ${S}/testprogs/TESTlib.pm ${D}${PTEST_PATH}/testprogs/
+    install -m 0644 ${S}/testprogs/TESTst.pm ${D}${PTEST_PATH}/testprogs/
+    install -m 0644 ${S}/testprogs/TESTmt.pm ${D}${PTEST_PATH}/testprogs/
+
+    # Offline test programs driven by the harness.
+    install -m 0755 ${B}/testprogs/filtertest ${D}${PTEST_PATH}/testprogs/
+    install -m 0755 ${B}/testprogs/translatetest ${D}${PTEST_PATH}/testprogs/
+    install -m 0755 ${B}/testprogs/enumeratetest ${D}${PTEST_PATH}/testprogs/
+
+    # Savefiles used by the filter tests (SAVEFILE_DIR is testprogs/../tests).
+    cp -r ${S}/tests/* ${D}${PTEST_PATH}/tests/
+
+    # config.h is read by TESTrun for feature-based test skipping.
+    install -m 0644 ${B}/config.h ${D}${PTEST_PATH}/config.h
+}
+
+RDEPENDS:${PN}-ptest += "perl perl-modules coreutils diffutils"
+
 BBCLASSEXTEND = "native nativesdk"
Signature · 1 line
2.43.0
#1 lore raw

PATCH v2 1/1 libpcap: add ptest support

Build libpcap's upstream testprogs and run the TESTrun harness under ptest. The harness drives filtertest, translatetest and enumeratetest to compile and translate BPF filter expressions against bundled savefiles and compares the results with the embedded expected output. These tests are offline and deterministic and need no capture privileges or network.

Tested on qemux86-64 with ptest-runner: 14801 passed, 0 failed.

---

Changes in v2:
- run-ptest now reports one PASS/SKIP/FAIL line per test case instead of a single result for the whole harness.

 .../distro/include/ptest-packagelists.inc     |  1 +
 .../libpcap/files/run-ptest                   | 25 +++++++++++++
 .../libpcap/libpcap_1.11.0.bb                 | 35 +++++++++++++++++--
 3 files changed, 59 insertions(+), 2 deletions(-)
 create mode 100644 meta/recipes-connectivity/libpcap/files/run-ptest
meta/conf/distro/include/ptest-packagelists.inc +1 -0
index 7d0a9148bc..3ba103de06 100644
@@ -136,6 +136,7 @@ PTESTS_SLOW = "\
     libevent \
     libgcrypt \
     libmodule-build-perl \
+    libpcap \
     libpng \
     ${@bb.utils.contains('DISTRO_FEATURES', 'seccomp', 'libseccomp', '',d)} \
     lttng-tools \
meta/recipes-connectivity/libpcap/files/run-ptest new file +25 -0
new file mode 100644
index 0000000000..c4b869d541
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+cd "$(dirname "$0")/testprogs" || exit 1
+
+FILTERTEST_BIN="./filtertest"
+TRANSLATETEST_BIN="./translatetest"
+ENUMERATETEST_BIN="./enumeratetest"
+CONFIG_H="../config.h"
+export FILTERTEST_BIN TRANSLATETEST_BIN ENUMERATETEST_BIN CONFIG_H
+
+./TESTrun --passed --skipped 2>&1 | awk '
+    /^Passed tests:/  { section = "PASS"; next }
+    /^Skipped tests:/ { section = "SKIP"; next }
+    /^Failed tests:/  { section = "FAIL"; next }
+    /^-+$/            { section = ""; next }
+    section != "" && /^    / {
+        c = index($0, ": ")
+        if (c >= 45) {
+            label = substr($0, 5, c - 5)
+            sub(/[[:space:]]+$/, "", label)
+            if (label != "")
+                print section ": " label
+        }
+    }
+'
meta/recipes-connectivity/libpcap/libpcap_1.11.0.bb +33 -2
index df63ab68b8..ef1ff0fff8 100644
@@ -10,10 +10,12 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=5eb289217c160e2920d2e35bddc36453 \
                     file://pcap.h;beginline=1;endline=32;md5=39af3510e011f34b8872f120b1dc31d2"
 DEPENDS = "flex-native bison-native"
 
-SRC_URI = "https://www.tcpdump.org/release/${BP}.tar.xz"
+SRC_URI = "https://www.tcpdump.org/release/${BP}.tar.xz \
+           file://run-ptest \
+           "
 SRC_URI[sha256sum] = "9237f5bae9dcf3a91823d9963ec43b7c0e2e3374ef2ad57d92c8cd39530f4723"
 
-inherit autotools binconfig-disabled pkgconfig
+inherit autotools binconfig-disabled pkgconfig ptest
 
 BINCONFIG = "${bindir}/pcap-config"
 
@@ -36,4 +38,33 @@ do_configure:prepend () {
     sed 's|\([ "^'\''I]\+\)/usr/include/|\1${STAGING_INCDIR}/|g' -i ${S}/configure.ac
 }
 
+do_compile_ptest() {
+    oe_runmake -C ${B}/testprogs CFLAGS="${CFLAGS} ${LDFLAGS}" \
+        filtertest translatetest enumeratetest
+}
+
+do_install_ptest() {
+    install -d ${D}${PTEST_PATH}/testprogs
+    install -d ${D}${PTEST_PATH}/tests
+
+    # Perl harness and its helper modules.
+    install -m 0755 ${S}/testprogs/TESTrun ${D}${PTEST_PATH}/testprogs/
+    install -m 0644 ${S}/testprogs/TESTlib.pm ${D}${PTEST_PATH}/testprogs/
+    install -m 0644 ${S}/testprogs/TESTst.pm ${D}${PTEST_PATH}/testprogs/
+    install -m 0644 ${S}/testprogs/TESTmt.pm ${D}${PTEST_PATH}/testprogs/
+
+    # Offline test programs driven by the harness.
+    install -m 0755 ${B}/testprogs/filtertest ${D}${PTEST_PATH}/testprogs/
+    install -m 0755 ${B}/testprogs/translatetest ${D}${PTEST_PATH}/testprogs/
+    install -m 0755 ${B}/testprogs/enumeratetest ${D}${PTEST_PATH}/testprogs/
+
+    # Savefiles used by the filter tests (SAVEFILE_DIR is testprogs/../tests).
+    cp -r ${S}/tests/* ${D}${PTEST_PATH}/tests/
+
+    # config.h is read by TESTrun for feature-based test skipping.
+    install -m 0644 ${B}/config.h ${D}${PTEST_PATH}/config.h
+}
+
+RDEPENDS:${PN}-ptest += "perl perl-modules coreutils diffutils"
+
 BBCLASSEXTEND = "native nativesdk"
Signature · 1 line
2.43.0
#2 lore raw
Quoted 10 lines · Pratik Farkase

Build libpcap's upstream testprogs and run the TESTrun harness under ptest. The harness drives filtertest, translatetest and enumeratetest to compile and translate BPF filter expressions against bundled savefiles and compares the results with the embedded expected output. These tests are offline and deterministic and need no capture privileges or network.

Tested on qemux86-64 with ptest-runner: 14801 passed, 0 failed.

---

Hi Pratik,

Thanks for adding tests. It looks like this is failing on riscv64, probably because of the performances of the qemu machine:

AssertionError:
Failed ptests:
{'libpcap': 'START: ptest-runner\n'

            '2026-09-29T12:01\n'
            'Timeout! System state:\n'
            'Collected system state:\n'
            '+ dmesg\n'
	    ...
	    '\n'
            'ERROR: Exited from signal Killed (9)\n'
            'DURATION: 451\n'}

I did happen on my two runs:

https://autobuilder.yoctoproject.org/valkyrie/#/builders/56/builds/2498
https://autobuilder.yoctoproject.org/valkyrie/#/builders/56/builds/2501

Can you have a look at it? It might be some timeout we can increase, or maybe we have to disable this test on riscv.

Thanks,
Mathieu

Signature · 3 lines
Mathieu Dubois-Briand, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#3 lore raw

Hi Mathieu,

It's been recently observed that many ptests are failing on riscv64 arch which is expected to happen to some extent as it's a growing area and has time to mature, i will send a follow-up patch to disable these tests for this arch for the time being.

Best Regards,
Pratik

________________________________________
From: Mathieu Dubois-Briand <[email protected]>
Sent: Tuesday, September 29, 2026 3:53 PM
To: Pratik Farkase; [email protected]
Cc: [email protected]
Subject: Re: [OE-core][PATCH v2] libpcap: add ptest support

Quoted 10 lines · Pratik Farkase

Build libpcap's upstream testprogs and run the TESTrun harness under ptest. The harness drives filtertest, translatetest and enumeratetest to compile and translate BPF filter expressions against bundled savefiles and compares the results with the embedded expected output. These tests are offline and deterministic and need no capture privileges or network.

Tested on qemux86-64 with ptest-runner: 14801 passed, 0 failed.

---

Hi Pratik,

Thanks for adding tests. It looks like this is failing on riscv64, probably because of the performances of the qemu machine:

AssertionError:
Failed ptests:
{'libpcap': 'START: ptest-runner\n'

            '2026-09-29T12:01\n'
            'Timeout! System state:\n'
            'Collected system state:\n'
            '+ dmesg\n'
            ...
            '\n'
            'ERROR: Exited from signal Killed (9)\n'
            'DURATION: 451\n'}

I did happen on my two runs:

https://autobuilder.yoctoproject.org/valkyrie/#/builders/56/builds/2498
https://autobuilder.yoctoproject.org/valkyrie/#/builders/56/builds/2501

Can you have a look at it? It might be some timeout we can increase, or maybe we have to disable this test on riscv.

Thanks,
Mathieu

--
Mathieu Dubois-Briand, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

#4 lore raw

PATCH v3 1/1 libpcap: add ptest support

In reply to Pratik Farkase

Build libpcap's upstream testprogs and run the TESTrun harness under ptest. The harness drives filtertest, translatetest and enumeratetest to compile and translate BPF filter expressions against bundled savefiles and compares the results with the embedded expected output. These tests are offline and deterministic and need no capture privileges or network.

Tested on qemux86-64 with ptest-runner: 14801 passed, 0 failed.

---

Changes in v3:
- Disable the ptest on riscv64: the TESTrun harness is too slow under qemuriscv64 (TCG) and exceeds the ptest-runner timeout.

Changes in v2:
- run-ptest now reports one PASS/SKIP/FAIL line per test case instead of a single result for the whole harness.

 .../distro/include/ptest-packagelists.inc     |  5 +--
 .../libpcap/files/run-ptest                   | 25 +++++++++++++
 .../libpcap/libpcap_1.11.0.bb                 | 35 +++++++++++++++++--
 3 files changed, 61 insertions(+), 4 deletions(-)
 create mode 100644 meta/recipes-connectivity/libpcap/files/run-ptest
meta/conf/distro/include/ptest-packagelists.inc +3 -2
index 7d0a9148bc..dba231d249 100644
@@ -136,6 +136,7 @@ PTESTS_SLOW = "\
     libevent \
     libgcrypt \
     libmodule-build-perl \
+    libpcap \
     libpng \
     ${@bb.utils.contains('DISTRO_FEATURES', 'seccomp', 'libseccomp', '',d)} \
     lttng-tools \
@@ -166,8 +167,8 @@ PTESTS_PROBLEMS:append:riscv32 = " lttng-tools strace"
 PTESTS_SLOW:append:libc-musl = " libc-test"
 
 # These tests don't yet pass for riscv64
-PTESTS_SLOW:remove:riscv64 = "tcl tcl8 python3-cffi strace lttng-tools python3-numpy perl glib-2.0 zstd"
-PTESTS_PROBLEMS:append:riscv64 = " tcl tcl8 python3-cffi strace lttng-tools python3-numpy perl glib-2.0 zstd"
+PTESTS_SLOW:remove:riscv64 = "tcl tcl8 python3-cffi strace lttng-tools python3-numpy perl glib-2.0 zstd libpcap"
+PTESTS_PROBLEMS:append:riscv64 = " tcl tcl8 python3-cffi strace lttng-tools python3-numpy perl glib-2.0 zstd libpcap"
 
 # These tests don't yet pass for musl qemuarm64
 PTESTS_SLOW:remove:libc-musl:qemuarm64 = "strace perl gnutls glib-2.0"
meta/recipes-connectivity/libpcap/files/run-ptest new file +25 -0
new file mode 100644
index 0000000000..c4b869d541
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+cd "$(dirname "$0")/testprogs" || exit 1
+
+FILTERTEST_BIN="./filtertest"
+TRANSLATETEST_BIN="./translatetest"
+ENUMERATETEST_BIN="./enumeratetest"
+CONFIG_H="../config.h"
+export FILTERTEST_BIN TRANSLATETEST_BIN ENUMERATETEST_BIN CONFIG_H
+
+./TESTrun --passed --skipped 2>&1 | awk '
+    /^Passed tests:/  { section = "PASS"; next }
+    /^Skipped tests:/ { section = "SKIP"; next }
+    /^Failed tests:/  { section = "FAIL"; next }
+    /^-+$/            { section = ""; next }
+    section != "" && /^    / {
+        c = index($0, ": ")
+        if (c >= 45) {
+            label = substr($0, 5, c - 5)
+            sub(/[[:space:]]+$/, "", label)
+            if (label != "")
+                print section ": " label
+        }
+    }
+'
meta/recipes-connectivity/libpcap/libpcap_1.11.0.bb +33 -2
index df63ab68b8..ef1ff0fff8 100644
@@ -10,10 +10,12 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=5eb289217c160e2920d2e35bddc36453 \
                     file://pcap.h;beginline=1;endline=32;md5=39af3510e011f34b8872f120b1dc31d2"
 DEPENDS = "flex-native bison-native"
 
-SRC_URI = "https://www.tcpdump.org/release/${BP}.tar.xz"
+SRC_URI = "https://www.tcpdump.org/release/${BP}.tar.xz \
+           file://run-ptest \
+           "
 SRC_URI[sha256sum] = "9237f5bae9dcf3a91823d9963ec43b7c0e2e3374ef2ad57d92c8cd39530f4723"
 
-inherit autotools binconfig-disabled pkgconfig
+inherit autotools binconfig-disabled pkgconfig ptest
 
 BINCONFIG = "${bindir}/pcap-config"
 
@@ -36,4 +38,33 @@ do_configure:prepend () {
     sed 's|\([ "^'\''I]\+\)/usr/include/|\1${STAGING_INCDIR}/|g' -i ${S}/configure.ac
 }
 
+do_compile_ptest() {
+    oe_runmake -C ${B}/testprogs CFLAGS="${CFLAGS} ${LDFLAGS}" \
+        filtertest translatetest enumeratetest
+}
+
+do_install_ptest() {
+    install -d ${D}${PTEST_PATH}/testprogs
+    install -d ${D}${PTEST_PATH}/tests
+
+    # Perl harness and its helper modules.
+    install -m 0755 ${S}/testprogs/TESTrun ${D}${PTEST_PATH}/testprogs/
+    install -m 0644 ${S}/testprogs/TESTlib.pm ${D}${PTEST_PATH}/testprogs/
+    install -m 0644 ${S}/testprogs/TESTst.pm ${D}${PTEST_PATH}/testprogs/
+    install -m 0644 ${S}/testprogs/TESTmt.pm ${D}${PTEST_PATH}/testprogs/
+
+    # Offline test programs driven by the harness.
+    install -m 0755 ${B}/testprogs/filtertest ${D}${PTEST_PATH}/testprogs/
+    install -m 0755 ${B}/testprogs/translatetest ${D}${PTEST_PATH}/testprogs/
+    install -m 0755 ${B}/testprogs/enumeratetest ${D}${PTEST_PATH}/testprogs/
+
+    # Savefiles used by the filter tests (SAVEFILE_DIR is testprogs/../tests).
+    cp -r ${S}/tests/* ${D}${PTEST_PATH}/tests/
+
+    # config.h is read by TESTrun for feature-based test skipping.
+    install -m 0644 ${B}/config.h ${D}${PTEST_PATH}/config.h
+}
+
+RDEPENDS:${PN}-ptest += "perl perl-modules coreutils diffutils"
+
 BBCLASSEXTEND = "native nativesdk"
Signature · 1 line
2.43.0