[PATCH 2/7] test: Add script to check for redundant reference images
"Bryce W. Harrington" <[email protected]>
| Newsgroups | gmane.comp.lib.cairo |
|---|---|
| Message-ID | <5A5FB412583EA944A1D0228D52A9C57263A3E7@sisaex02sj> |
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 <[email protected]> --- test/check_refs.sh | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100755 test/check_refs.sh diff --git a/test/check_refs.sh b/test/check_refs.sh new file mode 100755 index 0000000..649d509 --- /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 -- 1.7.9.5 -- Bryce Harrington Senior Open Source Developer - [email protected] Open Source Group - Samsung Research America -- cairo mailing list [email protected] http://lists.cairographics.org/mailman/listinfo/cairo