win32-vd_agent/test-png
Frediano Ziglio 9c573c9754 Execute tests for MSYS2 build
Avoid to run executables using Wine if system is not Linux.
Use relative paths for executables as bash otherwise won't find them.
Make build.sh script fail on intermediate errors.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2025-03-04 11:07:31 +00:00

75 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
VERBOSE=${VERBOSE:-0}
IN=in.png
OUT=out.png
OUT_BMP=out.bmp
error() {
echo "$*" >&2
exit 1
}
verbose() {
if [ $VERBOSE != 0 ]; then
"$@"
fi
}
# under Windows we don't need to run test under Wine
WINE=wine
MAGICK=
if [ "x`uname -s`" != xLinux ]; then
WINE=
if command -V magick.exe &> /dev/null; then
MAGICK=magick.exe
fi
fi
# MSVC build put executables under <Configuration> directory
IMAGETEST=./imagetest.exe
if [ -e ./Release/imagetest.exe ]; then
IMAGETEST=./Release/imagetest.exe
fi
compare_images() {
DIFF=$($MAGICK compare -metric AE $1 $2 - 2>&1 > /dev/null || true)
if [ "$DIFF" != "0 (0)" -a "$DIFF" != "0" ]; then
error "Images $1 and $2 are too different, diff $DIFF"
fi
}
do_test() {
echo "Running image $IMAGE with '$*'..."
$MAGICK convert $IMAGE "$@" $IN
$WINE $IMAGETEST $IN $OUT_BMP $OUT
verbose ls -lh $IN
verbose $MAGICK identify $IN
verbose $MAGICK identify $OUT_BMP
compare_images $IN $OUT
compare_images $IN $OUT_BMP
rm -f $IN $OUT $OUT_BMP
}
do_test_all() {
IMAGE="$1"
do_test
do_test -type Palette
do_test -type Palette -colors 14
do_test -type Palette -colors 3
do_test -type TrueColor
do_test -type Grayscale -depth 8
do_test -type Grayscale -depth 2
do_test -type Grayscale -depth 4
}
set -e
# test with small image
do_test_all rose:
# test with larger image
do_test_all logo:
rm -f $IN $OUT $OUT_BMP
verbose echo Finish