[cairo] [PATCH v2 3/7] test: Use cmp to catch byte-by-byte identical files

Bryce W. Harrington b.harrington at samsung.com
Wed Jul 3 15:35:08 PDT 2013


cmp runs faster than perceptualdiff, and catches files that are exact
copies of the reference image.  We still use perceptualdiff for catching
files that aren't bytewise identical, but are still identical at the
pixel level.

Signed-off-by: Bryce Harrington <b.harrington at samsung.com>
---
 test/check_refs.sh |   20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/test/check_refs.sh b/test/check_refs.sh
index 649d509..a9dfe17 100755
--- a/test/check_refs.sh
+++ b/test/check_refs.sh
@@ -47,14 +47,18 @@ for file in *.ref.png; do
     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
+	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
-- 
1.7.9.5

--
Bryce Harrington
Senior Open Source Developer  -  b.harrington at samsung.com
Open Source Group             -  Samsung Research America


More information about the cairo mailing list