roentgen b75cab
# Common code fragment for tests
roentgen b75cab
#
roentgen b75cab
srcdir=${srcdir:-.}
roentgen b75cab
BUILDDIR=`pwd`
roentgen b75cab
SRCDIR=`dirname $0`
roentgen b75cab
SRCDIR=`cd $SRCDIR && pwd`
roentgen b75cab
TOPSRCDIR=`cd $srcdir/.. && pwd`
roentgen b75cab
TOOLS=`cd ../tools && pwd`
roentgen b75cab
IMAGES="${SRCDIR}/images"
roentgen b75cab
roentgen b75cab
# Aliases for built tools
roentgen b75cab
BMP2TIFF=${TOOLS}/bmp2tiff
roentgen b75cab
FAX2PS=${TOOLS}/fax2ps
roentgen b75cab
FAX2TIFF=${TOOLS}/fax2tiff
roentgen b75cab
GIF2TIFF=${TOOLS}/gif2tiff
roentgen b75cab
PAL2RGB=${TOOLS}/pal2rgb
roentgen b75cab
PPM2TIFF=${TOOLS}/ppm2tiff
roentgen b75cab
RAS2TIFF=${TOOLS}/ras2tiff
roentgen b75cab
RAW2TIFF=${TOOLS}/raw2tiff
roentgen b75cab
RGB2YCBCR=${TOOLS}/rgb2ycbcr
roentgen b75cab
THUMBNAIL=${TOOLS}/thumbnail
roentgen b75cab
TIFF2BW=${TOOLS}/tiff2bw
roentgen b75cab
TIFF2PDF=${TOOLS}/tiff2pdf
roentgen b75cab
TIFF2PS=${TOOLS}/tiff2ps
roentgen b75cab
TIFF2RGBA=${TOOLS}/tiff2rgba
roentgen b75cab
TIFFCMP=${TOOLS}/tiffcmp
roentgen b75cab
TIFFCP=${TOOLS}/tiffcp
roentgen b75cab
TIFFCROP=${TOOLS}/tiffcrop
roentgen b75cab
TIFFDITHER=${TOOLS}/tiffdither
roentgen b75cab
TIFFDUMP=${TOOLS}/tiffdump
roentgen b75cab
TIFFINFO=${TOOLS}/tiffinfo
roentgen b75cab
TIFFMEDIAN=${TOOLS}/tiffmedian
roentgen b75cab
TIFFSET=${TOOLS}/tiffset
roentgen b75cab
TIFFSPLIT=${TOOLS}/tiffsplit
roentgen b75cab
roentgen b75cab
# Aliases for input test files
roentgen b75cab
IMG_MINISBLACK_1C_16B=${IMAGES}/minisblack-1c-16b.tiff
roentgen b75cab
IMG_MINISBLACK_1C_8B=${IMAGES}/minisblack-1c-8b.tiff
roentgen b75cab
IMG_MINISWHITE_1C_1B=${IMAGES}/miniswhite-1c-1b.tiff
roentgen b75cab
IMG_PALETTE_1C_1B=${IMAGES}/palette-1c-1b.tiff
roentgen b75cab
IMG_PALETTE_1C_4B=${IMAGES}/palette-1c-4b.tiff
roentgen b75cab
IMG_PALETTE_1C_8B=${IMAGES}/palette-1c-8b.tiff
roentgen b75cab
IMG_RGB_3C_16B=${IMAGES}/rgb-3c-16b.tiff
roentgen b75cab
IMG_RGB_3C_8B=${IMAGES}/rgb-3c-8b.tiff
roentgen b75cab
IMG_MINISBLACK_2C_8B_ALPHA=${IMAGES}/minisblack-2c-8b-alpha.tiff
roentgen b75cab
roentgen b75cab
IMG_PALETTE_1C_8B_BMP=${IMAGES}/palette-1c-8b.bmp
roentgen b75cab
IMG_RGB_3C_8B_BMP=${IMAGES}/rgb-3c-8b.bmp
roentgen b75cab
roentgen b75cab
IMG_PALETTE_1C_8B_GIF=${IMAGES}/palette-1c-8b.gif
roentgen b75cab
roentgen b75cab
IMG_MINISWHITE_1C_1B_PBM=${IMAGES}/miniswhite-1c-1b.pbm
roentgen b75cab
IMG_MINISBLACK_1C_8B_PGM=${IMAGES}/minisblack-1c-8b.pgm
roentgen b75cab
IMG_RGB_3C_8B_PPM=${IMAGES}/rgb-3c-8b.ppm
roentgen b75cab
roentgen b75cab
# All uncompressed image files
roentgen b75cab
IMG_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}"
roentgen b75cab
roentgen b75cab
#
roentgen b75cab
# Test a simple convert-like command.
roentgen b75cab
#
roentgen b75cab
# f_test_convert command infile outfile
roentgen b75cab
f_test_convert ()
roentgen b75cab
{ 
roentgen b75cab
  command=$1
roentgen b75cab
  infile=$2
roentgen b75cab
  outfile=$3
roentgen b75cab
  rm -f $outfile
roentgen b75cab
  echo "$MEMCHECK $command $infile $outfile"
roentgen b75cab
  eval $MEMCHECK $command $infile $outfile
roentgen b75cab
  status=$?
roentgen b75cab
  if [ $status != 0 ] ; then
roentgen b75cab
    echo "Returned failed status $status!"
roentgen b75cab
    echo "Output (if any) is in \"${outfile}\"."
roentgen b75cab
    exit $status
roentgen b75cab
  fi
roentgen b75cab
}
roentgen b75cab
roentgen b75cab
#
roentgen b75cab
# Test a simple command which sends output to stdout
roentgen b75cab
#
roentgen b75cab
# f_test_stdout command infile outfile
roentgen b75cab
f_test_stdout ()
roentgen b75cab
{ 
roentgen b75cab
  command=$1
roentgen b75cab
  infile=$2
roentgen b75cab
  outfile=$3
roentgen b75cab
  rm -f $outfile
roentgen b75cab
  echo "$MEMCHECK $command $infile > $outfile"
roentgen b75cab
  eval $MEMCHECK $command $infile > $outfile
roentgen b75cab
  status=$?
roentgen b75cab
  if [ $status != 0 ] ; then
roentgen b75cab
    echo "Returned failed status $status!"
roentgen b75cab
    echo "Output (if any) is in \"${outfile}\"."
roentgen b75cab
    exit $status
roentgen b75cab
  fi
roentgen b75cab
}
roentgen b75cab
roentgen b75cab
#
roentgen b75cab
# Execute a simple command (e.g. tiffinfo) with one input file
roentgen b75cab
#
roentgen b75cab
# f_test_exec command infile
roentgen b75cab
f_test_reader ()
roentgen b75cab
{ 
roentgen b75cab
  command=$1
roentgen b75cab
  infile=$2
roentgen b75cab
  echo "$MEMCHECK $command $infile"
roentgen b75cab
  eval $MEMCHECK $command $infile
roentgen b75cab
  status=$?
roentgen b75cab
  if [ $status != 0 ] ; then
roentgen b75cab
    echo "Returned failed status $status!"
roentgen b75cab
    exit $status
roentgen b75cab
  fi
roentgen b75cab
}
roentgen b75cab
roentgen b75cab
#
roentgen b75cab
# Execute tiffinfo on a specified file to validate it
roentgen b75cab
#
roentgen b75cab
# f_tiffinfo_validate infile
roentgen b75cab
f_tiffinfo_validate ()
roentgen b75cab
{
roentgen b75cab
    f_test_reader "$TIFFINFO -D" $1
roentgen b75cab
}
roentgen b75cab
roentgen b75cab
if test "$VERBOSE" = TRUE
roentgen b75cab
then
roentgen b75cab
  set -x
roentgen b75cab
fi
roentgen b75cab