Enable ptest for tiff (libtiff), running the upstream test suite shipped
in the source test/ directory: the C unit-test programs (check_PROGRAMS)
plus the shell-script tests that exercise the tiff command-line tools.

do_compile_ptest builds the test programs via "make check TESTS=" (build
only, no run). do_install_ptest installs the compiled test binaries (real
ELF from test/.libs, static testtypes from test/), the shell test scripts,
the shared common.sh helper, and the images/refs data. common.sh is
adjusted so the scripts find the installed tiff tools in ${bindir} rather
than the build tree's ../tools, and run-ptest recreates the SOURCE_DIR
path that test_ifd_loop_detection was compiled with so its images resolve
on target.

The run-ptest wrapper emits automake-style PASS/FAIL/SKIP results and
skips the JBIG test (JBIG is not in the default PACKAGECONFIG) and the
thumbnail test (the thumbnail tool is not built by default).

The recipe is registered in ptest-packagelists.inc (PTESTS_SLOW), and
buildpaths QA is skipped for the -ptest package since the compiled test
binaries legitimately embed build paths.

Validated on qemux86-64: all C tests and shell tests pass, 2 skipped
(jbig, thumbnail), 0 failed.

Signed-off-by: Himani Ramesh Barde <[email protected]>
---
 .../distro/include/ptest-packagelists.inc     |  1 +
 .../recipes-multimedia/libtiff/tiff/run-ptest | 31 ++++++++++++++
 meta/recipes-multimedia/libtiff/tiff_4.7.2.bb | 42 ++++++++++++++++++-
 3 files changed, 73 insertions(+), 1 deletion(-)
 create mode 100755 meta/recipes-multimedia/libtiff/tiff/run-ptest

diff --git a/meta/conf/distro/include/ptest-packagelists.inc 
b/meta/conf/distro/include/ptest-packagelists.inc
index 2b5d665..837e1c1 100644
--- a/meta/conf/distro/include/ptest-packagelists.inc
+++ b/meta/conf/distro/include/ptest-packagelists.inc
@@ -151,6 +151,7 @@ PTESTS_SLOW = "\
     tar \
     tcl \
     tcl8 \
+    tiff \
     util-linux \
     zstd \
 "
