@@ -63,6 +63,23 @@ function call()
6363 fi
6464}
6565
66+ function get-diff()
67+ {
68+ local -n _ABSERR=$1
69+ local -n _NBPIX=$2
70+ local FROM=$3
71+ local TO=$4
72+ local DIFF=$5
73+
74+ local RES=( $( $COMPARE $FROM $TO -metric ae $DIFF 2>&1 ) )
75+
76+ _ABSERR=${RES[0]}
77+ _NBPIX=${RES[1]// (/ }
78+ _NBPIX=${_NBPIX// )/ }
79+
80+ [[ ${_NBPIX} -eq 0 ]] && return 0 || return 1
81+ }
82+
6683[[ -z $( command -v $CLI ) ]] && echo Make sure $CLI is in the path && exit 1
6784
6885set -- $( getopt -q -u -o : -l gdb,gdb-cl,disable-opencl,no-deltae,fast-fail,op:,operation: -- $* )
@@ -232,10 +249,10 @@ for dir in $TESTS; do
232249
233250 if [[ $res -eq 0 ]]; then
234251 if [[ -n " $COMPARE " ]] && [[ $DO_OPENCL == yes ]]; then
235- diffcount= " $( $COMPARE output.png output-cl.png -metric ae diff-cl.png 2>&1 ) "
252+ get-diff ABSERR DIFFPIX output.png output-cl.png diff-cl.png
236253
237254 if [[ $? -ne 0 ]]; then
238- e " CPU & GPU version differ by ${diffcount } pixels"
255+ e " CPU & GPU version differ by ${DIFFPIX } pixels"
239256 if [[ $DO_DELTAE == yes ]]; then
240257 e " CPU vs. GPU report :"
241258 ../deltae output.png output-cl.png | tee -a $LOG
@@ -258,37 +275,37 @@ for dir in $TESTS; do
258275 if [[ $res -lt 2 ]]; then
259276 e " OK"
260277 if [[ $res = 1 ]]; then
261- diffcount= " $( $COMPARE expected.png output.png -metric ae diff-ok.png 2>&1 ) "
278+ get-diff ABSERR DIFFPIX expected.png output.png diff-ok.png
262279 fi
263280 res=0
264281
265282 else
266283 e " FAILS: image visually changed"
267284 if [[ ! -z $COMPARE ]] && [[ -f expected.png ]]; then
268- diffcount= " $( $COMPARE expected.png output.png -metric ae diff.png 2>&1 ) "
285+ get-diff ABSERR DIFFPIX expected.png output.png diff.png
269286 e " see diff.png for visual difference"
270- e " (${diffcount } pixels changed)"
287+ e " (${DIFFPIX } pixels changed)"
271288 fi
272289 fi
273290 else
274291 if [[ -z $COMPARE ]]; then
275292 e " no delta-e mode : required compare tool not found."
276293 res=1
277294 else
278- diffcount= " $( $COMPARE expected.png output.png -metric ae diff-ok.png 2>&1 ) "
295+ get-diff ABSERR DIFFPIX expected.png output.png diff-ok.png
279296
280297 # if we have an exponent just pretend this is a number
281- # above 2000 which is the limit checked below.
298+ # above 5000 which is the limit checked below.
282299
283- if [[ $diffcount =~ e ]]; then
284- diffcount =50000
300+ if [[ $DIFFPIX =~ e ]]; then
301+ DIFFPIX =50000
285302 fi
286303
287- if [[ $diffcount -lt 2000 ]]; then
304+ if [[ $DIFFPIX -lt 5000 ]]; then
288305 e " Light check : OK"
289306 res=0
290307 else
291- e " Light check : NOK"
308+ e " Light check : NOK ( $DIFFPIX ) "
292309 res=1
293310 fi
294311 fi
0 commit comments