@@ -69,6 +69,7 @@ PTESTS_FAST = "\
nettle \
npth \
opkg \
+ patch \
popt \
procps \
psmisc \
@@ -8,11 +8,25 @@ HOMEPAGE = "http://savannah.gnu.org/projects/patch/"
SRC_URI = "${GNU_MIRROR}/patch/patch-${PV}.tar.gz \
file://CVE-2026-56289.patch \
file://CVE-2026-56288.patch \
+ file://run-ptest \
"
S = "${UNPACKDIR}/patch-${PV}"
-inherit autotools update-alternatives
+inherit autotools update-alternatives ptest
ALTERNATIVE:${PN} = "patch"
ALTERNATIVE_PRIORITY = "100"
+
+do_install_ptest() {
+ install -d ${D}${PTEST_PATH}/tests
+ install -m 0644 ${S}/tests/test-lib.sh ${D}${PTEST_PATH}/tests/
+ for t in $(cd ${S}/tests && ls); do
+ if [ -f ${S}/tests/$t ] && [ "$t" != "test-lib.sh" ] && \
+ [ "$t" != "Makefile.am" ] && [ "$t" != "Makefile.in" ]; then
+ install -m 0755 ${S}/tests/$t ${D}${PTEST_PATH}/tests/$t
+ fi
+ done
+}
+
+RDEPENDS:${PN}-ptest += "diffutils sed coreutils"
new file mode 100755
@@ -0,0 +1,40 @@
+#!/bin/sh
+
+cd "$(dirname "$0")/tests" || exit 1
+
+PATCH="$(command -v patch)"
+srcdir="."
+abs_top_builddir="$(cd .. && pwd)"
+export PATCH srcdir abs_top_builddir
+
+XFAIL_TESTS="dash-o-append context-format"
+
+is_xfail() {
+ for x in $XFAIL_TESTS; do
+ [ "$1" = "$x" ] && return 0
+ done
+ return 1
+}
+
+for t in *; do
+ [ -f "$t" ] || continue
+ [ "$t" = "test-lib.sh" ] && continue
+
+ sh "$t"
+ rc=$?
+
+ if is_xfail "$t"; then
+ if [ "$rc" -eq 0 ]; then
+ echo "FAIL: $t (unexpected pass)"
+ else
+ echo "PASS: $t (expected failure)"
+ fi
+ continue
+ fi
+
+ case "$rc" in
+ 0) echo "PASS: $t" ;;
+ 77) echo "SKIP: $t" ;;
+ *) echo "FAIL: $t" ;;
+ esac
+done
Install GNU patch's shell-based test suite and run it under ptest against the installed binary. The run-ptest script maps the automake test protocol (exit 0 = pass, 77 = skip) to ptest-runner results and handles the dash-o-append and context-format expected failures. Tested on qemux86-64 with ptest-runner: 47 pass, 2 skip, 0 fail. Signed-off-by: Pratik Farkase <pratik.farkase@est.tech> --- Notes: Changes in v2: - run-ptest: don't redirect test output to a log file so failures are visible in automated environments (Ross Burton). .../distro/include/ptest-packagelists.inc | 1 + meta/recipes-devtools/patch/patch.inc | 16 +++++++- meta/recipes-devtools/patch/patch/run-ptest | 40 +++++++++++++++++++ 3 files changed, 56 insertions(+), 1 deletion(-) create mode 100755 meta/recipes-devtools/patch/patch/run-ptest