summaryrefslogtreecommitdiff
path: root/test/check-refs.sh
diff options
context:
space:
mode:
authorBryce W. Harrington <b.harrington@samsung.com>2013-07-03 22:33:57 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2013-07-04 09:04:05 +0100
commitb0be0d8d42b5b6ba80e59a869a8f72fd8556e91e (patch)
tree897f0583eeaed84a3a6ecd725ccf93370c06e6d2 /test/check-refs.sh
parent7f1be42e85589ee07dacead012234c1a1eb1b395 (diff)
downloadcairo-b0be0d8d42b5b6ba80e59a869a8f72fd8556e91e.tar.gz
test: Add script to check for redundant reference images
This script requires the perceptualdiff program, which can be built as follows: cd test/pdiff && make perceptualdiff The script's output provides a list of target-specific or format-specific images that are identical to their more generic reference files, and thus are redundant and can be safely removed from the archive without altering any test behaviors. Signed-off-by: Bryce Harrington <b.harrington@samsung.com> [ickle: applied Behdad's suggestion of renaming the script check-refs.sh]
Diffstat (limited to 'test/check-refs.sh')
-rwxr-xr-xtest/check-refs.sh60
1 files changed, 60 insertions, 0 deletions
diff --git a/test/check-refs.sh b/test/check-refs.sh
new file mode 100755
index 000000000..b8960b4e9
--- /dev/null
+++ b/test/check-refs.sh
@@ -0,0 +1,60 @@
+#!/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
+
+ if [ -e $ref ]; then
+ # 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 is binary identical to %s\n" $file $ref
+ notes=""
+ fi
+ fi
+
+done