diff mbox series

tiff: add ptest support

Message ID 20260605065152.402887-1-Shilong.Jiao@windriver.com
State Under Review
Headers show
Series tiff: add ptest support | expand

Commit Message

Jiao, Shilong June 5, 2026, 6:51 a.m. UTC
From: Shilong Jiao <Shilong.Jiao@windriver.com>

Add ptest support for libtiff to enable automated testing of the
library's functionality.

Tests for tiffcrop are skipped as this tool has known security
vulnerabilities (CVE-2024-13978, CVE-2025-8176, etc.) and is
disabled by default since version 4.6.0. JBIG tests are skipped
as JBIG support is optional and not commonly enabled.

Test results on qemux86-64:
START: ptest-runner
BEGIN: /usr/lib/tiff/ptest
PASS: fax2tiff
PASS: ppm2tiff_pbm
PASS: ppm2tiff_pgm
PASS: ppm2tiff_ppm
PASS: testdeflatelaststripextradata
PASS: testfax3_bug54_1dnoEOL
PASS: testfax3_bug_513
PASS: testfax4
PASS: tiff2bw-palette-1c-8b
PASS: tiff2bw-quad-lzw-compat
PASS: tiff2bw-rgb-3c-8b
PASS: tiff2pdf
PASS: tiff2ps-EPS1
PASS: tiff2ps-PS1
PASS: tiff2ps-PS2
PASS: tiff2ps-PS3
PASS: tiff2rgba-32bpp-None-jpeg
PASS: tiff2rgba-logluv-3c-16b
PASS: tiff2rgba-minisblack-1c-16b
PASS: tiff2rgba-minisblack-1c-8b
PASS: tiff2rgba-minisblack-2c-8b-alpha
PASS: tiff2rgba-miniswhite-1c-1b
PASS: tiff2rgba-ojpeg_chewey_subsamp21_multi_strip
PASS: tiff2rgba-ojpeg_single_strip_no_rowsperstrip
PASS: tiff2rgba-ojpeg_zackthecat_subsamp22_single_strip
PASS: tiff2rgba-palette-1c-1b
PASS: tiff2rgba-palette-1c-4b
PASS: tiff2rgba-palette-1c-8b
PASS: tiff2rgba-quad-tile.jpg
PASS: tiff2rgba-rgb-3c-16b
PASS: tiff2rgba-rgb-3c-8b
PASS: tiffcp-32bpp-None-jpeg
PASS: tiffcp-g3-1d-fill
PASS: tiffcp-g3-1d
PASS: tiffcp-g3-2d-fill
PASS: tiffcp-g3-2d
PASS: tiffcp-g3
PASS: tiffcp-g4
PASS: tiffcp-logluv
PASS: tiffcp-lzw-compat
PASS: tiffcp-lzw-scanline-decode
SKIP: tiffcp-lzw-single-strip-jbig (JBIG not supported)
PASS: tiffcp-split-join
PASS: tiffcp-split
PASS: tiffcp-thumbnail
SKIP: tiffcrop-* (44 tests - tiffcrop has known issues)
PASS: tiffdump
PASS: tiffinfo
DURATION: 1
END: /usr/lib/tiff/ptest
STOP: ptest-runner
TOTAL: 1 FAIL: 0

Signed-off-by: Shilong Jiao <Shilong.Jiao@windriver.com>
---
 .../distro/include/ptest-packagelists.inc     |  1 +
 .../recipes-multimedia/libtiff/tiff/run-ptest | 34 +++++++++
 meta/recipes-multimedia/libtiff/tiff_4.7.1.bb | 76 ++++++++++++++++++-
 3 files changed, 110 insertions(+), 1 deletion(-)
 create mode 100644 meta/recipes-multimedia/libtiff/tiff/run-ptest
diff mbox series

Patch

