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 47IMG_PALETTE_1C_8B_BMP=${IMAGES}/palette-1c-8b.bmp 48IMG_RGB_3C_8B_BMP=${IMAGES}/rgb-3c-8b.bmp 49 50IMG_PALETTE_1C_8B_GIF=${IMAGES}/palette-1c-8b.gif 51 52IMG_MINISWHITE_1C_1B_PBM=${IMAGES}/miniswhite-1c-1b.pbm 53IMG_MINISBLACK_1C_8B_PGM=${IMAGES}/minisblack-1c-8b.pgm 54IMG_RGB_3C_8B_PPM=${IMAGES}/rgb-3c-8b.ppm 55 56# All uncompressed image files 57IMG_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}" 58 59# 60# Test a simple convert-like command. 61# 62# f_test_convert command infile outfile 63f_test_convert () 64{ 65 command=$1 66 infile=$2 67 outfile=$3 68 rm -f $outfile 69 echo "$MEMCHECK $command $infile $outfile" 70 eval $MEMCHECK $command $infile $outfile 71 status=$? 72 if [ $status != 0 ] ; then 73 echo "Returned failed status $status!" 74 echo "Output (if any) is in \"${outfile}\"." 75 exit $status 76 fi 77} 78 79# 80# Test a simple command which sends output to stdout 81# 82# f_test_stdout command infile outfile 83f_test_stdout () 84{ 85 command=$1 86 infile=$2 87 outfile=$3 88 rm -f $outfile 89 echo "$MEMCHECK $command $infile > $outfile" 90 eval $MEMCHECK $command $infile > $outfile 91 status=$? 92 if [ $status != 0 ] ; then 93 echo "Returned failed status $status!" 94 echo "Output (if any) is in \"${outfile}\"." 95 exit $status 96 fi 97} 98 99# 100# Execute a simple command (e.g. tiffinfo) with one input file 101# 102# f_test_exec command infile 103f_test_reader () 104{ 105 command=$1 106 infile=$2 107 echo "$MEMCHECK $command $infile" 108 eval $MEMCHECK $command $infile 109 status=$? 110 if [ $status != 0 ] ; then 111 echo "Returned failed status $status!" 112 exit $status 113 fi 114} 115 116# 117# Execute tiffinfo on a specified file to validate it 118# 119# f_tiffinfo_validate infile 120f_tiffinfo_validate () 121{ 122 f_test_reader "$TIFFINFO -D" $1 123} 124 125if test "$VERBOSE" = TRUE 126then 127 set -x 128fi 129 130