diff mbox series

[v2] libxcrypt: add ptest support

Message ID 20261204111808.29339-1-pratik.farkase@est.tech
State New
Headers show
Series [v2] libxcrypt: add ptest support | expand

Commit Message

Pratik Farkase Dec. 4, 2026, 11:18 a.m. UTC
Build libxcrypt's upstream test programs and run them under ptest. The
test list is taken from the TESTS variable of the build's Makefile, so
tests added upstream are picked up without a recipe change. Each test's
output is captured and printed only when the test fails, because several
tests print their own PASS:/FAIL: lines that would otherwise be counted
as extra results.

Skip alg-yescrypt. It allocates about 1 GiB for its scrypt known-answer
test and 256 MiB for its ROM test, which fail on the 1 GiB ptest image,
and it then crashes reading the uninitialised ROM [1].

The suite takes about 7.5 minutes on qemuriscv64, which is over the
default 450s timeout, so raise the timeout to 900s and list libxcrypt
in PTESTS_SLOW.

[1] https://github.com/besser82/libxcrypt/issues/165

Tested with testimage on qemuriscv64: 50 passed, 1 skipped
(getrandom-fallbacks), 0 failed.

Signed-off-by: Pratik Farkase <pratik.farkase@est.tech>
---

Notes:
    v2: Remove libxcrypt from PTESTS_SLOW on musl, where it is not built
        because virtual/crypt is provided by musl.

 .../distro/include/ptest-packagelists.inc     |  2 ++
 meta/recipes-core/images/core-image-ptest.bb  |  1 +
 meta/recipes-core/libxcrypt/files/run-ptest   | 12 +++++++++++
 .../recipes-core/libxcrypt/libxcrypt_4.5.2.bb | 20 +++++++++++++++++++
 4 files changed, 35 insertions(+)
 create mode 100644 meta/recipes-core/libxcrypt/files/run-ptest
diff mbox series

Patch

diff --git a/meta/conf/distro/include/ptest-packagelists.inc b/meta/conf/distro/include/ptest-packagelists.inc
index 351913226e..aaa736811f 100644
--- a/meta/conf/distro/include/ptest-packagelists.inc
+++ b/meta/conf/distro/include/ptest-packagelists.inc
@@ -149,6 +149,7 @@  PTESTS_SLOW = "\
     libpcap \
     libpng \
     libsoup \
+    libxcrypt \
     ${@bb.utils.contains('DISTRO_FEATURES', 'seccomp', 'libseccomp', '',d)} \
     lttng-tools \
     lz4 \
@@ -173,6 +174,7 @@  PTESTS_SLOW = "\
 PTESTS_SLOW:remove:riscv32 = "lttng-tools strace "
 PTESTS_PROBLEMS:append:riscv32 = " lttng-tools strace"
 PTESTS_SLOW:append:libc-musl = " libc-test"
+PTESTS_SLOW:remove:libc-musl = "libxcrypt"
 
 # These tests don't yet pass for riscv64
 PTESTS_SLOW:remove:riscv64 = "tcl python3-cffi lttng-tools python3-numpy perl glib-2.0 zstd libpcap"
diff --git a/meta/recipes-core/images/core-image-ptest.bb b/meta/recipes-core/images/core-image-ptest.bb
index 9b8af9b93a..852ea036c7 100644
--- a/meta/recipes-core/images/core-image-ptest.bb
+++ b/meta/recipes-core/images/core-image-ptest.bb
@@ -12,6 +12,7 @@  PTESTS = "${PTESTS_SLOW} ${PTESTS_FAST}"
 PTEST_RUNNER_TIMEOUT:virtclass-mcextend-python3-cffi = "600"
 PTEST_RUNNER_TIMEOUT:virtclass-mcextend-go = "4800"
 PTEST_RUNNER_TIMEOUT:virtclass-mcextend-icu = "2400"
+PTEST_RUNNER_TIMEOUT:virtclass-mcextend-libxcrypt = "900"
 
 IMAGE_INSTALL:append = " ${MCNAME}-ptest openssh"
 
diff --git a/meta/recipes-core/libxcrypt/files/run-ptest b/meta/recipes-core/libxcrypt/files/run-ptest
new file mode 100644
index 0000000000..24c056ba90
--- /dev/null
+++ b/meta/recipes-core/libxcrypt/files/run-ptest
@@ -0,0 +1,12 @@ 
+#!/bin/sh
+
+cd "$(dirname "$0")/test" || exit 1
+
+for t in *; do
+    out=$(./"$t" 2>&1)
+    case $? in
+        0) echo "PASS: $t" ;;
+        77) echo "SKIP: $t" ;;
+        *) echo "FAIL: $t"; echo "$out" | sed 's/^/    /' ;;
+    esac
+done
diff --git a/meta/recipes-core/libxcrypt/libxcrypt_4.5.2.bb b/meta/recipes-core/libxcrypt/libxcrypt_4.5.2.bb
index 79dba2f6dc..3178e1674b 100644
--- a/meta/recipes-core/libxcrypt/libxcrypt_4.5.2.bb
+++ b/meta/recipes-core/libxcrypt/libxcrypt_4.5.2.bb
@@ -1,2 +1,22 @@ 
 require libxcrypt.inc
 
+inherit ptest
+
+SRC_URI += "file://run-ptest"
+
+do_compile_ptest() {
+    oe_runmake check TESTS=
+}
+
+LIBXCRYPT_PTEST_SKIP = "test/alg-yescrypt"
+
+do_install_ptest() {
+    install -d ${D}${PTEST_PATH}/test
+    for t in $(makefile-getvar ${B}/Makefile TESTS); do
+        case " ${LIBXCRYPT_PTEST_SKIP} " in
+        *" $t "*) continue ;;
+        esac
+        ${B}/libtool --mode=install install -m 0755 ${B}/$t ${D}${PTEST_PATH}/test/
+    done
+}
+