Skip to contentSkip to conversation

scripts/makefile-getvar: be more resilient

PATCH New Ross Burton 1 participant 5 messages Dec 18, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/5 scripts/makefile-getvar: be more resilient

Check that we've been passed enough arguments (at least the Makefile and one variable), and that the Makefile specified is actually a file.

---
 scripts/makefile-getvar | 11 +++++++++++
 1 file changed, 11 insertions(+)
scripts/makefile-getvar +11 -0
index 4a07055e687..e8a98327667 100755
@@ -11,9 +11,20 @@
 
 set -eu
 
+if [ $# -lt 2 ]; then
+	echo "Get a variable's value from a Makefile:"
+	echo "$ makefile-getvar Makefile VARIABLE VARIABLE ..."
+	exit 0
+fi
+
 MAKEFILE=$1
 shift
 
+if [ ! -f $MAKEFILE ]; then
+	echo $MAKEFILE is not a file
+	exit 1
+fi
+
 for VARIABLE in $*; do
 	make -f - $VARIABLE.var <<EOF
 include $MAKEFILE
Signature · 1 line
2.43.0
#1 lore raw

PATCH 2/5 libseccomp: allow out-of-tree builds

Out of tree builds appear to work fine, so use them. This means updating do_install_ptest so that it correctly uses S or B as appropriate.

---
 .../libseccomp/libseccomp_2.6.0.bb            | 38 +++++++++++--------
 1 file changed, 23 insertions(+), 15 deletions(-)
meta/recipes-support/libseccomp/libseccomp_2.6.0.bb +23 -15
index 998f1b5548d..dd56391e1ff 100644
@@ -14,7 +14,7 @@ SRC_URI = "git://github.com/seccomp/libseccomp.git;branch=release-2.6;protocol=h
            file://run-ptest \
            "
 
-inherit autotools-brokensep pkgconfig ptest features_check
+inherit autotools pkgconfig ptest features_check
 
 inherit_defer ${@bb.utils.contains('PACKAGECONFIG', 'python', 'python3native', '', d)}
 
@@ -31,27 +31,35 @@ do_compile_ptest() {
 
 do_install_ptest() {
     install -d ${D}${PTEST_PATH}/tests
-    install -d ${D}${PTEST_PATH}/tools
-    for file in $(find tests/* -executable -type f); do
-        install -m 744 ${S}/${file} ${D}/${PTEST_PATH}/tests
+    for file in $(find ${S}/tests/* -executable -type f); do
+        install -m 744 $file ${D}/${PTEST_PATH}/tests
     done
-    for file in $(find tests/*.tests -type f); do
-        install -m 744 ${S}/${file} ${D}/${PTEST_PATH}/tests
+    for file in $(find ${B}/tests/* -executable -type f); do
+        install -m 744 $file ${D}/${PTEST_PATH}/tests
     done
-        for file in $(find tests/*.pfc -type f); do
-        install -m 644 ${S}/${file} ${D}/${PTEST_PATH}/tests
+    for file in $(find ${S}/tests/*.tests -type f); do
+        install -m 744 $file ${D}/${PTEST_PATH}/tests
+    done
+        for file in $(find ${S}/tests/*.pfc -type f); do
+        install -m 644 $file ${D}/${PTEST_PATH}/tests
     done
     install -m 644 ${S}/tests/valgrind_test.supp ${D}/${PTEST_PATH}/tests
-    for file in $(find tools/* -executable -type f); do
-        install -m 744 ${S}/${file} ${D}/${PTEST_PATH}/tools
+
+    install -d ${D}${PTEST_PATH}/tools
+    for file in $(find ${S}/tools/* -executable -type f); do
+        install -m 744 $file ${D}/${PTEST_PATH}/tools
+    done
+    for file in $(find ${B}/tools/* -executable -type f); do
+        install -m 744 $file ${D}/${PTEST_PATH}/tools
     done
     # Overwrite libtool wrappers with real executables
-    for file in $(find tools/.libs/* -executable -type f); do
-        install -m 744 ${S}/${file} ${D}/${PTEST_PATH}/tools
+    for file in $(find ${B}/tools/.libs/* -executable -type f); do
+        install -m 744 $file ${D}/${PTEST_PATH}/tools
     done
-     # fix python shebang
-     sed -i -e 's@cmd /usr/bin/env python @cmd /usr/bin/env python3 @' ${D}/${PTEST_PATH}/tests/regression
-     sed -i -e 's@^#!/usr/bin/env python$@#!/usr/bin/env python3@' ${D}/${PTEST_PATH}/tests/*.py
+
+    # fix python shebang
+    sed -i -e 's@cmd /usr/bin/env python @cmd /usr/bin/env python3 @' ${D}/${PTEST_PATH}/tests/regression
+    sed -i -e 's@^#!/usr/bin/env python$@#!/usr/bin/env python3@' ${D}/${PTEST_PATH}/tests/*.py
 }
 
 FILES:${PN} = "${bindir} ${libdir}/${BPN}.so* ${PYTHON_SITEPACKAGES_DIR}/"
Signature · 1 line
2.43.0
#2 lore raw

PATCH 3/5 libseccomp: use libtool to install test binaries

In reply to Ross Burton

Instead of installing the libtool wrapper scripts and hoping that the real binaries are in .libs/, just use libtool to install the binaries directly.

This will relink if needed, and removes any assumptions about file locations.

---
 .../libseccomp/libseccomp_2.6.0.bb             | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)
meta/recipes-support/libseccomp/libseccomp_2.6.0.bb +7 -11
index dd56391e1ff..2c06824a799 100644
@@ -32,13 +32,13 @@ do_compile_ptest() {
 do_install_ptest() {
     install -d ${D}${PTEST_PATH}/tests
     for file in $(find ${S}/tests/* -executable -type f); do
-        install -m 744 $file ${D}/${PTEST_PATH}/tests
-    done
-    for file in $(find ${B}/tests/* -executable -type f); do
-        install -m 744 $file ${D}/${PTEST_PATH}/tests
+        install $file ${D}/${PTEST_PATH}/tests
     done
     for file in $(find ${S}/tests/*.tests -type f); do
-        install -m 744 $file ${D}/${PTEST_PATH}/tests
+        install $file ${D}/${PTEST_PATH}/tests
+    done
+    for file in $(find ${B}/tests/* -executable -type f); do
+        ${B}/libtool --mode=install install $file ${D}/${PTEST_PATH}/tests
     done
         for file in $(find ${S}/tests/*.pfc -type f); do
         install -m 644 $file ${D}/${PTEST_PATH}/tests
@@ -47,14 +47,10 @@ do_install_ptest() {
 
     install -d ${D}${PTEST_PATH}/tools
     for file in $(find ${S}/tools/* -executable -type f); do
-        install -m 744 $file ${D}/${PTEST_PATH}/tools
+        install $file ${D}/${PTEST_PATH}/tools
     done
     for file in $(find ${B}/tools/* -executable -type f); do
-        install -m 744 $file ${D}/${PTEST_PATH}/tools
-    done
-    # Overwrite libtool wrappers with real executables
-    for file in $(find ${B}/tools/.libs/* -executable -type f); do
-        install -m 744 $file ${D}/${PTEST_PATH}/tools
+        ${B}/libtool --mode=install install $file ${D}/${PTEST_PATH}/tools
     done
 
     # fix python shebang
Signature · 1 line
2.43.0
#3 lore raw

PATCH 4/5 libseccomp: remove redundant FILES

In reply to Ross Burton

Remove FILES entries that are already either in the default, or now redundant.

---
 meta/recipes-support/libseccomp/libseccomp_2.6.0.bb | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
meta/recipes-support/libseccomp/libseccomp_2.6.0.bb +1 -2
index 2c06824a799..9bbdc6b833b 100644
@@ -58,8 +58,7 @@ do_install_ptest() {
     sed -i -e 's@^#!/usr/bin/env python$@#!/usr/bin/env python3@' ${D}/${PTEST_PATH}/tests/*.py
 }
 
-FILES:${PN} = "${bindir} ${libdir}/${BPN}.so* ${PYTHON_SITEPACKAGES_DIR}/"
-FILES:${PN}-dbg += "${libdir}/${PN}/tests/.debug/* ${libdir}/${PN}/tools/.debug"
+FILES:${PN} += "${PYTHON_SITEPACKAGES_DIR}/"
 
 RDEPENDS:${PN} += "${@bb.utils.contains('PACKAGECONFIG', 'python', 'python3', '', d)}"
 RDEPENDS:${PN}-ptest = "coreutils bash"
Signature · 1 line
2.43.0
#4 lore raw

PATCH 5/5 libexif: rewrite ptest handling

In reply to Ross Burton

What started as replacing the installation of libtool wrapper scripts ended up being a rewrite of the ptest integration.

There are only ~15 tests so we can install the binaries with libtool, extract the test names from the Makefile, and just run them with a few lines of shell.

---
 .../recipes-support/libexif/libexif/run-ptest | 34 +++++++++++++++++--
 .../recipes-support/libexif/libexif_0.6.25.bb | 21 ++++--------
 2 files changed, 38 insertions(+), 17 deletions(-)
meta/recipes-support/libexif/libexif/run-ptest +32 -2
index 2d23159eb03..6a50f64822a 100644
@@ -1,3 +1,33 @@
-#!/bin/sh
+#! /bin/sh
 
-make -o Makefile runtest-TESTS
+all=0
+passed=0
+failed=0
+skipped=0
+
+for t in @TESTS@; do
+    "./$t"
+    case "$?" in
+        0)
+            echo "PASS: $t"
+            passed=$((passed + 1))
+            ;;
+        77)
+            echo "SKIP: $t"
+            skipped=$((skipped + 1))
+            ;;
+        *)
+            echo "FAIL: $t"
+            failed=$((failed + 1))
+            ;;
+    esac
+    all=$((all + 1))
+done
+
+if [ "$failed" -eq 0 ]; then
+    echo "All $all tests passed ($skipped skipped)"
+    exit 0
+else
+    echo "$failed of $all tests failed ($skipped skipped)"
+    exit 1
+fi
meta/recipes-support/libexif/libexif_0.6.25.bb +6 -15
index 59c22753d04..c57855303f4 100644
@@ -23,25 +23,16 @@ do_compile_ptest() {
 }
 
 do_install_ptest() {
-    install ${B}/test/test*[!\.o] ${D}${PTEST_PATH}
-    for f in ${D}${PTEST_PATH}/test*; do
-        sed -i "s/\(LD_LIBRARY_PATH=\).*\(:\$LD_LIBRARY_PATH\)\"/\1.\2/" $f
-    done
-
-    install ${B}/test/Makefile ${D}${PTEST_PATH}
-    sed -i -e "/^srcdir/c srcdir = \$\{PWD\}" ${D}${PTEST_PATH}/Makefile
-
-    install -d ${D}${PTEST_PATH}/nls
-    install ${B}/test/nls/*[!\.o] ${D}${PTEST_PATH}/nls
-    install -d ${D}${PTEST_PATH}/.libs
-    install ${B}/test/.libs/* ${D}${PTEST_PATH}/.libs
-
     install ${S}/test/*.sh ${D}${PTEST_PATH}
 
+    for file in $(find ${B}/test/test-* -executable -type f); do
+        ${B}/libtool --mode=install install $file ${D}/${PTEST_PATH}
+    done
+
     install -d ${D}${PTEST_PATH}/testdata
     install ${S}/test/testdata/* ${D}${PTEST_PATH}/testdata
+
+    sed -i -e "s/@TESTS@/$(makefile-getvar ${B}/test/Makefile TESTS)/" ${D}${PTEST_PATH}/run-ptest
 }
 
-RDEPENDS:${PN}-ptest += "make bash"
-
 BBCLASSEXTEND = "native nativesdk"
Signature · 1 line
2.43.0