xref: /potrace-1.14/check/binary-check.sh (revision b3fce824)
1#! /bin/sh
2
3# Copyright (C) 2001-2017 Peter Selinger.
4# This file is part of Potrace. It is free software and it is covered
5# by the GNU General Public License. See the file COPYING for details.
6
7echo "Checking binary output..." >& 2
8
9# On Windows, there are various workarounds for making sure that
10# stdout is in binary mode, depending on the build system used. This
11# check ensures that the output of potrace and mkbitmap is indeed
12# binary, with no line-end conversion.
13
14if test -z "$srcdir"; then
15    srcdir=.
16fi
17
18. "$srcdir/missing.sh"
19
20NAME=`basename "$0"`
21
22MKBITMAP="${CHECK_MKBITMAP:-../src/mkbitmap$EXEEXT}"
23POTRACE="${CHECK_POTRACE:-../src/potrace$EXEEXT}"
24DATADIR="$srcdir/data"
25CHECKBIN="./checkbin$EXEEXT"
26TMPDIR="${TEMPDIR:-/tmp}"
27TMP1=`mktemp "$TMPDIR/$NAME-1.XXXXXX"`
28DATA1="$DATADIR/data1.ppm"
29DATA2="$DATADIR/data2.ppm"
30
31action () {
32    "$@"
33    if test $? -ne 0; then
34	echo "$NAME: test failed" >& 2
35	echo "Failed command: $LINE: $@" >& 2
36	exit 1
37    fi
38}
39
40# keep track of line numbers
41alias action="LINE=\$LINENO; action"
42
43action $POTRACE -g "$DATA1" -o "$TMP1"
44action $CHECKBIN "$TMP1"
45
46action $POTRACE -g < "$DATA1" > "$TMP1"
47action $CHECKBIN "$TMP1"
48
49action $MKBITMAP -f2 -s2 -t.48 "$DATA2" -o "$TMP1"
50action $CHECKBIN "$TMP1"
51
52action $MKBITMAP -f2 -s2 -t.48 < "$DATA2" > "$TMP1"
53action $CHECKBIN "$TMP1"
54
55
56action rm -f "$TMP1"
57
58echo "$NAME: test succeeded" >& 2
59exit 0
60