diff --git a/meta/recipes-multimedia/libtiff/tiff/run-ptest 
b/meta/recipes-multimedia/libtiff/tiff/run-ptest
new file mode 100755
index 0000000..40301ed
--- /dev/null
+++ b/meta/recipes-multimedia/libtiff/tiff/run-ptest
@@ -0,0 +1,31 @@
+#!/bin/sh
+# Run the libtiff test suite and emit ptest-style PASS/FAIL/SKIP lines.
+cd "$(dirname "$0")/test" || exit 1
+
+# test_ifd_loop_detection is built with -DSOURCE_DIR="@SOURCE_DIR@" and opens
+# its images via that relative path; symlink it to the installed test dir.
+if [ ! -e "@SOURCE_DIR@" ]; then
+    mkdir -p "$(dirname @SOURCE_DIR@)"
+    ln -sf "$(pwd)" "@SOURCE_DIR@" 2>/dev/null || true
+fi
+
+CPROGS="ascii_tag long_tag short_tag strip_rw rewrite custom_dir \
+custom_dir_EXIF_231 defer_strile_loading defer_strile_writing test_directory \
+test_IFD_enlargement test_open_options test_append_to_strip \
+test_ifd_loop_detection testtypes test_signed_tags raw_decode"
+
+for t in $CPROGS; do
+    if [ -x "./$t" ]; then
+        if ./"$t" >/dev/null 2>&1; then echo "PASS: $t"; else echo "FAIL: $t"; 
fi
+    fi
+done
+
+for t in *.sh; do
+    [ "$t" = "common.sh" ] && continue
+    case "$t" in
+        *jbig*) echo "SKIP: $t (JBIG support not enabled)"; continue ;;
+        tiffcp-thumbnail.sh)
+            command -v thumbnail >/dev/null 2>&1 || { echo "SKIP: $t 
(thumbnail tool not built)"; continue; } ;;
+    esac
+    if sh "./$t" >/dev/null 2>&1; then echo "PASS: $t"; else echo "FAIL: $t"; 
fi
+done
diff --git a/meta/recipes-multimedia/libtiff/tiff_4.7.2.bb 
b/meta/recipes-multimedia/libtiff/tiff_4.7.2.bb
index 8bc3a48..ea4300b 100644
--- a/meta/recipes-multimedia/libtiff/tiff_4.7.2.bb
+++ b/meta/recipes-multimedia/libtiff/tiff_4.7.2.bb
@@ -9,6 +9,7 @@ LIC_FILES_CHKSUM = 
"file://LICENSE.md;md5=4ab490c3088a0acff254eb2f8c577547"
 CVE_PRODUCT = "libtiff"
 
 SRC_URI = "http://download.osgeo.org/libtiff/tiff-${PV}.tar.gz \
+           file://run-ptest \
           "
 
 SRC_URI[sha256sum] = 
"672bd7d10aee4606171afb864f3570b83340f6a33e2c186dc0512f7145ffdf6a"
@@ -23,7 +24,7 @@ CVE_STATUS[CVE-2023-6277] = "fixed-version: Fixed since 
4.7.0, NVD tracks this a
 CVE_STATUS[CVE-2025-8851] = "fixed-version: Fixed since 4.7.0, NVD tracks this 
as fixed in 2024-08-11 vulnerability"
 CVE_STATUS[CVE-2026-4775] = "fixed-version: Fixed since 4.7.2, NVD tracks this 
as version-less vulnerability"
 
-inherit autotools multilib_header
+inherit autotools multilib_header ptest
 
 CACHED_CONFIGUREVARS = "ax_cv_check_gl_libgl=no"
 
@@ -64,3 +65,42 @@ do_install:append() {
 }
 
 BBCLASSEXTEND = "native nativesdk"
+
+do_compile_ptest() {
+    oe_runmake -C ${B}/test check TESTS=""
+}
+
+do_install_ptest() {
+    install -d ${D}${PTEST_PATH}/test
+    # Compiled C unit-test programs. libtool leaves a wrapper script in test/
+    # and the real ELF binary in test/.libs/; testtypes is static and lives
+    # only in test/.
+    for prog in ascii_tag long_tag short_tag strip_rw rewrite custom_dir \
+                custom_dir_EXIF_231 defer_strile_loading defer_strile_writing \
+                test_directory test_IFD_enlargement test_open_options \
+                test_append_to_strip test_ifd_loop_detection testtypes \
+                test_signed_tags raw_decode; do
+        if [ -e ${B}/test/.libs/$prog ]; then
+            install -m 0755 ${B}/test/.libs/$prog ${D}${PTEST_PATH}/test/
+        else
+            install -m 0755 ${B}/test/$prog ${D}${PTEST_PATH}/test/
+        fi
+    done
+    # Shell test scripts and the shared helper
+    install ${S}/test/*.sh ${D}${PTEST_PATH}/test/
+    install ${S}/test/common.sh ${D}${PTEST_PATH}/test/
+    # Point the test scripts at the installed tiff tools instead of ../tools
+    sed -i -e "s|^TOOLS=.*|TOOLS=${bindir}|" ${D}${PTEST_PATH}/test/common.sh
+    # test_ifd_loop_detection embeds -DSOURCE_DIR=../../tiff-${PV}/test; fill
+    # that path into run-ptest so it can be symlinked to the installed tests.
+    sed -i -e "s|@SOURCE_DIR@|../../tiff-${PV}/test|g" 
${D}${PTEST_PATH}/run-ptest
+    # Input images and reference outputs
+    cp -r ${S}/test/images ${D}${PTEST_PATH}/test/
+    cp -r ${S}/test/refs ${D}${PTEST_PATH}/test/
+}
+
+RDEPENDS:${PN}-ptest += "make bash tiff-utils"
+
+# The compiled C test programs embed build paths in debug info; this is
+# expected for ptest binaries and not relevant to the shipped library.
+INSANE_SKIP:${PN}-ptest += "buildpaths"
-- 
2.54.0

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#245825): 
https://lists.openembedded.org/g/openembedded-core/message/245825
Mute This Topic: https://lists.openembedded.org/mt/121257807/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to