1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
#! /bin/sh
# Copyright (C) 2001-2019 Peter Selinger.
# This file is part of Potrace. It is free software and it is covered
# by the GNU General Public License. See the file COPYING for details.
echo "Checking mkbitmap..." >& 2
# because of floating point inaccuracies, we cannot check that the
# output is identical to its reference; instead, we compare pixmaps
# and allow for small differences.
if test -z "$srcdir"; then
srcdir=.
fi
. "$srcdir/missing.sh"
NAME=`basename "$0"`
MKBITMAP="${CHECK_MKBITMAP:-../src/mkbitmap$EXEEXT}"
DATADIR="$srcdir/data"
PGMDIFF="./pgmdiff$EXEEXT"
TMPDIR="${TEMPDIR:-/tmp}"
TMP1=`mktemp "$TMPDIR/$NAME-1.XXXXXX"`
DATA="$DATADIR/data2.ppm"
REFDATA1="$DATADIR/data2-out1.pbm"
REFDATA2="$DATADIR/data2-out2.pbm"
action () {
"$@"
if test $? -ne 0; then
echo "$NAME: test failed" >& 2
echo "Failed command: $LINE: $@" >& 2
exit 1
fi
}
actiondiff () {
D=`action "$PGMDIFF" "$1" "$2"`
# check return value because subshell can't exit
if test $? -ne 0; then
exit 1;
fi
echo "Difference: $D" >& 2
if test "$D" -gt "$3"; then
echo "$NAME: test failed" >& 2
echo "Failed command: $LINE: $PGMDIFF $1 $2" >& 2
exit 1;
fi
}
# keep track of line numbers
alias action="LINE=\$LINENO; action"
alias actiondiff="LINE=\$LINENO; actiondiff"
action $MKBITMAP -f2 -s2 -t.48 -o "$TMP1" "$DATA"
actiondiff "$TMP1" "$REFDATA1" 50
action $MKBITMAP -f1 -s2 -t.54 -1 -i -o "$TMP1" "$DATA"
actiondiff "$TMP1" "$REFDATA2" 50
action rm -f "$TMP1"
echo "$NAME: test succeeded" >& 2
exit 0
|