From 288ad311f0eb2c636c7c7eeadc9eb3aedc6d46b9 Mon Sep 17 00:00:00 2001 From: Nicolas Marguet Date: Mon, 14 Aug 2023 16:54:51 -0700 Subject: librelp: add ptest MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use internal test from librelp project as ptest. This work is largely inspired on the rsyslog ptest implementation, which copies the automake-based tests/Makefile to the target and runs 'make check-TESTS'. sed is used to fix a few Makefile paths or env-vars so 'make' can run on the target. Tested on qemux86_64 and qemuarm64: ========================================== librelp 1.11.0: tests/test-suite.log ========================================== TOTAL: 30 PASS: 27 SKIP: 3 XFAIL: 0 FAIL: 0 XPASS: 0 ERROR: 0 The 3 skipped tests are either self-identified as “not do anything really useful” or may need to port libtool to the target. Signed-off-by: Nicolas Marguet Signed-off-by: Khem Raj --- ...on-inline-errors-in-debug-optimization-Og.patch | 34 ------------- ...on-inline-errors-in-debug-optimization-Og.patch | 34 +++++++++++++ meta-oe/recipes-extended/rsyslog/librelp/run-ptest | 10 ++++ meta-oe/recipes-extended/rsyslog/librelp_1.11.0.bb | 59 +++++++++++++++++++++- 4 files changed, 102 insertions(+), 35 deletions(-) delete mode 100644 meta-oe/recipes-extended/rsyslog/files/0001-Fix-function-inline-errors-in-debug-optimization-Og.patch create mode 100644 meta-oe/recipes-extended/rsyslog/librelp/0001-Fix-function-inline-errors-in-debug-optimization-Og.patch create mode 100644 meta-oe/recipes-extended/rsyslog/librelp/run-ptest (limited to 'meta-oe/recipes-extended') diff --git a/meta-oe/recipes-extended/rsyslog/files/0001-Fix-function-inline-errors-in-debug-optimization-Og.patch b/meta-oe/recipes-extended/rsyslog/files/0001-Fix-function-inline-errors-in-debug-optimization-Og.patch deleted file mode 100644 index 10e2b564cc..0000000000 --- a/meta-oe/recipes-extended/rsyslog/files/0001-Fix-function-inline-errors-in-debug-optimization-Og.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 6d575d98565ce3119a14359eecb11ccdff92a303 Mon Sep 17 00:00:00 2001 -From: Yash Shinde <53660251+Yashinde145@users.noreply.github.com> -Date: Thu, 29 Jun 2023 18:10:15 +0530 -Subject: [PATCH] Fix function inline errors in debug optimization (-Og) - -Compiler does not inline any functions when using debug optimization (-Og). -Hence, remove -Winline flag when compiling with debug optimization. - -Signed-off-by: Nicolas Marguet ---- -Upstream-Status: Backport [https://github.com/rsyslog/librelp/commit/6d575d9] - - configure.ac | 6 ++++++ - 1 file changed, 6 insertions(+) - -diff --git a/configure.ac b/configure.ac -index 21c1fde..1204c4e 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -230,6 +230,12 @@ if test "$enable_debug" = "no"; then - AC_DEFINE(NDEBUG, 1, [Defined if debug mode is disabled.]) - fi - -+#Compiler does not inline any functions when not optimizing(-Og). -+#Hence, remove -Winline flag when DEBUG is enabled. -+#ifdef DEBUG -+WARN_CFLAGS="$(echo "$WARN_CFLAGS" | sed s/-Winline//g)" -+#endif -+ - # valgrind - AC_ARG_ENABLE(valgrind, - [AS_HELP_STRING([--enable-valgrind],[Enable valgrind tests@<:@default=yes@:>@])], --- -2.39.0 diff --git a/meta-oe/recipes-extended/rsyslog/librelp/0001-Fix-function-inline-errors-in-debug-optimization-Og.patch b/meta-oe/recipes-extended/rsyslog/librelp/0001-Fix-function-inline-errors-in-debug-optimization-Og.patch new file mode 100644 index 0000000000..10e2b564cc --- /dev/null +++ b/meta-oe/recipes-extended/rsyslog/librelp/0001-Fix-function-inline-errors-in-debug-optimization-Og.patch @@ -0,0 +1,34 @@ +From 6d575d98565ce3119a14359eecb11ccdff92a303 Mon Sep 17 00:00:00 2001 +From: Yash Shinde <53660251+Yashinde145@users.noreply.github.com> +Date: Thu, 29 Jun 2023 18:10:15 +0530 +Subject: [PATCH] Fix function inline errors in debug optimization (-Og) + +Compiler does not inline any functions when using debug optimization (-Og). +Hence, remove -Winline flag when compiling with debug optimization. + +Signed-off-by: Nicolas Marguet +--- +Upstream-Status: Backport [https://github.com/rsyslog/librelp/commit/6d575d9] + + configure.ac | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/configure.ac b/configure.ac +index 21c1fde..1204c4e 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -230,6 +230,12 @@ if test "$enable_debug" = "no"; then + AC_DEFINE(NDEBUG, 1, [Defined if debug mode is disabled.]) + fi + ++#Compiler does not inline any functions when not optimizing(-Og). ++#Hence, remove -Winline flag when DEBUG is enabled. ++#ifdef DEBUG ++WARN_CFLAGS="$(echo "$WARN_CFLAGS" | sed s/-Winline//g)" ++#endif ++ + # valgrind + AC_ARG_ENABLE(valgrind, + [AS_HELP_STRING([--enable-valgrind],[Enable valgrind tests@<:@default=yes@:>@])], +-- +2.39.0 diff --git a/meta-oe/recipes-extended/rsyslog/librelp/run-ptest b/meta-oe/recipes-extended/rsyslog/librelp/run-ptest new file mode 100644 index 0000000000..a649a5716f --- /dev/null +++ b/meta-oe/recipes-extended/rsyslog/librelp/run-ptest @@ -0,0 +1,10 @@ +#!/bin/sh +# +set -e +set -o pipefail + +SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )" +cd ${SCRIPTPATH} +useradd tester || echo "user already exists" +su tester -c "make -C tests -k check-TESTS" +userdel tester diff --git a/meta-oe/recipes-extended/rsyslog/librelp_1.11.0.bb b/meta-oe/recipes-extended/rsyslog/librelp_1.11.0.bb index bac5abb052..cbbc31b7d1 100644 --- a/meta-oe/recipes-extended/rsyslog/librelp_1.11.0.bb +++ b/meta-oe/recipes-extended/rsyslog/librelp_1.11.0.bb @@ -8,10 +8,67 @@ DEPENDS = "gmp nettle libidn zlib gnutls openssl" SRC_URI = "git://github.com/rsyslog/librelp.git;protocol=https;branch=stable \ file://0001-Fix-function-inline-errors-in-debug-optimization-Og.patch \ + file://run-ptest \ " SRCREV = "b421f56d9ee31a966058d23bd23c966221c91396" S = "${WORKDIR}/git" -inherit autotools pkgconfig +inherit autotools pkgconfig ptest + +# For ptests, copy source tests/*.sh scripts, Makefile and +# executables and run them with make on target. +TESTDIR = "tests" +do_compile_ptest() { + echo 'buildtest-TESTS: $(check_PROGRAMS)' >> ${TESTDIR}/Makefile + oe_runmake -C ${TESTDIR} buildtest-TESTS +} + +do_install_ptest() { + install -d ${D}${PTEST_PATH}/${TESTDIR} + + # copy source tests/*.sh and python scripts + cp -f ${S}/${TESTDIR}/*.{sh,py} ${D}${PTEST_PATH}/${TESTDIR} + # install data files needed by the test scripts on the target + cp -f ${S}/${TESTDIR}/*.supp ${D}${PTEST_PATH}/${TESTDIR} + cp -rf ${S}/${TESTDIR}/tls-certs ${D}${PTEST_PATH}/${TESTDIR} + + # copy executables + find ${B}/${TESTDIR} -type f -executable -exec cp {} ${D}${PTEST_PATH}/${TESTDIR} \; + cp -rf ${B}/${TESTDIR}/.libs ${D}${PTEST_PATH}/${TESTDIR} + # copy Makefile + # run-ptest will run make which runs the executables + cp -f ${B}/${TESTDIR}/Makefile ${D}${PTEST_PATH}/${TESTDIR} + cp -f ${B}/${TESTDIR}/set-envvars ${D}${PTEST_PATH}/${TESTDIR} + + # give permissions to all users + # some tests need to write to this directory + chmod 777 -R ${D}${PTEST_PATH}/${TESTDIR} + + # do NOT need to rebuild Makefile or $(check_PROGRAMS) + sed -i 's/^Makefile:.*$/Makefile:/' ${D}${PTEST_PATH}/${TESTDIR}/Makefile + sed -i 's/^check-TESTS:.*$/check-TESTS:/' ${D}${PTEST_PATH}/${TESTDIR}/Makefile + + # fix the srcdir, top_srcdir, abs_top_builddir + sed -i 's,^\(srcdir = \).*,\1${PTEST_PATH}/${TESTDIR},' ${D}${PTEST_PATH}/${TESTDIR}/Makefile + sed -i 's,^\(top_srcdir = \).*,\1${PTEST_PATH}/${TESTDIR},' ${D}${PTEST_PATH}/${TESTDIR}/Makefile + sed -i 's,^\(abs_top_builddir = \).*,\1${PTEST_PATH}/,' ${D}${PTEST_PATH}/${TESTDIR}/Makefile + + # install test-driver + install -m 644 ${S}/test-driver ${D}${PTEST_PATH} + + # fix the python3 path for tests/set-envar + sed -i -e s:${HOSTTOOLS_DIR}:${bindir}:g ${D}${PTEST_PATH}/${TESTDIR}/set-envvars + + # these 2 scripts need help finding their /usr/lib/librelp/ptest/tests/.libs libraries + sed -i 's:${B}/src:${PTEST_PATH}/${TESTDIR}:' ${D}${PTEST_PATH}/${TESTDIR}/send + sed -i 's:${B}/src:${PTEST_PATH}/${TESTDIR}:' ${D}${PTEST_PATH}/${TESTDIR}/receive +} + +RDEPENDS:${PN}-ptest += "\ + make bash coreutils libgcc util-linux gawk grep \ + python3-core python3-io \ +" + +RRECOMMENDS:${PN}-ptest += " valgrind" -- cgit v1.2.3-54-g00ecf