@@ -18,6 +18,7 @@ PTESTS_FAST_META_MULTIMEDIA = "\
PTESTS_SLOW_META_MULTIMEDIA = "\
gupnp \
+ libupnp \
"
PTESTS_PROBLEMS_META_MULTIMEDIA = "\
new file mode 100755
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+cd "$(dirname "$0")"
+
+ctest --timeout 300 --output-on-failure 2>&1 | awk '
+/Test +#[0-9]+: / {
+ name = $0
+ sub(/.*Test +#[0-9]+: /, "", name)
+ sub(/ .*/, "", name)
+ if ($0 ~ /Passed/)
+ print "PASS: " name
+ else if ($0 ~ /Skipped/)
+ print "SKIP: " name
+ else
+ print "FAIL: " name
+ next
+}
+{ print }'
@@ -10,9 +10,10 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=394a0f17b97f33426275571e15920434"
SRCREV = "fac0494691434c35243131f66a0b27ea0c29f700"
SRC_URI = "git://github.com/pupnp/pupnp.git;protocol=https;branch=main;tag=release-${PV} \
+ file://run-ptest \
"
-inherit cmake pkgconfig
+inherit cmake pkgconfig ptest python3native
EXTRA_OECMAKE = "\
-DCMAKE_BUILD_TYPE=Release \
@@ -26,3 +27,50 @@ EXTRA_OECMAKE = "\
PACKAGECONFIG ??= ""
PACKAGECONFIG[openssl] = "-DUPNP_ENABLE_OPEN_SSL=ON,-DUPNP_ENABLE_OPEN_SSL=OFF,openssl"
+
+DEPENDS += "${@bb.utils.contains('PTEST_ENABLED', '1', 'googletest python3-pytest-native', '', d)}"
+
+# Most tests use internal symbols and only link against the static
+# libraries, which share a CMake export set with the shared ones, so the
+# tests get a separate build tree and the installed library stays
+# shared-only.
+PTEST_B = "${B}/ptest"
+
+do_configure_ptest() {
+ mkdir -p ${PTEST_B}
+ cd ${PTEST_B}
+ cmake ${OECMAKE_GENERATOR_ARGS} ${OECMAKE_SOURCEPATH} ${OECMAKE_ARGS} \
+ ${EXTRA_OECMAKE} -Wno-dev \
+ -DUPNP_BUILD_STATIC=ON \
+ -DUPNP_ENABLE_TESTING=ON \
+ -DPython3_EXECUTABLE=${PYTHON}
+}
+
+do_compile_ptest() {
+ cmake --build ${PTEST_B} -- ${EXTRA_OECMAKE_BUILD}
+}
+
+do_install_ptest() {
+ cd ${PTEST_B}
+ find . -name CTestTestfile.cmake | while read f; do
+ install -D -m 0644 $f ${D}${PTEST_PATH}/$f
+ sed -i -e 's# _BACKTRACE_TRIPLES "[^"]*"##' \
+ -e 's#${PTEST_B}#${PTEST_PATH}#g' -e 's#${S}#${PTEST_PATH}#g' \
+ -e 's#${PYTHON}#${bindir}/python3#g' ${D}${PTEST_PATH}/$f
+ done
+ find . -path '*/CMakeFiles' -prune -o -type f -perm -u+x ! -name '*.so*' -print | while read f; do
+ install -D -m 0755 $f ${D}${PTEST_PATH}/$f
+ done
+
+ install -d ${D}${PTEST_PATH}/ixml/test ${D}${PTEST_PATH}/tests ${D}${PTEST_PATH}/upnp/inc
+ cp -r ${S}/ixml/test/testdata ${D}${PTEST_PATH}/ixml/test/
+ install -m 0644 ${S}/tests/*.py ${D}${PTEST_PATH}/tests/
+ install -m 0755 ${S}/upnp/test/check_symbol_visibility.sh ${D}${PTEST_PATH}/upnp/test/
+ # The Python and symbol visibility tests look for the library in the
+ # build tree; point them at the installed one.
+ install -m 0644 ${PTEST_B}/upnp/inc/upnpconfig.h ${D}${PTEST_PATH}/upnp/inc/
+ ln -sf ${libdir}/libupnp.so.${PV} ${D}${PTEST_PATH}/upnp/libupnp.so
+ ln -sf ${libdir}/libupnp.so.${PV} ${D}${PTEST_PATH}/upnp/libupnp.so.${PV}
+}
+
+RDEPENDS:${PN}-ptest += "cmake python3-core python3-ctypes python3-fcntl python3-io python3-pytest"
Run upstream's test suite (ixml and upnp unit tests, googletest regression tests and the Python ctypes tests) with ctest on the target and turn its results into ptest PASS/FAIL/SKIP lines. Most of the regression tests use internal symbols and link only against the static libraries. Upstream puts the static and shared targets in one CMake export set, so building static libraries would make the -dev CMake config require the .a files from -staticdev. Instead, configure and build a second tree with static libraries and tests enabled in do_configure_ptest/do_compile_ptest, and install the tests from there. The shipped packages are the same with or without ptest. The Python tests and the symbol visibility check look for the library in the build tree, so point them at the installed one. The visibility check needs nm and is skipped on images without binutils. On qemux86-64: 198 pass, 1 skipped (visibility check), ~50s, so list it with the slow ptests. AI-Generated: Uses Claude Code Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com> --- .../ptest-packagelists-meta-multimedia.inc | 1 + .../libupnp/libupnp/run-ptest | 18 +++++++ .../libupnp/libupnp_22.2.2.bb | 50 ++++++++++++++++++- 3 files changed, 68 insertions(+), 1 deletion(-) create mode 100755 meta-multimedia/recipes-connectivity/libupnp/libupnp/run-ptest