Re: [PATCH v2 2/7] test: Add script to check for redundant reference images

Behdad Esfahbod <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <[email protected]>
Nit: Please use dashes not underscores in file names.

On 13-07-03 04:33 PM, Bryce W. Harrington wrote:
> 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/Makefile.am   |    1 +
>  test/check_refs.sh |   60 ++++++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 61 insertions(+)
>  create mode 100755 test/check_refs.sh
> 
> diff --git a/test/Makefile.am b/test/Makefile.am
> index d5c726a..a097409 100644
> --- a/test/Makefile.am
> +++ b/test/Makefile.am
> @@ -72,6 +72,7 @@ endif
>  test_sources += $(test)
>  
>  noinst_PROGRAMS = cairo-test-suite$(EXEEXT) # always build
> +noinst_SCRIPTS += check_refs.sh
>  
>  TESTS += cairo-test-suite$(EXEEXT)
>  
> 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
> 

-- 
behdad
http://behdad.org/
-- 
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.