| Message ID | 20251103051945.1615774-1-ashishkumar.mishra@bmwtechworks.in |
|---|---|
| State | New |
| Headers | show |
| Series | [meta-oe,master] imagemagick: adds ptest for imagemagick recipe | expand |
Khem, Did this patch fell through the cracks accidentally, or do you think it needs some corrections first? On 11/3/25 06:19, AshishKumar Mishra via lists.openembedded.org wrote: > 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. > --- > .../include/ptest-packagelists-meta-oe.inc | 1 + > .../imagemagick/imagemagick-ptest.sh | 132 ++++++++++++++++++ > .../imagemagick/imagemagick/run-ptest | 43 ++++++ > .../imagemagick/imagemagick_7.1.2-5.bb | 13 +- > 4 files changed, 187 insertions(+), 2 deletions(-) > create mode 100755 meta-oe/recipes-support/imagemagick/imagemagick/imagemagick-ptest.sh > create mode 100644 meta-oe/recipes-support/imagemagick/imagemagick/run-ptest > > diff --git a/meta-oe/conf/include/ptest-packagelists-meta-oe.inc b/meta-oe/conf/include/ptest-packagelists-meta-oe.inc > index 825747d522..bd6db35c5b 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 = "\ > function2 \ > fwupd \ > gcab \ > + imagemagick \ > jemalloc \ > jq \ > 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 @@ > +#!/bin/sh > +# > +# ImageMagick ptest: > +# We ceate an BASERGB file for our usage using "magick" > +# We convert this RGB file to BASEPNG > +# Using BASEPNG we recreate RGB named REGENERATEDRGB > +# > +# BASERGB to BASEPNG to REGENERATEDRGB > +# - Then compare BASERGB with REGENERATEDRGB > +# > +# 0) The convert command is deprecated in IMv7 > +# used "magick" instead of "convert" > +# 1) We are checking if the binaries are present in RFS or not > +# 2) We Created an RBG of size : WIDTH x HEIGHT pixels > +# 3) Return value is captured after every major actio to capture the status > +# 4) cmp -s is used to compare binary byte by byte data and > +# capture only exit status > +# 5) Important parametsrs used are : > +# -depth : How many bits for each colour pixel > +# -alpha off : Don't consider transparency > +# -define png:color-type=2 : Make PNG work with truecolour RGB > +# -strip : Remove all non-pixel metadata og PNG > +# so file is reproducible > +# -set gamma 1.0 : No PNG brightness correction > +# gradient:red-blue : Data moves liberly from RED to Blue vertically > + > + > +WIDTH=16 > +HEIGHT=16 > +BASERGB=base.rgb > +BASEPNG=base.png > +REGENERATEDRGB=roundtrip.rgb > + > +echo "[DEBUG] Starting ImageMagick Ptest with ${WIDTH}x${HEIGHT} pixels " > + > +# Verify required binaries > +for bin in magick cmp wc rm; do > + if [ -z "$(command -v "$bin" 2>/dev/null)" ]; then > + echo "[ERROR] Required binary '$bin' not found $PATH" > + exit 127 > + fi > +done > + > + > +# Generate raw RGB > +magick -size ${WIDTH}x${HEIGHT} gradient:red-blue \ > + -depth 8 -type TrueColor \ > + -alpha off -define png:color-type=2 \ > + -strip -set gamma 1.0 \ > + rgb:${BASERGB} > + > +returnvalue=$? > +if [ "$returnvalue" -ne 0 ]; then > + echo "[FAIL] Failed to generate RGB pattern " > + exit 1 > +else > + echo "[DEBUG] ${BASERGB} generated from gradient" > +fi > + > + > +# Convert raw RGB to PNG > +magick -depth 8 -size ${WIDTH}x${HEIGHT} rgb:${BASERGB} \ > + -type TrueColor -alpha off \ > + -define png:color-type=2 -strip -set gamma 1.0 \ > + ${BASEPNG} > + > +returnvalue=$? > +if [ $returnvalue -ne 0 ]; then > + echo "[FAIL] Failed to convert RGB to PNG" > + rm -f ${BASERGB} > + exit 1 > +else > + echo "[DEBUG] ${BASEPNG} generated from ${BASERGB}" > +fi > + > + > + > +# Regenerate raw RGB from PNG > +magick ${BASEPNG} \ > + -size ${WIDTH}x${HEIGHT} -depth 8 -type TrueColor \ > + -alpha off -define png:color-type=2 \ > + -strip -set gamma 1.0 \ > + rgb:${REGENERATEDRGB} > + > +returnvalue=$? > +if [ $returnvalue -ne 0 ]; then > + echo "[FAIL] Failed to regenerate RGB from PNG" > + rm -f ${BASERGB} ${BASEPNG} > + exit 1 > +else > + echo "[DEBUG] ${REGENERATEDRGB} generated from ${BASEPNG}" > +fi > + > + > + > +# Compare original and recreated RGB > +if cmp -s ${BASERGB} ${REGENERATEDRGB}; then > + echo "[PASS] RGB data identical after PNG round-trip" > + RESULT=0 > +else > + echo "[FAIL] RGB mismatch detected, printing their size " > + echo "[INFO] Base RGB size: $(wc -c < ${BASERGB}) bytes" > + echo "[INFO] Round-trip RGB size: $(wc -c < ${REGENERATEDRGB}) bytes" > + RESULT=1 > +fi > + > + > + > +# Checking the identify tool from imagemagick to get the PNG metadata > +# True is added in end to ensure that test script doesnt fail even if > +# identify fails for any reason > +echo "[DEBUG] PNG file info:" > +identify -verbose ${BASEPNG} | grep -E "Depth|Type|Colorspace" || true > + > + > + > +# Cleanup of files create by test code > +echo "[DEBUG] Cleaning up temporary files" > +rm -f ${BASERGB} ${BASEPNG} ${REGENERATEDRGB} > +returnvalue=$? > +echo "[DEBUG] Cleanup exit=$returnvalue" > + > + > +# Logging the final result > +if [ ${RESULT} -eq 0 ]; then > + echo "[DEBUG]: imagemagick-ptest.sh sucessfull " > +else > + echo "[DEBUG]: imagemagick-ptest.sh failed " > +fi > + > + > +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 @@ > +#!/bin/sh > +# > +# run-ptest — ImageMagick ptest harness > +# POSIX-safe and BusyBox compatible > + > +PTDIR=$(dirname "$0") > +TESTDIR="$PTDIR" > +PASSCOUNT=0 > +FAILCOUNT=0 > +TOTAL=0 > + > +echo "=======================================" > +echo "ImageMagick ptest: Runtime Validation" > +echo "=======================================" > + > +for t in "$TESTDIR"/*.sh; do > + [ -x "$t" ] || chmod +x "$t" > + TOTAL=$((TOTAL + 1)) > + echo > + echo "[DEBUG] Launching test script $t" > + > + if sh "$t" 2>&1; then > + echo "PASS: $(basename "$t")" > + PASSCOUNT=$((PASSCOUNT + 1)) > + else > + rc=$? > + if [ "$rc" -eq 77 ]; then > + echo "SKIP: $(basename "$t")" > + else > + echo "FAIL: $(basename "$t")" > + FAILCOUNT=$((FAILCOUNT + 1)) > + fi > + fi > + > +done > + > +echo > +echo "=======================================" > +echo "[SUMMARY] Total: $TOTAL | PASS: $PASSCOUNT | FAIL: $FAILCOUNT" > +echo "=======================================" > +echo > +[ "$FAILCOUNT" -eq 0 ] > + > diff --git a/meta-oe/recipes-support/imagemagick/imagemagick_7.1.2-5.bb b/meta-oe/recipes-support/imagemagick/imagemagick_7.1.2-5.bb > index 8ba14261ae..9da9d7df58 100644 > --- a/meta-oe/recipes-support/imagemagick/imagemagick_7.1.2-5.bb > +++ b/meta-oe/recipes-support/imagemagick/imagemagick_7.1.2-5.bb > @@ -12,11 +12,14 @@ DEPENDS = "lcms bzip2 jpeg libpng tiff zlib fftw freetype libtool" > BASE_PV = "${@d.getVar('PV').split('-')[0]}" > UPSTREAM_CHECK_GITTAGREGEX = "(?P<pver>([0-9][\.|_|-]?)+)" > > -SRC_URI = "git://github.com/ImageMagick/ImageMagick.git;branch=main;protocol=https;tag=${PV}" > +SRC_URI = "git://github.com/ImageMagick/ImageMagick.git;branch=main;protocol=https;tag=${PV} \ > + file://run-ptest \ > + file://imagemagick-ptest.sh \ > +" > SRCREV = "4a620c2a89a7481e83cb4a0ff32db0ccbb3afcd2" > > > -inherit autotools pkgconfig update-alternatives > +inherit autotools pkgconfig update-alternatives ptest > export ac_cv_sys_file_offset_bits = "64" > > EXTRA_OECONF = "--program-prefix= --program-suffix=.im7 --without-perl --enable-largefile" > @@ -55,6 +58,12 @@ do_install:append:class-target() { > fi > } > > +do_install_ptest() { > + install -d ${D}${PTEST_PATH} > + install -m 0755 ${UNPACKDIR}/run-ptest ${D}${PTEST_PATH}/ > + install -m 0755 ${UNPACKDIR}/imagemagick-ptest.sh ${D}${PTEST_PATH}/ > +} > + > FILES:${PN} += "${libdir}/ImageMagick-${BASE_PV}/config-Q16* \ > ${datadir}/ImageMagick-7" > > > -=-=-=-=-=-=-=-=-=-=-=- > Links: You receive all messages sent to this group. > View/Reply Online (#121265): https://lists.openembedded.org/g/openembedded-devel/message/121265 > Mute This Topic: https://lists.openembedded.org/mt/116093375/6084445 > Group Owner: openembedded-devel+owner@lists.openembedded.org > Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [skandigraun@gmail.com] > -=-=-=-=-=-=-=-=-=-=-=- >
On Wed, Nov 5, 2025 at 2:33 AM Gyorgy Sarvari via lists.openembedded.org <skandigraun=gmail.com@lists.openembedded.org> wrote: > Khem, > > Did this patch fell through the cracks accidentally, or do you think it > needs some corrections first? > > Thanks for bumping this up, I was dealing with another patch doing the upgrade for this recipe and wanted to serialize them but did not reply back. Please rebase it on the latest master/master-next and I will queue it up. > On 11/3/25 06:19, AshishKumar Mishra via lists.openembedded.org wrote: > > 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. > > --- > > .../include/ptest-packagelists-meta-oe.inc | 1 + > > .../imagemagick/imagemagick-ptest.sh | 132 ++++++++++++++++++ > > .../imagemagick/imagemagick/run-ptest | 43 ++++++ > > .../imagemagick/imagemagick_7.1.2-5.bb | 13 +- > > 4 files changed, 187 insertions(+), 2 deletions(-) > > create mode 100755 > meta-oe/recipes-support/imagemagick/imagemagick/imagemagick-ptest.sh > > create mode 100644 > meta-oe/recipes-support/imagemagick/imagemagick/run-ptest > > > > diff --git a/meta-oe/conf/include/ptest-packagelists-meta-oe.inc > b/meta-oe/conf/include/ptest-packagelists-meta-oe.inc > > index 825747d522..bd6db35c5b 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 = "\ > > function2 \ > > fwupd \ > > gcab \ > > + imagemagick \ > > jemalloc \ > > jq \ > > 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 @@ > > +#!/bin/sh > > +# > > +# ImageMagick ptest: > > +# We ceate an BASERGB file for our usage using "magick" > > +# We convert this RGB file to BASEPNG > > +# Using BASEPNG we recreate RGB named REGENERATEDRGB > > +# > > +# BASERGB to BASEPNG to REGENERATEDRGB > > +# - Then compare BASERGB with REGENERATEDRGB > > +# > > +# 0) The convert command is deprecated in IMv7 > > +# used "magick" instead of "convert" > > +# 1) We are checking if the binaries are present in RFS or not > > +# 2) We Created an RBG of size : WIDTH x HEIGHT pixels > > +# 3) Return value is captured after every major actio to capture the > status > > +# 4) cmp -s is used to compare binary byte by byte data and > > +# capture only exit status > > +# 5) Important parametsrs used are : > > +# -depth : How many bits for each colour pixel > > +# -alpha off : Don't consider transparency > > +# -define png:color-type=2 : Make PNG work with truecolour RGB > > +# -strip : Remove all non-pixel metadata og PNG > > +# so file is reproducible > > +# -set gamma 1.0 : No PNG brightness correction > > +# gradient:red-blue : Data moves liberly from RED to Blue > vertically > > + > > + > > +WIDTH=16 > > +HEIGHT=16 > > +BASERGB=base.rgb > > +BASEPNG=base.png > > +REGENERATEDRGB=roundtrip.rgb > > + > > +echo "[DEBUG] Starting ImageMagick Ptest with ${WIDTH}x${HEIGHT} pixels > " > > + > > +# Verify required binaries > > +for bin in magick cmp wc rm; do > > + if [ -z "$(command -v "$bin" 2>/dev/null)" ]; then > > + echo "[ERROR] Required binary '$bin' not found $PATH" > > + exit 127 > > + fi > > +done > > + > > + > > +# Generate raw RGB > > +magick -size ${WIDTH}x${HEIGHT} gradient:red-blue \ > > + -depth 8 -type TrueColor \ > > + -alpha off -define png:color-type=2 \ > > + -strip -set gamma 1.0 \ > > + rgb:${BASERGB} > > + > > +returnvalue=$? > > +if [ "$returnvalue" -ne 0 ]; then > > + echo "[FAIL] Failed to generate RGB pattern " > > + exit 1 > > +else > > + echo "[DEBUG] ${BASERGB} generated from gradient" > > +fi > > + > > + > > +# Convert raw RGB to PNG > > +magick -depth 8 -size ${WIDTH}x${HEIGHT} rgb:${BASERGB} \ > > + -type TrueColor -alpha off \ > > + -define png:color-type=2 -strip -set gamma 1.0 \ > > + ${BASEPNG} > > + > > +returnvalue=$? > > +if [ $returnvalue -ne 0 ]; then > > + echo "[FAIL] Failed to convert RGB to PNG" > > + rm -f ${BASERGB} > > + exit 1 > > +else > > + echo "[DEBUG] ${BASEPNG} generated from ${BASERGB}" > > +fi > > + > > + > > + > > +# Regenerate raw RGB from PNG > > +magick ${BASEPNG} \ > > + -size ${WIDTH}x${HEIGHT} -depth 8 -type TrueColor \ > > + -alpha off -define png:color-type=2 \ > > + -strip -set gamma 1.0 \ > > + rgb:${REGENERATEDRGB} > > + > > +returnvalue=$? > > +if [ $returnvalue -ne 0 ]; then > > + echo "[FAIL] Failed to regenerate RGB from PNG" > > + rm -f ${BASERGB} ${BASEPNG} > > + exit 1 > > +else > > + echo "[DEBUG] ${REGENERATEDRGB} generated from ${BASEPNG}" > > +fi > > + > > + > > + > > +# Compare original and recreated RGB > > +if cmp -s ${BASERGB} ${REGENERATEDRGB}; then > > + echo "[PASS] RGB data identical after PNG round-trip" > > + RESULT=0 > > +else > > + echo "[FAIL] RGB mismatch detected, printing their size " > > + echo "[INFO] Base RGB size: $(wc -c < ${BASERGB}) bytes" > > + echo "[INFO] Round-trip RGB size: $(wc -c < ${REGENERATEDRGB}) > bytes" > > + RESULT=1 > > +fi > > + > > + > > + > > +# Checking the identify tool from imagemagick to get the PNG metadata > > +# True is added in end to ensure that test script doesnt fail even if > > +# identify fails for any reason > > +echo "[DEBUG] PNG file info:" > > +identify -verbose ${BASEPNG} | grep -E "Depth|Type|Colorspace" || true > > + > > + > > + > > +# Cleanup of files create by test code > > +echo "[DEBUG] Cleaning up temporary files" > > +rm -f ${BASERGB} ${BASEPNG} ${REGENERATEDRGB} > > +returnvalue=$? > > +echo "[DEBUG] Cleanup exit=$returnvalue" > > + > > + > > +# Logging the final result > > +if [ ${RESULT} -eq 0 ]; then > > + echo "[DEBUG]: imagemagick-ptest.sh sucessfull " > > +else > > + echo "[DEBUG]: imagemagick-ptest.sh failed " > > +fi > > + > > + > > +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 @@ > > +#!/bin/sh > > +# > > +# run-ptest — ImageMagick ptest harness > > +# POSIX-safe and BusyBox compatible > > + > > +PTDIR=$(dirname "$0") > > +TESTDIR="$PTDIR" > > +PASSCOUNT=0 > > +FAILCOUNT=0 > > +TOTAL=0 > > + > > +echo "=======================================" > > +echo "ImageMagick ptest: Runtime Validation" > > +echo "=======================================" > > + > > +for t in "$TESTDIR"/*.sh; do > > + [ -x "$t" ] || chmod +x "$t" > > + TOTAL=$((TOTAL + 1)) > > + echo > > + echo "[DEBUG] Launching test script $t" > > + > > + if sh "$t" 2>&1; then > > + echo "PASS: $(basename "$t")" > > + PASSCOUNT=$((PASSCOUNT + 1)) > > + else > > + rc=$? > > + if [ "$rc" -eq 77 ]; then > > + echo "SKIP: $(basename "$t")" > > + else > > + echo "FAIL: $(basename "$t")" > > + FAILCOUNT=$((FAILCOUNT + 1)) > > + fi > > + fi > > + > > +done > > + > > +echo > > +echo "=======================================" > > +echo "[SUMMARY] Total: $TOTAL | PASS: $PASSCOUNT | FAIL: $FAILCOUNT" > > +echo "=======================================" > > +echo > > +[ "$FAILCOUNT" -eq 0 ] > > + > > diff --git a/meta-oe/recipes-support/imagemagick/imagemagick_7.1.2-5.bb > b/meta-oe/recipes-support/imagemagick/imagemagick_7.1.2-5.bb > > index 8ba14261ae..9da9d7df58 100644 > > --- a/meta-oe/recipes-support/imagemagick/imagemagick_7.1.2-5.bb > > +++ b/meta-oe/recipes-support/imagemagick/imagemagick_7.1.2-5.bb > > @@ -12,11 +12,14 @@ DEPENDS = "lcms bzip2 jpeg libpng tiff zlib fftw > freetype libtool" > > BASE_PV = "${@d.getVar('PV').split('-')[0]}" > > UPSTREAM_CHECK_GITTAGREGEX = "(?P<pver>([0-9][\.|_|-]?)+)" > > > > -SRC_URI = "git:// > github.com/ImageMagick/ImageMagick.git;branch=main;protocol=https;tag=${PV} > <http://github.com/ImageMagick/ImageMagick.git;branch=main;protocol=https;tag=$%7BPV%7D> > " > > +SRC_URI = "git:// > github.com/ImageMagick/ImageMagick.git;branch=main;protocol=https;tag=${PV} > <http://github.com/ImageMagick/ImageMagick.git;branch=main;protocol=https;tag=$%7BPV%7D> > \ > > + file://run-ptest \ > > + file://imagemagick-ptest.sh \ > > +" > > SRCREV = "4a620c2a89a7481e83cb4a0ff32db0ccbb3afcd2" > > > > > > -inherit autotools pkgconfig update-alternatives > > +inherit autotools pkgconfig update-alternatives ptest > > export ac_cv_sys_file_offset_bits = "64" > > > > EXTRA_OECONF = "--program-prefix= --program-suffix=.im7 --without-perl > --enable-largefile" > > @@ -55,6 +58,12 @@ do_install:append:class-target() { > > fi > > } > > > > +do_install_ptest() { > > + install -d ${D}${PTEST_PATH} > > + install -m 0755 ${UNPACKDIR}/run-ptest ${D}${PTEST_PATH}/ > > + install -m 0755 ${UNPACKDIR}/imagemagick-ptest.sh ${D}${PTEST_PATH}/ > > +} > > + > > FILES:${PN} += "${libdir}/ImageMagick-${BASE_PV}/config-Q16* \ > > ${datadir}/ImageMagick-7" > > > > > > > > > > > -=-=-=-=-=-=-=-=-=-=-=- > Links: You receive all messages sent to this group. > View/Reply Online (#121325): > https://lists.openembedded.org/g/openembedded-devel/message/121325 > Mute This Topic: https://lists.openembedded.org/mt/116093375/1997914 > Group Owner: openembedded-devel+owner@lists.openembedded.org > Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [ > raj.khem@gmail.com] > -=-=-=-=-=-=-=-=-=-=-=- > >
Dear Khem Raj / Gyorgy Sarvari , Have shared the rebased patch @ https://lists.openembedded.org/g/openembedded-devel/topic/meta_oe_master_patch_v2/116149980 ( https://lists.openembedded.org/g/openembedded-devel/topic/meta_oe_master_patch_v2/116149980 ) Request to please consider this for merge. Thanks , Ashish
diff --git a/meta-oe/conf/include/ptest-packagelists-meta-oe.inc b/meta-oe/conf/include/ptest-packagelists-meta-oe.inc index 825747d522..bd6db35c5b 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 = "\ function2 \ fwupd \ gcab \ + imagemagick \ jemalloc \ jq \ 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 @@ +#!/bin/sh +# +# ImageMagick ptest: +# We ceate an BASERGB file for our usage using "magick" +# We convert this RGB file to BASEPNG +# Using BASEPNG we recreate RGB named REGENERATEDRGB +# +# BASERGB to BASEPNG to REGENERATEDRGB +# - Then compare BASERGB with REGENERATEDRGB +# +# 0) The convert command is deprecated in IMv7 +# used "magick" instead of "convert" +# 1) We are checking if the binaries are present in RFS or not +# 2) We Created an RBG of size : WIDTH x HEIGHT pixels +# 3) Return value is captured after every major actio to capture the status +# 4) cmp -s is used to compare binary byte by byte data and +# capture only exit status +# 5) Important parametsrs used are : +# -depth : How many bits for each colour pixel +# -alpha off : Don't consider transparency +# -define png:color-type=2 : Make PNG work with truecolour RGB +# -strip : Remove all non-pixel metadata og PNG +# so file is reproducible +# -set gamma 1.0 : No PNG brightness correction +# gradient:red-blue : Data moves liberly from RED to Blue vertically + + +WIDTH=16 +HEIGHT=16 +BASERGB=base.rgb +BASEPNG=base.png +REGENERATEDRGB=roundtrip.rgb + +echo "[DEBUG] Starting ImageMagick Ptest with ${WIDTH}x${HEIGHT} pixels " + +# Verify required binaries +for bin in magick cmp wc rm; do + if [ -z "$(command -v "$bin" 2>/dev/null)" ]; then + echo "[ERROR] Required binary '$bin' not found $PATH" + exit 127 + fi +done + + +# Generate raw RGB +magick -size ${WIDTH}x${HEIGHT} gradient:red-blue \ + -depth 8 -type TrueColor \ + -alpha off -define png:color-type=2 \ + -strip -set gamma 1.0 \ + rgb:${BASERGB} + +returnvalue=$? +if [ "$returnvalue" -ne 0 ]; then + echo "[FAIL] Failed to generate RGB pattern " + exit 1 +else + echo "[DEBUG] ${BASERGB} generated from gradient" +fi + + +# Convert raw RGB to PNG +magick -depth 8 -size ${WIDTH}x${HEIGHT} rgb:${BASERGB} \ + -type TrueColor -alpha off \ + -define png:color-type=2 -strip -set gamma 1.0 \ + ${BASEPNG} + +returnvalue=$? +if [ $returnvalue -ne 0 ]; then + echo "[FAIL] Failed to convert RGB to PNG" + rm -f ${BASERGB} + exit 1 +else + echo "[DEBUG] ${BASEPNG} generated from ${BASERGB}" +fi + + + +# Regenerate raw RGB from PNG +magick ${BASEPNG} \ + -size ${WIDTH}x${HEIGHT} -depth 8 -type TrueColor \ + -alpha off -define png:color-type=2 \ + -strip -set gamma 1.0 \ + rgb:${REGENERATEDRGB} + +returnvalue=$? +if [ $returnvalue -ne 0 ]; then + echo "[FAIL] Failed to regenerate RGB from PNG" + rm -f ${BASERGB} ${BASEPNG} + exit 1 +else + echo "[DEBUG] ${REGENERATEDRGB} generated from ${BASEPNG}" +fi + + + +# Compare original and recreated RGB +if cmp -s ${BASERGB} ${REGENERATEDRGB}; then + echo "[PASS] RGB data identical after PNG round-trip" + RESULT=0 +else + echo "[FAIL] RGB mismatch detected, printing their size " + echo "[INFO] Base RGB size: $(wc -c < ${BASERGB}) bytes" + echo "[INFO] Round-trip RGB size: $(wc -c < ${REGENERATEDRGB}) bytes" + RESULT=1 +fi + + + +# Checking the identify tool from imagemagick to get the PNG metadata +# True is added in end to ensure that test script doesnt fail even if +# identify fails for any reason +echo "[DEBUG] PNG file info:" +identify -verbose ${BASEPNG} | grep -E "Depth|Type|Colorspace" || true + + + +# Cleanup of files create by test code +echo "[DEBUG] Cleaning up temporary files" +rm -f ${BASERGB} ${BASEPNG} ${REGENERATEDRGB} +returnvalue=$? +echo "[DEBUG] Cleanup exit=$returnvalue" + + +# Logging the final result +if [ ${RESULT} -eq 0 ]; then + echo "[DEBUG]: imagemagick-ptest.sh sucessfull " +else + echo "[DEBUG]: imagemagick-ptest.sh failed " +fi + + +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 @@ +#!/bin/sh +# +# run-ptest — ImageMagick ptest harness +# POSIX-safe and BusyBox compatible + +PTDIR=$(dirname "$0") +TESTDIR="$PTDIR" +PASSCOUNT=0 +FAILCOUNT=0 +TOTAL=0 + +echo "=======================================" +echo "ImageMagick ptest: Runtime Validation" +echo "=======================================" + +for t in "$TESTDIR"/*.sh; do + [ -x "$t" ] || chmod +x "$t" + TOTAL=$((TOTAL + 1)) + echo + echo "[DEBUG] Launching test script $t" + + if sh "$t" 2>&1; then + echo "PASS: $(basename "$t")" + PASSCOUNT=$((PASSCOUNT + 1)) + else + rc=$? + if [ "$rc" -eq 77 ]; then + echo "SKIP: $(basename "$t")" + else + echo "FAIL: $(basename "$t")" + FAILCOUNT=$((FAILCOUNT + 1)) + fi + fi + +done + +echo +echo "=======================================" +echo "[SUMMARY] Total: $TOTAL | PASS: $PASSCOUNT | FAIL: $FAILCOUNT" +echo "=======================================" +echo +[ "$FAILCOUNT" -eq 0 ] + diff --git a/meta-oe/recipes-support/imagemagick/imagemagick_7.1.2-5.bb b/meta-oe/recipes-support/imagemagick/imagemagick_7.1.2-5.bb index 8ba14261ae..9da9d7df58 100644 --- a/meta-oe/recipes-support/imagemagick/imagemagick_7.1.2-5.bb +++ b/meta-oe/recipes-support/imagemagick/imagemagick_7.1.2-5.bb @@ -12,11 +12,14 @@ DEPENDS = "lcms bzip2 jpeg libpng tiff zlib fftw freetype libtool" BASE_PV = "${@d.getVar('PV').split('-')[0]}" UPSTREAM_CHECK_GITTAGREGEX = "(?P<pver>([0-9][\.|_|-]?)+)" -SRC_URI = "git://github.com/ImageMagick/ImageMagick.git;branch=main;protocol=https;tag=${PV}" +SRC_URI = "git://github.com/ImageMagick/ImageMagick.git;branch=main;protocol=https;tag=${PV} \ + file://run-ptest \ + file://imagemagick-ptest.sh \ +" SRCREV = "4a620c2a89a7481e83cb4a0ff32db0ccbb3afcd2" -inherit autotools pkgconfig update-alternatives +inherit autotools pkgconfig update-alternatives ptest export ac_cv_sys_file_offset_bits = "64" EXTRA_OECONF = "--program-prefix= --program-suffix=.im7 --without-perl --enable-largefile" @@ -55,6 +58,12 @@ do_install:append:class-target() { fi } +do_install_ptest() { + install -d ${D}${PTEST_PATH} + install -m 0755 ${UNPACKDIR}/run-ptest ${D}${PTEST_PATH}/ + install -m 0755 ${UNPACKDIR}/imagemagick-ptest.sh ${D}${PTEST_PATH}/ +} + FILES:${PN} += "${libdir}/ImageMagick-${BASE_PV}/config-Q16* \ ${datadir}/ImageMagick-7"