@@ -68,6 +68,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" > "$t.log" 2>&1
+ 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