diff mbox series

[v2,1/2] nettle: rewrite ptest integration

Message ID 20230608115916.1539101-1-ross.burton@arm.com
State Accepted, archived
Commit dc5cd169e8b9a0f9d9881f116a8d83706460bb7c
Headers show
Series [v2,1/2] nettle: rewrite ptest integration | expand

Commit Message

Ross Burton June 8, 2023, 11:59 a.m. UTC
From: Ross Burton <ross.burton@arm.com>

Instead of patching a relative path to an unversioned libnettle.so to be
a bare filename which then needs nettle-dev to be installed, create a
symlink in the expected place which points to the actual library. This
means nettle-ptest no longer needs to depend on nettle-dev.

Explicitly skip symbols-test, it has been silently failing as nm isn't
available and also needs a static libnettle.a to run.

Install two rsa-* example binaries that are needed for pkcs1-conv-test
to pass.

Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 .../nettle/nettle/dlopen-test.patch           | 29 --------------
 meta/recipes-support/nettle/nettle/run-ptest  | 40 ++++++++++---------
 meta/recipes-support/nettle/nettle_3.8.1.bb   | 21 +++++-----
 3 files changed, 32 insertions(+), 58 deletions(-)
 delete mode 100644 meta/recipes-support/nettle/nettle/dlopen-test.patch
diff mbox series

Patch

diff --git a/meta/recipes-support/nettle/nettle/dlopen-test.patch b/meta/recipes-support/nettle/nettle/dlopen-test.patch
deleted file mode 100644
index ab9b91f88bc..00000000000
--- a/meta/recipes-support/nettle/nettle/dlopen-test.patch
+++ /dev/null
@@ -1,29 +0,0 @@ 
-Remove the relative path for libnettle.so so the test
-program can find it.
-Relative paths are not suitable, as the folder strucure for ptest
-is different from the one expected by the nettle testsuite.
-
-Upstream-Status: Inappropriate [embedded specific]
-
-Signed-off-by: Juro Bystricky <juro.bystricky@intel.com>
-Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
----
- testsuite/dlopen-test.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/testsuite/dlopen-test.c b/testsuite/dlopen-test.c
-index 4265bf7..1a25d17 100644
---- a/testsuite/dlopen-test.c
-+++ b/testsuite/dlopen-test.c
-@@ -15,7 +15,7 @@ int
- main (int argc UNUSED, char **argv UNUSED)
- {
- #if HAVE_LIBDL
--  void *handle = dlopen ("../libnettle." SO_EXT, RTLD_NOW);
-+  void *handle = dlopen ("libnettle.so", RTLD_NOW);
-   int (*get_version)(void);
-   if (!handle)
-     {
--- 
-2.17.1
-
diff --git a/meta/recipes-support/nettle/nettle/run-ptest b/meta/recipes-support/nettle/nettle/run-ptest
index b90bed66d27..61a43c78f12 100644
--- a/meta/recipes-support/nettle/nettle/run-ptest
+++ b/meta/recipes-support/nettle/nettle/run-ptest
@@ -6,31 +6,35 @@  failed=0
 all=0
 
 for f in *-test; do
-    if [ "$f" = "sha1-huge-test" ] ; then
-        echo "SKIP: $f (skipped for ludicrous run time)"
-        continue
-    fi
-
-    "./$f"
-    case "$?" in
-        0)
-            echo "PASS: $f"
-            all=$((all + 1))
+    case "$f" in
+        "sha1-huge-test")
+            echo "SKIP: $f (long run time)"
             ;;
-        77)
-            echo "SKIP: $f"
+        "symbols-test")
+            echo "SKIP: $f (needs static libraries)"
             ;;
         *)
-            echo "FAIL: $f"
-            failed=$((failed + 1))
-            all=$((all + 1))
+            "./$f"
+            case "$?" in
+                0)
+                    echo "PASS: $f"
+                    all=$((all + 1))
+                    ;;
+                77)
+                    echo "SKIP: $f"
+                    ;;
+                *)
+                    echo "FAIL: $f"
+                    failed=$((failed + 1))
+                    all=$((all + 1))
+                    ;;
+            esac
             ;;
     esac
 done
 
 if [ "$failed" -eq 0 ] ; then
-  echo "All $all tests passed"
+    echo "All $all tests passed"
 else
-  echo "$failed of $all tests failed"
+    echo "$failed of $all tests failed"
 fi
-
diff --git a/meta/recipes-support/nettle/nettle_3.8.1.bb b/meta/recipes-support/nettle/nettle_3.8.1.bb
index bf491322354..184023e4031 100644
--- a/meta/recipes-support/nettle/nettle_3.8.1.bb
+++ b/meta/recipes-support/nettle/nettle_3.8.1.bb
@@ -20,10 +20,6 @@  SRC_URI = "${GNU_MIRROR}/${BPN}/${BP}.tar.gz \
            file://check-header-files-of-openssl-only-if-enable_.patch \
            "
 
-SRC_URI:append:class-target = "\
-            file://dlopen-test.patch \
-            "
-
 SRC_URI[sha256sum] = "364f3e2b77cd7dcde83fd7c45219c834e54b0c75e428b6f894a23d12dd41cbfe"
 
 UPSTREAM_CHECK_REGEX = "nettle-(?P<pver>\d+(\.\d+)+)\.tar"
@@ -44,14 +40,17 @@  do_install:append() {
 
 do_install_ptest() {
         install -d ${D}${PTEST_PATH}/testsuite/
-        install ${S}/testsuite/gold-bug.txt ${D}${PTEST_PATH}/testsuite/
-        install ${S}/testsuite/*-test ${D}${PTEST_PATH}/testsuite/
-        # tools can be found in PATH, not in ../tools/
-        sed -i -e 's|../tools/||' ${D}${PTEST_PATH}/testsuite/*-test
         install ${B}/testsuite/*-test ${D}${PTEST_PATH}/testsuite/
-}
+        install ${S}/testsuite/*-test ${D}${PTEST_PATH}/testsuite/
+        install ${S}/testsuite/gold-bug.txt ${D}${PTEST_PATH}/testsuite/
 
-RDEPENDS:${PN}-ptest += "${PN}-dev"
-INSANE_SKIP:${PN}-ptest += "dev-deps"
+        # Install a symlink for dlopen-test
+        ln -sr ${D}${libdir}/libnettle.so.*.* ${D}${PTEST_PATH}/libnettle.so
+        # These examples are needed for pkcs1-conv-test
+        install ${B}/examples/rsa-sign ${B}/examples/rsa-verify ${D}${PTEST_PATH}/testsuite/
+        # Fix build-time relative paths
+        sed -i -e 's|../tools/|${bindir}/|g' ${D}${PTEST_PATH}/testsuite/*-test
+        sed -i -e 's|../examples/|./|g' ${D}${PTEST_PATH}/testsuite/*-test
+}
 
 BBCLASSEXTEND = "native nativesdk"