cairo/test/check-refs.sh
Bryce W. Harrington 33895904d5 test: Add special cases for create-from-png and fallback-resolution
These tests use reference images somewhat differently from other tests,
so treat them as special cases and avoid recommending deleting any of
their files.

Add TODO's to each test to rework them to be more consistent with other
tests.

Signed-off-by: Bryce Harrington <b.harrington@samsung.com>
2013-07-04 09:27:56 +01:00

74 lines
2.1 KiB
Bash
Executable file

#!/bin/bash
current_dir=$(pwd)
# Move to the reference directory as needed
if [ $(basename $current_dir) != 'test' ]; then
if [ -d test ]; then
cd test || exit 1
fi
fi
if [ $(basename $current_dir) != 'reference' ]; then
if [ -d reference ]; then
cd reference || exit 2
fi
fi
pdiff=../pdiff/perceptualdiff
if [ ! -e "${pdiff}" ]; then
echo "Error: requires ${pdiff} executable"
exit 3
fi
for file in *.ref.png; do
test=$(echo $file | cut -d'.' -f1)
target=$(echo $file | cut -d'.' -f2)
format=$(echo $file | cut -d'.' -f3)
notes=""
ref=""
result=""
if [ $target = 'base' ]; then
# Ignore the base images for this script's purposes
continue
elif [ $target = 'ref' ]; then
# This is actually the baseline reference image
continue
elif [ $format = 'ref' ]; then
# This is either a format-specific reference, or a target-specific/format-generic image
# In either case, compare it against the generic reference image
ref="$test.ref.png"
else
# Prefer the target-specific/format-generic reference image, if available
ref="$test.$target.ref.png"
if [ ! -e $ref ]; then
ref="$test.$format.ref.png"
fi
fi
# Special cases
if [ $test = "create-from-png" ]; then
# The create-from-png test utilizes multiple reference images directly
continue
elif [ $test = "fallback-resolution" ]; then
# The fallback-resolution test generates a set of reference images;
# These won't be redundant with one another, but just ignore them all.
continue
fi
if [ -e $ref ]; then
if cmp --silent "$ref" "$file" ; then
printf "redundant: %s and %s are byte-by-byte identical files\n" $file $ref
else
# Run perceptualdiff with minimum threshold
pdiff_output=$($pdiff $ref $file -threshold 1)
result=${pdiff_output%:*}
notes=$(echo "${pdiff_output#*: }" | tail -n 1)
if [ "$result" = "PASS" ] && [ "$notes" = "Images are binary identical" ]; then
printf "redundant: %s and %s are pixel equivalent images\n" $file $ref
notes=""
fi
fi
fi
done