[meta-networking] libnftnl: add ptest

Message ID 20211216191504.3999-1-trevor.gamblin@windriver.com
State New
Headers show
Series [meta-networking] libnftnl: add ptest | expand

Commit Message

Trevor Gamblin Dec. 16, 2021, 7:15 p.m. UTC
Signed-off-by: Trevor Gamblin <trevor.gamblin@windriver.com>
---
 .../0001-configure.ac-Add-serial-tests.patch  | 33 +++++++++++++++++++
 .../libnftnl/libnftnl/run-ptest               |  2 ++
 .../recipes-filter/libnftnl/libnftnl_1.2.1.bb | 29 +++++++++++++++-
 3 files changed, 63 insertions(+), 1 deletion(-)
 create mode 100644 meta-networking/recipes-filter/libnftnl/libnftnl/0001-configure.ac-Add-serial-tests.patch
 create mode 100644 meta-networking/recipes-filter/libnftnl/libnftnl/run-ptest

Patch

diff --git a/meta-networking/recipes-filter/libnftnl/libnftnl/0001-configure.ac-Add-serial-tests.patch b/meta-networking/recipes-filter/libnftnl/libnftnl/0001-configure.ac-Add-serial-tests.patch
new file mode 100644
index 000000000..049ad2d39
--- /dev/null
+++ b/meta-networking/recipes-filter/libnftnl/libnftnl/0001-configure.ac-Add-serial-tests.patch
@@ -0,0 +1,33 @@ 
+From 1cb59c1fed33607e4fb2bee9144ce45276e9cc96 Mon Sep 17 00:00:00 2001
+From: Trevor Gamblin <trevor.gamblin@windriver.com>
+Date: Tue, 14 Dec 2021 12:31:12 -0500
+Subject: [PATCH] configure.ac: Add serial-tests
+
+ptest needs buildtest-TESTS and runtest-TESTS targets.
+serial-tests is required to generate those targets.
+
+Upstream-Status: Inappropriate (default automake behavior incompatible with ptest)
+
+Signed-off-by: Trevor Gamblin <trevor.gamblin@windriver.com>
+---
+ configure.ac | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/configure.ac b/configure.ac
+index 8e68035..2704214 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -8,7 +8,9 @@ AC_CONFIG_HEADERS([config.h])
+ m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
+ 
+ AM_INIT_AUTOMAKE([-Wall foreign tar-pax no-dist-gzip dist-bzip2
+-	1.6 subdir-objects])
++	1.6 subdir-objects serial-tests])
++
++AM_EXTRA_RECURSIVE_TARGETS([buildtest-TESTS])
+ 
+ dnl kernel style compile messages
+ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
+-- 
+2.33.1
+
diff --git a/meta-networking/recipes-filter/libnftnl/libnftnl/run-ptest b/meta-networking/recipes-filter/libnftnl/libnftnl/run-ptest
new file mode 100644
index 000000000..133cf92d0
--- /dev/null
+++ b/meta-networking/recipes-filter/libnftnl/libnftnl/run-ptest
@@ -0,0 +1,2 @@ 
+#!/bin/sh
+make -C tests -k runtest-TESTS
diff --git a/meta-networking/recipes-filter/libnftnl/libnftnl_1.2.1.bb b/meta-networking/recipes-filter/libnftnl/libnftnl_1.2.1.bb
index 16de8589a..ec4619e7b 100644
--- a/meta-networking/recipes-filter/libnftnl/libnftnl_1.2.1.bb
+++ b/meta-networking/recipes-filter/libnftnl/libnftnl_1.2.1.bb
@@ -7,8 +7,35 @@  DEPENDS = "libmnl"
 SRCREV = "09456c720e9c00eecc08e41ac6b7c291b3821ee5"
 SRC_URI = "git://git.netfilter.org/libnftnl;branch=master \
            file://0001-avoid-naming-local-function-as-one-of-printf-family.patch \
+           file://0001-configure.ac-Add-serial-tests.patch \
+           file://run-ptest \
            "
 
 S = "${WORKDIR}/git"
 
-inherit autotools pkgconfig
+inherit autotools pkgconfig ptest
+
+RDEPENDS:${PN}-ptest += " bash python3-core make"
+ 
+TESTDIR = "tests"
+
+do_compile_ptest() {
+    cp -rf ${S}/build-aux .
+    oe_runmake buildtest-TESTS
+}
+ 
+do_install_ptest() {
+    cp -rf ${B}/build-aux ${D}${PTEST_PATH}
+    install -d ${D}${PTEST_PATH}/${TESTDIR}
+    cp -rf ${B}/${TESTDIR}/Makefile ${D}${PTEST_PATH}/${TESTDIR}
+
+    # the binaries compiled in ${TESTDIR} will look for a compiler to
+    # use, which will cause failures. Substitute the binaries in
+    # ${TESTDIR}/.libs instead
+    cp -rf ${B}/${TESTDIR}/.libs/* ${D}${PTEST_PATH}/${TESTDIR}
+
+    # Alter the Makefile so that it does not try and rebuild anything in
+    # other nonexistent paths before running the actual tests
+    sed -i 's/^Makefile/_Makefile/'  ${D}${PTEST_PATH}/${TESTDIR}/Makefile
+}
+