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