Skip to contentSkip to conversation

librelp: add ptest

PATCH In review [email protected] 2 participants 3 messages Aug 17, 2023 – Aug 19, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 librelp: add ptest

From: Nicolas Marguet <[email protected]>

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.

---
 ...line-errors-in-debug-optimization-Og.patch |  0
 .../rsyslog/librelp/run-ptest                 | 10 ++++
 .../rsyslog/librelp_1.11.0.bb                 | 59 ++++++++++++++++++-
 3 files changed, 68 insertions(+), 1 deletion(-)
 rename meta-oe/recipes-extended/rsyslog/{files => librelp}/0001-Fix-function-inline-errors-in-debug-optimization-Og.patch (100%)
 create mode 100644 meta-oe/recipes-extended/rsyslog/librelp/run-ptest
meta-oe/recipes-extended/rsyslog/librelp/0001-Fix-function-inline-errors-in-debug-optimization-Og.patch renamed from meta-oe/recipes-extended/rsyslog/files/0001-Fix-function-inline-errors-in-debug-optimization-Og.patch +0 -0
similarity index 100%
rename from meta-oe/recipes-extended/rsyslog/files/0001-Fix-function-inline-errors-in-debug-optimization-Og.patch
rename to meta-oe/recipes-extended/rsyslog/librelp/0001-Fix-function-inline-errors-in-debug-optimization-Og.patch
meta-oe/recipes-extended/rsyslog/librelp/run-ptest new file +10 -0
new file mode 100644
index 000000000..a649a5716
@@ -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
meta-oe/recipes-extended/rsyslog/librelp_1.11.0.bb +58 -1

68 lines not on this page · raw message

Signature · 1 line
2.39.0
#1 lore raw

PATCH 2/2 librelp: Fix function prototypes in tests

From: Khem Raj <[email protected]>

Helps fix issues found with clang

Cc Nicolas Marguet <[email protected]>
---
 .../0001-tests-Fix-callback-prototype.patch   | 49 +++++++++++++++++++
 .../rsyslog/librelp_1.11.0.bb                 |  1 +
 2 files changed, 50 insertions(+)
 create mode 100644 meta-oe/recipes-extended/rsyslog/librelp/0001-tests-Fix-callback-prototype.patch
meta-oe/recipes-extended/rsyslog/librelp/0001-tests-Fix-callback-prototype.patch new file +49 -0
new file mode 100644
index 000000000..ba081926e
@@ -0,0 +1,49 @@
+From 2a7e26510cf9276b7e640ca8282cc1c5e46075d0 Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email protected]>
+Date: Tue, 15 Aug 2023 11:59:40 -0700
+Subject: [PATCH] tests: Fix callback prototype
+
+clang errors about it
+
+| ../../git/tests/receive.c:71:34: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
+|    71 | hdlr_enable(int sig, void (*hdlr)())
+|       |                                  ^
+|       |                                   void
+| 1 error generated.
+
+Upstream-Status: Submitted [https://github.com/rsyslog/librelp/pull/260]
+Signed-off-by: Khem Raj <[email protected]>
+---
+ tests/receive.c | 2 +-
+ tests/send.c    | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/tests/receive.c b/tests/receive.c
+index f376cb4..c12e911 100644
+--- a/tests/receive.c
++++ b/tests/receive.c
+@@ -68,7 +68,7 @@ doSleep(int iSeconds, const int iuSeconds)
+ }
+ 
+ static void
+-hdlr_enable(int sig, void (*hdlr)())
++hdlr_enable(int sig, void (*hdlr)(const int))
+ {
+ 	struct sigaction sigAct;
+ 	memset(&sigAct, 0, sizeof (sigAct));
+diff --git a/tests/send.c b/tests/send.c
+index d7e90f0..1b1df4f 100644
+--- a/tests/send.c
++++ b/tests/send.c
+@@ -57,7 +57,7 @@ struct usrdata { /* used for testing user pointer pass-back */
+ struct usrdata *userdata = NULL;
+ 
+ static void
+-hdlr_enable(int sig, void (*hdlr)())
++hdlr_enable(int sig, void (*hdlr)(const int))
+ {
+ 	struct sigaction sigAct;
+ 	memset(&sigAct, 0, sizeof (sigAct));
+-- 
+2.41.0
+
meta-oe/recipes-extended/rsyslog/librelp_1.11.0.bb +1 -0
index cbbc31b7d..eebfece3f 100644
@@ -8,6 +8,7 @@ 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://0001-tests-Fix-callback-prototype.patch \
            file://run-ptest \
 "
 
Signature · 1 line
2.39.0
#2 lore raw
In reply to [email protected]

+ cp -f ${S}/${TESTDIR}/*.{sh,py} ${D}${PTEST_PATH}/${TESTDIR}

Can you please change this to:
cp -f ${S}/${TESTDIR}/*.sh ${S}/${TESTDIR}/*,py
${D}${PTEST_PATH}/${TESTDIR}

so that it works with dash as well? It's now failing with:

DEBUG: Executing shell function do_install_ptest_base
cp: cannot stat 'TOPDIR/BUILD/work/qemux86_64-oe-linux/librelp/1.11.0/git/tests/*.{sh,py}':
No such file or directory
WARNING: exit code 1 from a shell command.

Quoted 163 lines · nicolas.marguet via lists.openembedded.org

From: Nicolas Marguet <[email protected]>

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.

---
 ...line-errors-in-debug-optimization-Og.patch |  0
 .../rsyslog/librelp/run-ptest                 | 10 ++++
 .../rsyslog/librelp_1.11.0.bb                 | 59 ++++++++++++++++++-
 3 files changed, 68 insertions(+), 1 deletion(-)
 rename meta-oe/recipes-extended/rsyslog/{files =>
librelp}/0001-Fix-function-inline-errors-in-debug-optimization-Og.patch
(100%)
 create mode 100644 meta-oe/recipes-extended/rsyslog/librelp/run-ptest

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/librelp/0001-Fix-function-inline-errors-in-debug-optimization-Og.patch similarity index 100%
rename from meta-oe/recipes-extended/rsyslog/files/0001-Fix-function-inline-errors-in-debug-optimization-Og.patch rename to meta-oe/recipes-extended/rsyslog/librelp/0001-Fix-function-inline-errors-in-debug-optimization-Og.patch

meta-oe/recipes-extended/rsyslog/librelp/run-ptest new file +10 -0
new file mode 100644
index 000000000..a649a5716
@@ -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
meta-oe/recipes-extended/rsyslog/librelp_1.11.0.bb +22 -1
index bac5abb05..cbbc31b7d 100644
@@ -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} \;

meta-oe/recipes-extended/rsyslog/librelp_1.11.0.bb +12 -0
+    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

meta-oe/recipes-extended/rsyslog/librelp_1.11.0.bb +3 -0
+
+    # 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

meta-oe/recipes-extended/rsyslog/librelp_1.11.0.bb +6 -0
+
+    # 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

meta-oe/recipes-extended/rsyslog/librelp_1.11.0.bb +2 -0
+
+    # 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

meta-oe/recipes-extended/rsyslog/librelp_1.11.0.bb +8 -1
+}
+
+RDEPENDS:${PN}-ptest += "\
+  make bash coreutils libgcc util-linux gawk grep \
+  python3-core python3-io \
+"
+
+RRECOMMENDS:${PN}-ptest += " valgrind"
--

2.39.0

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#104473):
https://lists.openembedded.org/g/openembedded-devel/message/104473
Mute This Topic: https://lists.openembedded.org/mt/100804400/3617156
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-