From 7fe87bea09081575a6536cf044d6bc62803b1acd Mon Sep 17 00:00:00 2001 From: Xiangyu Chen Date: Fri, 11 Nov 2022 16:22:00 +0800 Subject: [PATCH] lldpd: add ptest for lldpd package Signed-off-by: Xiangyu Chen Signed-off-by: Khem Raj --- .../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 --git a/meta-networking/recipes-daemons/lldpd/files/run-ptest b/meta-networking/recipes-daemons/lldpd/files/run-ptest new file mode 100755 index 0000000000..da686eb465 --- /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 6a3687cf72..c7237d74bb 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 +}