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