diff mbox series

avahi: add ptest support

Message ID 20260928112020.42351-1-pratik.farkase@est.tech
State Under Review
Headers show
Series avahi: add ptest support | expand

Commit Message

Pratik Farkase Sept. 28, 2026, 11:20 a.m. UTC
Build avahi's upstream automake unit tests (via --enable-tests) and run
the deterministic, non-interactive ones under ptest: the avahi-common
(strlst, domain, alternative, timeval, utf8) and avahi-core (dns-spin,
dns, hashmap) tests.

Tested on qemux86-64 with ptest-runner: 8 tests, all pass.

Signed-off-by: Pratik Farkase <pratik.farkase@est.tech>
---
 .../distro/include/ptest-packagelists.inc     |  1 +
 meta/recipes-connectivity/avahi/avahi_0.9.bb  | 31 ++++++++++++++++++-
 .../avahi/files/run-ptest                     | 12 +++++++
 3 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 meta/recipes-connectivity/avahi/files/run-ptest
diff mbox series

Patch

diff --git a/meta/conf/distro/include/ptest-packagelists.inc b/meta/conf/distro/include/ptest-packagelists.inc
index cc9a3451cb..7d0a9148bc 100644
--- a/meta/conf/distro/include/ptest-packagelists.inc
+++ b/meta/conf/distro/include/ptest-packagelists.inc
@@ -7,6 +7,7 @@  PTESTS_FAST = "\
     acl \
     apr-util \
     attr \
+    avahi \
     babeltrace2 \
     bc \
     bluez5 \
diff --git a/meta/recipes-connectivity/avahi/avahi_0.9.bb b/meta/recipes-connectivity/avahi/avahi_0.9.bb
index 15189d0906..ff8d5ceb4e 100644
--- a/meta/recipes-connectivity/avahi/avahi_0.9.bb
+++ b/meta/recipes-connectivity/avahi/avahi_0.9.bb
@@ -24,6 +24,7 @@  SRC_URI = "git://github.com/avahi/avahi;protocol=https;branch=master;tag=v0.9-rc
            file://avahi-daemon.in \
            file://avahi-dnsconfd.in \
            file://0001-Fix-opening-etc-resolv.conf-error.patch \
+           file://run-ptest \
            "
 
 PV = "0.9~rc5"
@@ -47,7 +48,7 @@  PACKAGECONFIG[libevent] = "--enable-libevent,--disable-libevent,libevent"
 PACKAGECONFIG[systemd] = "--enable-libsystemd,--disable-libsystemd --without-systemdsystemunitdir,systemd"
 PACKAGECONFIG[qt5] = "--enable-qt5,--disable-qt5,qtbase"
 
-inherit autotools pkgconfig gettext gobject-introspection github-releases
+inherit autotools pkgconfig gettext gobject-introspection github-releases ptest
 
 EXTRA_OECONF = " \
              --runstatedir=${runtimedir} \
@@ -62,6 +63,7 @@  EXTRA_OECONF = " \
              --disable-python \
              --disable-doxygen-doc \
              --disable-manpages \
+             --enable-tests \
              ${EXTRA_OECONF_SYSVINIT} \
            "
 
@@ -79,6 +81,33 @@  do_compile:prepend() {
 
 RRECOMMENDS:${PN}:append:libc-glibc = " avahi-libnss-mdns"
 
+AVAHI_PTESTS = " \
+    avahi-common/strlst-test \
+    avahi-common/domain-test \
+    avahi-common/alternative-test \
+    avahi-common/timeval-test \
+    avahi-common/utf8-test \
+    avahi-core/dns-spin-test \
+    avahi-core/dns-test \
+    avahi-core/hashmap-test \
+"
+
+do_install_ptest() {
+    install -d ${D}${PTEST_PATH}/tests
+    for t in ${AVAHI_PTESTS}; do
+        d=$(dirname $t)
+        n=$(basename $t)
+        if [ -x ${B}/$d/.libs/$n ]; then
+            install -m 0755 ${B}/$d/.libs/$n ${D}${PTEST_PATH}/tests/$n
+        else
+            install -m 0755 ${B}/$t ${D}${PTEST_PATH}/tests/$n
+        fi
+    done
+}
+
+RDEPENDS:${PN}-ptest += "libavahi-common libavahi-core"
+RDEPENDS:${PN}-ptest:remove = "${PN}"
+
 do_install() {
 	autotools_do_install
 
diff --git a/meta/recipes-connectivity/avahi/files/run-ptest b/meta/recipes-connectivity/avahi/files/run-ptest
new file mode 100644
index 0000000000..3c675d5eef
--- /dev/null
+++ b/meta/recipes-connectivity/avahi/files/run-ptest
@@ -0,0 +1,12 @@ 
+#!/bin/sh
+# SPDX-License-Identifier: MIT
+
+cd "$(dirname "$0")/tests" || exit 1
+
+for t in *; do
+    if ./"$t" >/dev/null 2>&1; then
+        echo "PASS: $t"
+    else
+        echo "FAIL: $t"
+    fi
+done