diff --git a/meta/conf/distro/include/ptest-packagelists.inc b/meta/conf/distro/include/ptest-packagelists.inc
index f3f42f908a..0eaa09eb33 100644
--- a/meta/conf/distro/include/ptest-packagelists.inc
+++ b/meta/conf/distro/include/ptest-packagelists.inc
@@ -99,6 +99,7 @@  PTESTS_FAST = "\
     rpm-sequoia \
     sed \
     slang \
+    tiff \
     utfcpp \
     wayland \
     xz \
diff --git a/meta/recipes-multimedia/libtiff/tiff/run-ptest b/meta/recipes-multimedia/libtiff/tiff/run-ptest
new file mode 100644
index 0000000000..5c62de52c7
--- /dev/null
+++ b/meta/recipes-multimedia/libtiff/tiff/run-ptest
@@ -0,0 +1,34 @@ 
+#!/bin/sh
+
+cd $(dirname $0)/test
+
+for test in *.sh; do
+    [ -x "$test" ] || continue
+    
+    # Skip tests for tools with known issues or missing tools
+    case "$test" in
+        *tiffcrop*)
+            # tiffcrop has known security issues and is disabled by default since 4.6.0
+            echo "SKIP: ${test%.sh} (tiffcrop has known issues)"
+            continue
+            ;;
+        *jbig*)
+            # Skip JBIG tests if not supported
+            echo "SKIP: ${test%.sh} (JBIG not supported)"
+            continue
+            ;;
+        *thumbnail*)
+            # thumbnail tool may not be built by default
+            if [ ! -x ../tools/thumbnail ]; then
+                echo "SKIP: ${test%.sh} (thumbnail tool not available)"
+                continue
+            fi
+            ;;
+    esac
+    
+    if ./"$test" >/dev/null 2>&1; then
+        echo "PASS: ${test%.sh}"
+    else
+        echo "FAIL: ${test%.sh}"
+    fi
+done
diff --git a/meta/recipes-multimedia/libtiff/tiff_4.7.1.bb b/meta/recipes-multimedia/libtiff/tiff_4.7.1.bb
index 750565e11c..4175ce5870 100644
--- a/meta/recipes-multimedia/libtiff/tiff_4.7.1.bb
+++ b/meta/recipes-multimedia/libtiff/tiff_4.7.1.bb
@@ -23,7 +23,9 @@  CVE_STATUS[CVE-2023-6228] = "fixed-version: Fixed since 4.7.0, NVD tracks this a
 CVE_STATUS[CVE-2023-6277] = "fixed-version: Fixed since 4.7.0, NVD tracks this as version-less vulnerability"
 CVE_STATUS[CVE-2025-8851] = "fixed-version: Fixed since 4.7.0, NVD tracks this as fixed in 2024-08-11 vulnerability"
 
-inherit autotools multilib_header
+inherit autotools multilib_header ptest
+
+SRC_URI += "file://run-ptest"
 
 CACHED_CONFIGUREVARS = "ax_cv_check_gl_libgl=no"
 
@@ -63,4 +65,76 @@  do_install:append() {
     oe_multilib_header tiffconf.h
 }
 
+do_compile_ptest() {
+    oe_runmake -C ${B}/test
+    # Build additional tools needed for tests (they are in EXTRA_PROGRAMS)
+    oe_runmake -C ${B}/tools thumbnail || bbwarn "thumbnail tool failed to build"
+    oe_runmake -C ${B}/tools rgb2ycbcr || bbwarn "rgb2ycbcr tool failed to build"
+}
+
+do_install_ptest() {
+    install -d ${D}${PTEST_PATH}/test
+    install -d ${D}${PTEST_PATH}/tools
+
+    # Install test executables (they are in .libs after libtool build)
+    if [ -d ${B}/test/.libs ]; then
+        for f in ${B}/test/.libs/*; do
+            if [ -f "$f" ] && [ -x "$f" ]; then
+                case "$(basename $f)" in
+                    *.la|*.so*|*.o|lt-*) ;;
+                    *)
+                        install -m 0755 "$f" ${D}${PTEST_PATH}/tools/
+                        ;;
+                esac
+            fi
+        done
+    fi
+
+    # Also check test directory directly
+    for f in ${B}/test/*; do
+        if [ -f "$f" ] && [ -x "$f" ]; then
+            case "$(basename $f)" in
+                *.sh|*.la|*.so*|*.o|Makefile*|*.log) ;;
+                *)
+                    # Skip if already installed from .libs
+                    [ -f ${D}${PTEST_PATH}/tools/$(basename $f) ] && continue
+                    install -m 0755 "$f" ${D}${PTEST_PATH}/tools/
+                    ;;
+            esac
+        fi
+    done
+
+    # Install extra tools from tools/.libs (thumbnail, rgb2ycbcr)
+    if [ -d ${B}/tools/.libs ]; then
+        for tool in thumbnail rgb2ycbcr; do
+            if [ -f ${B}/tools/.libs/$tool ] && [ -x ${B}/tools/.libs/$tool ]; then
+                install -m 0755 ${B}/tools/.libs/$tool ${D}${PTEST_PATH}/tools/
+            fi
+        done
+    fi
+
+    # Install tiff tools from bindir
+    if [ -d ${D}${bindir} ]; then
+        for tool in ${D}${bindir}/*; do
+            if [ -f "$tool" ]; then
+                ln -sf ${bindir}/$(basename $tool) ${D}${PTEST_PATH}/tools/
+            fi
+        done
+    fi
+
+    # Install test data
+    cp -r ${S}/test/images ${D}${PTEST_PATH}/test/
+    cp -r ${S}/test/refs ${D}${PTEST_PATH}/test/
+
+    # Install test scripts
+    find ${S}/test -maxdepth 1 -name "*.sh" -exec install -m 0755 {} ${D}${PTEST_PATH}/test/ \;
+
+    # Install common.sh if exists
+    if [ -f ${S}/test/common.sh ]; then
+        install -m 0644 ${S}/test/common.sh ${D}${PTEST_PATH}/test/
+    fi
+}
+
+RDEPENDS:${PN}-ptest += "bash"
+
 BBCLASSEXTEND = "native nativesdk"