File: input-check.sh

package info (click to toggle)
potrace 1.16-2
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 4,440 kB
  • sloc: ansic: 9,349; sh: 4,829; makefile: 76
file content (66 lines) | stat: -rwxr-xr-x 1,510 bytes parent folder | download
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 input formats..." >& 2

# we check that potrace can read different file formats without error,
# and produces identical output irrespective of the input file format.

if test -z "$srcdir"; then
    srcdir=.
fi

. "$srcdir/missing.sh"

NAME=`basename "$0"`

POTRACE="${CHECK_POTRACE:-../src/potrace$EXEEXT --progress}"
DATADIR="$srcdir/data"
TMPDIR="${TEMPDIR:-/tmp}"
TMP1=`mktemp "$TMPDIR/$NAME-1.XXXXXX"`
TMP2=`mktemp "$TMPDIR/$NAME-2.XXXXXX"`

action () {
    "$@"
    if test $? -ne 0; then
	echo "$NAME: test failed" >& 2
	echo "Failed command: $LINE: $@" >& 2
	exit 1
    fi
}

# keep track of line numbers
alias action="LINE=\$LINENO; action"

dofiles() {
    action $POTRACE -o "$TMP1" "$DATADIR/$1"
    shift

    for i in "$@"; do
	action $POTRACE -o "$TMP2" "$DATADIR/$i"
	action diff "$TMP1" "$TMP2" > /dev/null
	action rm -f "$TMP2"
    done
}

# available input files

INFILES="data1.pbm data1.pgm data1.ppm                     \
         data1.pbm.plain data1.pgm.plain data1.ppm.plain   \
         data1.bmp1 data1.bmp4 data1.bmp8 data1.bmp24      \
         data1.bmp32 data1.bmp4r data1.bmp8r data1.bmp24td \
         data1.bmp24v5 data1.bmp32bf"

dofiles $INFILES

INFILES="data2.ppm data2.bmp32bf"

dofiles $INFILES

action rm -f "$TMP1"

echo "$NAME: test succeeded" >& 2
exit 0