diff mbox series

[3/4] attr: improve ptest packaging

Message ID 20250324172008.3110176-3-ross.burton@arm.com
State Accepted, archived
Commit baa1cbab47326656f762562303ddf4b0d9cc2b5c
Headers show
Series [1/4] perl: add more module RDEPENDS that don't get detected | expand

Commit Message

Ross Burton March 24, 2025, 5:20 p.m. UTC
As there's just a few test binaries in attr, instead of installing large
chunks of the build tree we can install just those and use a boilerplate
test runner.

Also add a comment explaining why we have to sed the test suite if musl
is used.

Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 meta/recipes-support/attr/attr/run-ptest | 34 +++++++++++++++-----
 meta/recipes-support/attr/attr_2.5.2.bb  | 40 +++++++-----------------
 2 files changed, 38 insertions(+), 36 deletions(-)
diff mbox series

Patch

diff --git a/meta/recipes-support/attr/attr/run-ptest b/meta/recipes-support/attr/attr/run-ptest
index 3e7a3a17a04..028671a9bde 100644
--- a/meta/recipes-support/attr/attr/run-ptest
+++ b/meta/recipes-support/attr/attr/run-ptest
@@ -1,10 +1,30 @@ 
 #!/bin/sh
 
-set +e
-make test-suite.log
-exitcode=$?
-if [ $exitcode -ne 0 -a -e test-suite.log ]; then
-    cat test-suite.log
-fi
-exit $exitcode
+failed=0
+all=0
 
+for f in *.test; do
+    ./run $f
+    case "$?" in
+        0)
+            echo "PASS: $f"
+            all=$((all + 1))
+            ;;
+        77)
+            echo "SKIP: $f"
+            ;;
+        *)
+            echo "FAIL: $f"
+            failed=$((failed + 1))
+            all=$((all + 1))
+            ;;
+    esac
+done
+
+if [ "$failed" -eq 0 ] ; then
+    echo "All $all tests passed"
+    exit 0
+else
+    echo "$failed of $all tests failed"
+    exit 1
+fi
diff --git a/meta/recipes-support/attr/attr_2.5.2.bb b/meta/recipes-support/attr/attr_2.5.2.bb
index b1a20930ed7..390445b959f 100644
--- a/meta/recipes-support/attr/attr_2.5.2.bb
+++ b/meta/recipes-support/attr/attr_2.5.2.bb
@@ -32,47 +32,29 @@  ALTERNATIVE:${PN} = "setfattr getfattr"
 ALTERNATIVE_TARGET[setfattr] = "${bindir}/setfattr"
 ALTERNATIVE_TARGET[getfattr] = "${bindir}/getfattr"
 
-PTEST_BUILD_HOST_FILES = "builddefs"
-PTEST_BUILD_HOST_PATTERN = "^RPM"
-
 do_install_ptest() {
-        cp ${B}/Makefile ${D}${PTEST_PATH}
-        sed -e 's,--sysroot=${STAGING_DIR_TARGET},,g' \
-            -e 's|${DEBUG_PREFIX_MAP}||g' \
-            -e 's:${HOSTTOOLS_DIR}/::g' \
-            -e 's:${RECIPE_SYSROOT_NATIVE}::g' \
-            -e 's:${BASE_WORKDIR}/${MULTIMACH_TARGET_SYS}::g' \
-            -i ${D}${PTEST_PATH}/Makefile
+    install -m755 ${S}/test/run ${S}/test/sort-getfattr-output ${D}${PTEST_PATH}/
 
-	sed -e "s|^srcdir =.*|srcdir = .|" \
-	    -e "s|^abs_srcdir =.*|abs_srcdir = .|" \
-	    -e "s|^abs_top_srcdir =.*|abs_top_srcdir = ..|" \
-	    -e "s|^Makefile:.*|Makefile:|" \
-	    -e "/^TEST_LOG_DRIVER =/s|(top_srcdir)|(top_builddir)|" \
-	    -i ${D}${PTEST_PATH}/Makefile
-
-	cp -rf ${S}/build-aux/ ${D}${PTEST_PATH}
-	cp -rf ${S}/test/ ${D}${PTEST_PATH}
+    for t in $(makefile-getvar ${S}/test/Makemodule.am TESTS); do
+        install -m644 ${S}/$t ${D}${PTEST_PATH}/
+    done
 }
 
 do_install_ptest:append:libc-musl() {
-        sed -i -e 's|f: Operation n|f: N|g' ${D}${PTEST_PATH}/test/attr.test
+    # With glibc strerror(ENOTSUP) is "Operation not supported" but
+    # musl is "Not supported".
+    # https://savannah.nongnu.org/bugs/?62370
+    sed -i -e 's|f: Operation not supported|f: Not supported|g' ${D}${PTEST_PATH}/attr.test
 }
 
 RDEPENDS:${PN}-ptest = "attr \
-                        bash \
-                        coreutils \
-                        perl-module-constant \
-                        perl-module-filehandle \
-                        perl-module-getopt-std \
-                        perl-module-posix \
-                        make \
                         perl \
-                        gawk \
                         perl-module-cwd \
                         perl-module-file-basename \
                         perl-module-file-path \
-                        perl-module-file-spec \
+                        perl-module-filehandle \
+                        perl-module-getopt-std \
+                        perl-module-posix \
                         "
 
 BBCLASSEXTEND = "native nativesdk"