diff options
| author | AshishKumar Mishra <ashishkumar.mishra@bmwtechworks.in> | 2025-11-06 14:44:10 +0530 |
|---|---|---|
| committer | Khem Raj <raj.khem@gmail.com> | 2025-11-06 16:00:52 -0800 |
| commit | 96b97c0c6490b713b559a4e82bd699a2ebe357d3 (patch) | |
| tree | 2282c0a422cfcfccc47a306219419931eb548a46 | |
| parent | 78e81c6390ab5c8585c33d7ed4b0d11372951406 (diff) | |
| download | meta-openembedded-96b97c0c6490b713b559a4e82bd699a2ebe357d3.tar.gz | |
imagemagick: adds ptest for imagemagick
The logic used is :
- We check if the required tools are present or not
- We used magick to create an raw RGB file
- The created RGB is then converted to PNG using convert
- We re-gerenate RGB from PNG and compare the original and re-generated RGB
- Enabled the ptest in ptest-packagelists-meta-oe.inc as
suggested by Gyorgy Sarvari and incorporated logging suggestion
- This was done as standard imagemagick test like drawtest requires manual
internetion to verify the file
Signed-off-by: AshishKumar Mishra <ashishkumar.mishra@bmwtechworks.in>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
4 files changed, 189 insertions, 2 deletions
diff --git a/meta-oe/conf/include/ptest-packagelists-meta-oe.inc b/meta-oe/conf/include/ptest-packagelists-meta-oe.inc index 0a5bbf5fe5..a685510359 100644 --- a/meta-oe/conf/include/ptest-packagelists-meta-oe.inc +++ b/meta-oe/conf/include/ptest-packagelists-meta-oe.inc | |||
| @@ -16,6 +16,7 @@ PTESTS_FAST_META_OE = "\ | |||
| 16 | function2 \ | 16 | function2 \ |
| 17 | fwupd \ | 17 | fwupd \ |
| 18 | gcab \ | 18 | gcab \ |
| 19 | imagemagick \ | ||
| 19 | jemalloc \ | 20 | jemalloc \ |
| 20 | jq \ | 21 | jq \ |
| 21 | leveldb \ | 22 | leveldb \ |
diff --git a/meta-oe/recipes-support/imagemagick/imagemagick/imagemagick-ptest.sh b/meta-oe/recipes-support/imagemagick/imagemagick/imagemagick-ptest.sh new file mode 100755 index 0000000000..08595837d6 --- /dev/null +++ b/meta-oe/recipes-support/imagemagick/imagemagick/imagemagick-ptest.sh | |||
| @@ -0,0 +1,132 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | # | ||
| 3 | # ImageMagick ptest: | ||
| 4 | # We ceate an BASERGB file for our usage using "magick" | ||
| 5 | # We convert this RGB file to BASEPNG | ||
| 6 | # Using BASEPNG we recreate RGB named REGENERATEDRGB | ||
| 7 | # | ||
| 8 | # BASERGB to BASEPNG to REGENERATEDRGB | ||
| 9 | # - Then compare BASERGB with REGENERATEDRGB | ||
| 10 | # | ||
| 11 | # 0) The convert command is deprecated in IMv7 | ||
| 12 | # used "magick" instead of "convert" | ||
| 13 | # 1) We are checking if the binaries are present in RFS or not | ||
| 14 | # 2) We Created an RBG of size : WIDTH x HEIGHT pixels | ||
| 15 | # 3) Return value is captured after every major actio to capture the status | ||
| 16 | # 4) cmp -s is used to compare binary byte by byte data and | ||
| 17 | # capture only exit status | ||
| 18 | # 5) Important parametsrs used are : | ||
| 19 | # -depth : How many bits for each colour pixel | ||
| 20 | # -alpha off : Don't consider transparency | ||
| 21 | # -define png:color-type=2 : Make PNG work with truecolour RGB | ||
| 22 | # -strip : Remove all non-pixel metadata og PNG | ||
| 23 | # so file is reproducible | ||
| 24 | # -set gamma 1.0 : No PNG brightness correction | ||
| 25 | # gradient:red-blue : Data moves liberly from RED to Blue vertically | ||
| 26 | |||
| 27 | |||
| 28 | WIDTH=16 | ||
| 29 | HEIGHT=16 | ||
| 30 | BASERGB=base.rgb | ||
| 31 | BASEPNG=base.png | ||
| 32 | REGENERATEDRGB=roundtrip.rgb | ||
| 33 | |||
| 34 | echo "[DEBUG] Starting ImageMagick Ptest with ${WIDTH}x${HEIGHT} pixels " | ||
| 35 | |||
| 36 | # Verify required binaries | ||
| 37 | for bin in magick cmp wc rm; do | ||
| 38 | if [ -z "$(command -v "$bin" 2>/dev/null)" ]; then | ||
| 39 | echo "[ERROR] Required binary '$bin' not found $PATH" | ||
| 40 | exit 127 | ||
| 41 | fi | ||
| 42 | done | ||
| 43 | |||
| 44 | |||
| 45 | # Generate raw RGB | ||
| 46 | magick -size ${WIDTH}x${HEIGHT} gradient:red-blue \ | ||
| 47 | -depth 8 -type TrueColor \ | ||
| 48 | -alpha off -define png:color-type=2 \ | ||
| 49 | -strip -set gamma 1.0 \ | ||
| 50 | rgb:${BASERGB} | ||
| 51 | |||
| 52 | returnvalue=$? | ||
| 53 | if [ "$returnvalue" -ne 0 ]; then | ||
| 54 | echo "[FAIL] Failed to generate RGB pattern " | ||
| 55 | exit 1 | ||
| 56 | else | ||
| 57 | echo "[DEBUG] ${BASERGB} generated from gradient" | ||
| 58 | fi | ||
| 59 | |||
| 60 | |||
| 61 | # Convert raw RGB to PNG | ||
| 62 | magick -depth 8 -size ${WIDTH}x${HEIGHT} rgb:${BASERGB} \ | ||
| 63 | -type TrueColor -alpha off \ | ||
| 64 | -define png:color-type=2 -strip -set gamma 1.0 \ | ||
| 65 | ${BASEPNG} | ||
| 66 | |||
| 67 | returnvalue=$? | ||
| 68 | if [ $returnvalue -ne 0 ]; then | ||
| 69 | echo "[FAIL] Failed to convert RGB to PNG" | ||
| 70 | rm -f ${BASERGB} | ||
| 71 | exit 1 | ||
| 72 | else | ||
| 73 | echo "[DEBUG] ${BASEPNG} generated from ${BASERGB}" | ||
| 74 | fi | ||
| 75 | |||
| 76 | |||
| 77 | |||
| 78 | # Regenerate raw RGB from PNG | ||
| 79 | magick ${BASEPNG} \ | ||
| 80 | -size ${WIDTH}x${HEIGHT} -depth 8 -type TrueColor \ | ||
| 81 | -alpha off -define png:color-type=2 \ | ||
| 82 | -strip -set gamma 1.0 \ | ||
| 83 | rgb:${REGENERATEDRGB} | ||
| 84 | |||
| 85 | returnvalue=$? | ||
| 86 | if [ $returnvalue -ne 0 ]; then | ||
| 87 | echo "[FAIL] Failed to regenerate RGB from PNG" | ||
| 88 | rm -f ${BASERGB} ${BASEPNG} | ||
| 89 | exit 1 | ||
| 90 | else | ||
| 91 | echo "[DEBUG] ${REGENERATEDRGB} generated from ${BASEPNG}" | ||
| 92 | fi | ||
| 93 | |||
| 94 | |||
| 95 | |||
| 96 | # Compare original and recreated RGB | ||
| 97 | if cmp -s ${BASERGB} ${REGENERATEDRGB}; then | ||
| 98 | echo "[PASS] RGB data identical after PNG round-trip" | ||
| 99 | RESULT=0 | ||
| 100 | else | ||
| 101 | echo "[FAIL] RGB mismatch detected, printing their size " | ||
| 102 | echo "[INFO] Base RGB size: $(wc -c < ${BASERGB}) bytes" | ||
| 103 | echo "[INFO] Round-trip RGB size: $(wc -c < ${REGENERATEDRGB}) bytes" | ||
| 104 | RESULT=1 | ||
| 105 | fi | ||
| 106 | |||
| 107 | |||
| 108 | |||
| 109 | # Checking the identify tool from imagemagick to get the PNG metadata | ||
| 110 | # True is added in end to ensure that test script doesnt fail even if | ||
| 111 | # identify fails for any reason | ||
| 112 | echo "[DEBUG] PNG file info:" | ||
| 113 | identify -verbose ${BASEPNG} | grep -E "Depth|Type|Colorspace" || true | ||
| 114 | |||
| 115 | |||
| 116 | |||
| 117 | # Cleanup of files create by test code | ||
| 118 | echo "[DEBUG] Cleaning up temporary files" | ||
| 119 | rm -f ${BASERGB} ${BASEPNG} ${REGENERATEDRGB} | ||
| 120 | returnvalue=$? | ||
| 121 | echo "[DEBUG] Cleanup exit=$returnvalue" | ||
| 122 | |||
| 123 | |||
| 124 | # Logging the final result | ||
| 125 | if [ ${RESULT} -eq 0 ]; then | ||
| 126 | echo "[DEBUG]: imagemagick-ptest.sh sucessfull " | ||
| 127 | else | ||
| 128 | echo "[DEBUG]: imagemagick-ptest.sh failed " | ||
| 129 | fi | ||
| 130 | |||
| 131 | |||
| 132 | exit ${RESULT} | ||
diff --git a/meta-oe/recipes-support/imagemagick/imagemagick/run-ptest b/meta-oe/recipes-support/imagemagick/imagemagick/run-ptest new file mode 100644 index 0000000000..75251a803f --- /dev/null +++ b/meta-oe/recipes-support/imagemagick/imagemagick/run-ptest | |||
| @@ -0,0 +1,43 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | # | ||
| 3 | # run-ptest — ImageMagick ptest harness | ||
| 4 | # POSIX-safe and BusyBox compatible | ||
| 5 | |||
| 6 | PTDIR=$(dirname "$0") | ||
| 7 | TESTDIR="$PTDIR" | ||
| 8 | PASSCOUNT=0 | ||
| 9 | FAILCOUNT=0 | ||
| 10 | TOTAL=0 | ||
| 11 | |||
| 12 | echo "=======================================" | ||
| 13 | echo "ImageMagick ptest: Runtime Validation" | ||
| 14 | echo "=======================================" | ||
| 15 | |||
| 16 | for t in "$TESTDIR"/*.sh; do | ||
| 17 | [ -x "$t" ] || chmod +x "$t" | ||
| 18 | TOTAL=$((TOTAL + 1)) | ||
| 19 | echo | ||
| 20 | echo "[DEBUG] Launching test script $t" | ||
| 21 | |||
| 22 | if sh "$t" 2>&1; then | ||
| 23 | echo "PASS: $(basename "$t")" | ||
| 24 | PASSCOUNT=$((PASSCOUNT + 1)) | ||
| 25 | else | ||
| 26 | rc=$? | ||
| 27 | if [ "$rc" -eq 77 ]; then | ||
| 28 | echo "SKIP: $(basename "$t")" | ||
| 29 | else | ||
| 30 | echo "FAIL: $(basename "$t")" | ||
| 31 | FAILCOUNT=$((FAILCOUNT + 1)) | ||
| 32 | fi | ||
| 33 | fi | ||
| 34 | |||
| 35 | done | ||
| 36 | |||
| 37 | echo | ||
| 38 | echo "=======================================" | ||
| 39 | echo "[SUMMARY] Total: $TOTAL | PASS: $PASSCOUNT | FAIL: $FAILCOUNT" | ||
| 40 | echo "=======================================" | ||
| 41 | echo | ||
| 42 | [ "$FAILCOUNT" -eq 0 ] | ||
| 43 | |||
diff --git a/meta-oe/recipes-support/imagemagick/imagemagick_7.1.2-8.bb b/meta-oe/recipes-support/imagemagick/imagemagick_7.1.2-8.bb index f83adb15f2..b445ae8f62 100644 --- a/meta-oe/recipes-support/imagemagick/imagemagick_7.1.2-8.bb +++ b/meta-oe/recipes-support/imagemagick/imagemagick_7.1.2-8.bb | |||
| @@ -12,11 +12,15 @@ DEPENDS = "lcms bzip2 jpeg libpng tiff zlib fftw freetype libtool" | |||
| 12 | BASE_PV = "${@d.getVar('PV').split('-')[0]}" | 12 | BASE_PV = "${@d.getVar('PV').split('-')[0]}" |
| 13 | UPSTREAM_CHECK_GITTAGREGEX = "(?P<pver>([0-9][\.|_|-]?)+)" | 13 | UPSTREAM_CHECK_GITTAGREGEX = "(?P<pver>([0-9][\.|_|-]?)+)" |
| 14 | 14 | ||
| 15 | SRC_URI = "git://github.com/ImageMagick/ImageMagick.git;branch=main;protocol=https;tag=${PV}" | 15 | SRC_URI = "git://github.com/ImageMagick/ImageMagick.git;branch=main;protocol=https;tag=${PV} \ |
| 16 | file://run-ptest \ | ||
| 17 | file://imagemagick-ptest.sh \ | ||
| 18 | " | ||
| 19 | |||
| 16 | SRCREV = "a3b13d143fd7dea44cd71d31aa02f411b597688f" | 20 | SRCREV = "a3b13d143fd7dea44cd71d31aa02f411b597688f" |
| 17 | 21 | ||
| 18 | 22 | ||
| 19 | inherit autotools pkgconfig update-alternatives | 23 | inherit autotools pkgconfig update-alternatives ptest |
| 20 | export ac_cv_sys_file_offset_bits = "64" | 24 | export ac_cv_sys_file_offset_bits = "64" |
| 21 | 25 | ||
| 22 | EXTRA_OECONF = "--program-prefix= --program-suffix=.im7 --without-perl --enable-largefile" | 26 | EXTRA_OECONF = "--program-prefix= --program-suffix=.im7 --without-perl --enable-largefile" |
| @@ -55,6 +59,13 @@ do_install:append:class-target() { | |||
| 55 | fi | 59 | fi |
| 56 | } | 60 | } |
| 57 | 61 | ||
| 62 | do_install_ptest() { | ||
| 63 | install -d ${D}${PTEST_PATH} | ||
| 64 | install -m 0755 ${UNPACKDIR}/run-ptest ${D}${PTEST_PATH}/ | ||
| 65 | install -m 0755 ${UNPACKDIR}/imagemagick-ptest.sh ${D}${PTEST_PATH}/ | ||
| 66 | } | ||
| 67 | |||
| 68 | |||
| 58 | FILES:${PN} += "${libdir}/ImageMagick-${BASE_PV}/config-Q16* \ | 69 | FILES:${PN} += "${libdir}/ImageMagick-${BASE_PV}/config-Q16* \ |
| 59 | ${datadir}/ImageMagick-7" | 70 | ${datadir}/ImageMagick-7" |
| 60 | 71 | ||
