patch: add ptest support
PATCH 1/1 patch: add ptest support
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.
--- .../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
meta/conf/distro/include/ptest-packagelists.inc +1 -0
@@ -68,6 +68,7 @@ PTESTS_FAST = "\ nettle \ npth \ opkg \ + patch \ popt \ procps \ psmisc \
meta/recipes-devtools/patch/patch.inc +15 -1
@@ -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"
meta/recipes-devtools/patch/patch/run-ptest new file +40 -0
@@ -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
Signature · 1 line
2.43.0
Quoted 2 lines · Pratik Farkase via lists.openembedded.org
+ sh "$t" > "$t.log" 2>&1
Don’t redirect the output to a log file, we run the tests in automated environments and if the failure isn’t output then we can’t see it.
Ross
PATCH v2 1/1 patch: add ptest support
In reply to Pratik FarkaseInstall 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.
---
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
meta/conf/distro/include/ptest-packagelists.inc +1 -0
@@ -69,6 +69,7 @@ PTESTS_FAST = "\ nettle \ npth \ opkg \ + patch \ popt \ procps \ psmisc \
meta/recipes-devtools/patch/patch.inc +15 -1
@@ -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"
meta/recipes-devtools/patch/patch/run-ptest new file +40 -0
@@ -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
Signature · 1 line
2.43.0