libgcrypt: Add ptest

Message ID 15666fb8-2cff-4525-adde-3e5714cdb7c2@denue6es010.ebgroup.elektrobit.com
State Accepted, archived
Commit 7e101c0231f9593185146770f1496a38fa9c590e
Headers show
Series libgcrypt: Add ptest | expand

Commit Message

Simone Weiss May 4, 2022, 12:25 p.m. UTC
Add a ptest for libgcript to core-image-ptest-all. All tests passed on a trial
run.

Signed-off-by: Simone Weiss <simone.weiss@elektrobit.com>
---
 meta/conf/distro/include/ptest-packagelists.inc   |  1 +
 meta/recipes-support/libgcrypt/files/run-ptest    |  3 +++
 .../recipes-support/libgcrypt/libgcrypt_1.10.1.bb | 15 ++++++++++++++-
 3 files changed, 18 insertions(+), 1 deletion(-)
 create mode 100644 meta/recipes-support/libgcrypt/files/run-ptest

Patch

diff --git a/meta/conf/distro/include/ptest-packagelists.inc b/meta/conf/distro/include/ptest-packagelists.inc
index 54a290871e..a1ead90649 100644
--- a/meta/conf/distro/include/ptest-packagelists.inc
+++ b/meta/conf/distro/include/ptest-packagelists.inc
@@ -87,6 +87,7 @@  PTESTS_SLOW = "\
     glib-2.0-ptest \
     gstreamer1.0-ptest \
     libevent-ptest \
+    libgcrypt-ptest \
     lttng-tools-ptest \
     openssh-ptest \
     openssl-ptest \
diff --git a/meta/recipes-support/libgcrypt/files/run-ptest b/meta/recipes-support/libgcrypt/files/run-ptest
new file mode 100644
index 0000000000..4818a061b4
--- /dev/null
+++ b/meta/recipes-support/libgcrypt/files/run-ptest
@@ -0,0 +1,3 @@ 
+#!/bin/sh
+
+make -C build/tests runtest-TESTS
diff --git a/meta/recipes-support/libgcrypt/libgcrypt_1.10.1.bb b/meta/recipes-support/libgcrypt/libgcrypt_1.10.1.bb
index 251e0d0348..aa83de226d 100644
--- a/meta/recipes-support/libgcrypt/libgcrypt_1.10.1.bb
+++ b/meta/recipes-support/libgcrypt/libgcrypt_1.10.1.bb
@@ -18,6 +18,7 @@  LIC_FILES_CHKSUM = "file://COPYING;md5=94d55d512a9ba36caa9b7df079bae19f \
                     "
 
 DEPENDS = "libgpg-error"
+RDEPENDS:${PN}-ptest = "bash"
 
 UPSTREAM_CHECK_URI = "https://gnupg.org/download/index.html"
 SRC_URI = "${GNUPG_MIRROR}/libgcrypt/libgcrypt-${PV}.tar.bz2 \
@@ -25,6 +26,7 @@  SRC_URI = "${GNUPG_MIRROR}/libgcrypt/libgcrypt-${PV}.tar.bz2 \
            file://0003-tests-bench-slope.c-workaround-ICE-failure-on-mips-w.patch \
            file://0002-libgcrypt-fix-building-error-with-O2-in-sysroot-path.patch \
            file://0004-tests-Makefile.am-fix-undefined-reference-to-pthread.patch \
+           file://run-ptest \
            "
 SRC_URI[sha256sum] = "ef14ae546b0084cd84259f61a55e07a38c3b53afc0f546bffcef2f01baffe9de"
 
@@ -33,11 +35,13 @@  CVE_CHECK_IGNORE += "CVE-2018-12433 CVE-2018-12438"
 
 BINCONFIG = "${bindir}/libgcrypt-config"
 
-inherit autotools texinfo binconfig-disabled pkgconfig
+inherit autotools texinfo binconfig-disabled pkgconfig ptest
 
 EXTRA_OECONF = "--disable-asm"
 EXTRA_OEMAKE:class-target = "LIBTOOLFLAGS='--tag=CC'"
 
+PRIVATE_LIBS:${PN}-ptest:append = " libgcrypt.so.20"
+
 PACKAGECONFIG ??= "capabilities"
 PACKAGECONFIG[capabilities] = "--with-capabilities,--without-capabilities,libcap"
 
@@ -52,6 +56,15 @@  do_install:append() {
 	install -m 0644 ${B}/src/libgcrypt.pc ${D}/${libdir}/pkgconfig/
 }
 
+do_install_ptest() {
+    cp -r --preserve=mode,links -v ${S} ${D}${PTEST_PATH}
+    cp -r --preserve=mode,links -v ${B} ${D}${PTEST_PATH}
+    rm ${D}${PTEST_PATH}/build/cipher/gost-s-box
+    rm ${D}${PTEST_PATH}/build/doc/yat2m
+    find ${D}/${PTEST_PATH}/build -name "*.cmake" -or -name "Makefile" \
+    | xargs sed -e "s|${WORKDIR}|${PTEST_PATH}|g" -e "s|${WORKDIR}/recipe-sysroot-native||g" -i
+}
+
 PACKAGES =+ "dumpsexp-dev"
 
 FILES:${PN}-dev += "${bindir}/hmac256"