diff mbox series

[meta-networking] lldpd: add ptest for lldpd package

Message ID 20221111082200.215065-1-xiangyu.chen@eng.windriver.com
State Under Review
Headers show
Series [meta-networking] lldpd: add ptest for lldpd package | expand

Commit Message

Xiangyu Chen Nov. 11, 2022, 8:22 a.m. UTC
Signed-off-by: Xiangyu Chen <xiangyu.chen@eng.windriver.com>
---
 .../recipes-daemons/lldpd/files/run-ptest     | 16 +++++++++++++++
 .../recipes-daemons/lldpd/lldpd_1.0.15.bb     | 20 ++++++++++++++++++-
 2 files changed, 35 insertions(+), 1 deletion(-)
 create mode 100755 meta-networking/recipes-daemons/lldpd/files/run-ptest
diff mbox series

Patch

diff --git a/meta-networking/recipes-daemons/lldpd/files/run-ptest b/meta-networking/recipes-daemons/lldpd/files/run-ptest
new file mode 100755
index 000000000..da686eb46
--- /dev/null
+++ b/meta-networking/recipes-daemons/lldpd/files/run-ptest
@@ -0,0 +1,16 @@ 
+#!/bin/sh
+
+num_fail=0
+
+for test in tests/check*
+do
+    ./"$test" \
+         && echo "PASS: $test" \
+         || {
+            echo "FAIL: $test"
+            num_fail=$(( ${num_fail} + 1))
+         }
+
+done
+
+exit $num_fail
diff --git a/meta-networking/recipes-daemons/lldpd/lldpd_1.0.15.bb b/meta-networking/recipes-daemons/lldpd/lldpd_1.0.15.bb
index 6a3687cf7..c7237d74b 100644
--- a/meta-networking/recipes-daemons/lldpd/lldpd_1.0.15.bb
+++ b/meta-networking/recipes-daemons/lldpd/lldpd_1.0.15.bb
@@ -9,11 +9,12 @@  SRC_URI = "\
     http://media.luffy.cx/files/${BPN}/${BPN}-${PV}.tar.gz \
     file://lldpd.init.d \
     file://lldpd.default \
+    file://run-ptest \
     "
 
 SRC_URI[sha256sum] = "f7fe3a130be98a19c491479ef60f36b8ee41a9e6bc4d7f2c41033f63956a3126"
 
-inherit autotools update-rc.d useradd systemd pkgconfig bash-completion github-releases
+inherit autotools update-rc.d useradd systemd pkgconfig bash-completion github-releases ptest
 
 USERADD_PACKAGES = "${PN}"
 USERADD_PARAM:${PN} = "--system -g lldpd --shell /bin/false lldpd"
@@ -61,3 +62,20 @@  RDEPENDS:${PN} += "os-release"
 FILES:${PN}-zsh-completion += "${datadir}/zsh/"
 # FIXME: zsh is broken in meta-oe so this cannot be enabled for now
 #RDEPENDS:${PN}-zsh-completion += "zsh"
+
+RDEPENDS:${PN}-ptest = "libcheck"
+DEPENDS += "${@bb.utils.contains('PTEST_ENABLED', '1', 'libcheck', '', d)}"
+
+TESTDIR = "tests"
+do_compile_ptest () {
+    # hack to remove the call to `make check-TESTS`
+    sed -i 's/$(MAKE) $(AM_MAKEFLAGS) check-TESTS//g' ${TESTDIR}/Makefile
+    oe_runmake check
+}
+
+do_install_ptest () {
+    # install the tests
+    cp -rf ${B}/${TESTDIR} ${D}${PTEST_PATH}
+    # remove the object files
+    rm ${D}${PTEST_PATH}/${TESTDIR}/*.o
+}