xref: /libtiff-4.0.7/test/common.sh (revision 0f2332ce)
1# Common code fragment for tests
2#
3srcdir=${srcdir:-.}
4BUILDDIR=`pwd`
5SRCDIR=`dirname $0`
6SRCDIR=`cd $SRCDIR && pwd`
7TOPSRCDIR=`cd $srcdir/.. && pwd`
8TOOLS=`cd ../tools && pwd`
9IMAGES="${SRCDIR}/images"
10
11# Aliases for built tools
12BMP2TIFF=${TOOLS}/bmp2tiff
13FAX2PS=${TOOLS}/fax2ps
14FAX2TIFF=${TOOLS}/fax2tiff
15GIF2TIFF=${TOOLS}/gif2tiff
16PAL2RGB=${TOOLS}/pal2rgb
17PPM2TIFF=${TOOLS}/ppm2tiff
18RAS2TIFF=${TOOLS}/ras2tiff
19RAW2TIFF=${TOOLS}/raw2tiff
20RGB2YCBCR=${TOOLS}/rgb2ycbcr
21THUMBNAIL=${TOOLS}/thumbnail
22TIFF2BW=${TOOLS}/tiff2bw
23TIFF2PDF=${TOOLS}/tiff2pdf
24TIFF2PS=${TOOLS}/tiff2ps
25TIFF2RGBA=${TOOLS}/tiff2rgba
26TIFFCMP=${TOOLS}/tiffcmp
27TIFFCP=${TOOLS}/tiffcp
28TIFFCROP=${TOOLS}/tiffcrop
29TIFFDITHER=${TOOLS}/tiffdither
30TIFFDUMP=${TOOLS}/tiffdump
31TIFFINFO=${TOOLS}/tiffinfo
32TIFFMEDIAN=${TOOLS}/tiffmedian
33TIFFSET=${TOOLS}/tiffset
34TIFFSPLIT=${TOOLS}/tiffsplit
35
36# Aliases for input test files
37IMG_MINISBLACK_1C_16B=${IMAGES}/minisblack-1c-16b.tiff
38IMG_MINISBLACK_1C_8B=${IMAGES}/minisblack-1c-8b.tiff
39IMG_MINISWHITE_1C_1B=${IMAGES}/miniswhite-1c-1b.tiff
40IMG_PALETTE_1C_1B=${IMAGES}/palette-1c-1b.tiff
41IMG_PALETTE_1C_4B=${IMAGES}/palette-1c-4b.tiff
42IMG_PALETTE_1C_8B=${IMAGES}/palette-1c-8b.tiff
43IMG_RGB_3C_16B=${IMAGES}/rgb-3c-16b.tiff
44IMG_RGB_3C_8B=${IMAGES}/rgb-3c-8b.tiff
45IMG_MINISBLACK_2C_8B_ALPHA=${IMAGES}/minisblack-2c-8b-alpha.tiff
46
47# All uncompressed image files
48IMG_UNCOMPRESSED="${IMG_MINISBLACK_1C_16B} ${IMG_MINISBLACK_1C_8B} ${IMG_MINISWHITE_1C_1B} ${IMG_PALETTE_1C_1B} ${IMG_PALETTE_1C_4B} ${IMG_PALETTE_1C_4B} ${IMG_PALETTE_1C_8B} ${IMG_RGB_3C_8B}"
49
50#
51# Test a simple convert-like command.
52#
53# f_test_convert command infile outfile
54f_test_convert ()
55{
56  command=$1
57  infile=$2
58  outfile=$3
59  rm -f $outfile
60  echo "$MEMCHECK $command $infile $outfile"
61  eval $MEMCHECK $command $infile $outfile
62  status=$?
63  if [ $status != 0 ] ; then
64    echo "Returned failed status $status!"
65    echo "Output (if any) is in \"${outfile}\"."
66    exit $status
67  fi
68}
69
70#
71# Test a simple command which sends output to stdout
72#
73# f_test_stdout command infile outfile
74f_test_stdout ()
75{
76  command=$1
77  infile=$2
78  outfile=$3
79  rm -f $outfile
80  echo "$MEMCHECK $command $infile > $outfile"
81  eval $MEMCHECK $command $infile > $outfile
82  status=$?
83  if [ $status != 0 ] ; then
84    echo "Returned failed status $status!"
85    echo "Output (if any) is in \"${outfile}\"."
86    exit $status
87  fi
88}
89
90#
91# Execute a simple command (e.g. tiffinfo) with one input file
92#
93# f_test_exec command infile
94f_test_reader ()
95{
96  command=$1
97  infile=$2
98  echo "$MEMCHECK $command $infile"
99  eval $MEMCHECK $command $infile
100  status=$?
101  if [ $status != 0 ] ; then
102    echo "Returned failed status $status!"
103    exit $status
104  fi
105}
106
107#
108# Execute tiffinfo on a specified file to validate it
109#
110# f_tiffinfo_validate infile
111f_tiffinfo_validate ()
112{
113    f_test_reader "$TIFFINFO -D" $1
114}
115
116if test "$VERBOSE" = TRUE
117then
118  set -x
119fi
120
121