| 1 | # Common code fragment for tests |
| 2 | # |
| 3 | srcdir=${srcdir:-.} |
| 4 | BUILDDIR=`pwd` |
| 5 | SRCDIR=`dirname $0` |
| 6 | SRCDIR=`cd $SRCDIR && pwd` |
| 7 | TOPSRCDIR=`cd $srcdir/.. && pwd` |
| 8 | TOOLS=`cd ../tools && pwd` |
| 9 | IMAGES="${SRCDIR}/images" |
| 10 | |
| 11 | # Aliases for built tools |
| 12 | BMP2TIFF=${TOOLS}/bmp2tiff |
| 13 | FAX2PS=${TOOLS}/fax2ps |
| 14 | FAX2TIFF=${TOOLS}/fax2tiff |
| 15 | GIF2TIFF=${TOOLS}/gif2tiff |
| 16 | PAL2RGB=${TOOLS}/pal2rgb |
| 17 | PPM2TIFF=${TOOLS}/ppm2tiff |
| 18 | RAS2TIFF=${TOOLS}/ras2tiff |
| 19 | RAW2TIFF=${TOOLS}/raw2tiff |
| 20 | RGB2YCBCR=${TOOLS}/rgb2ycbcr |
| 21 | THUMBNAIL=${TOOLS}/thumbnail |
| 22 | TIFF2BW=${TOOLS}/tiff2bw |
| 23 | TIFF2PDF=${TOOLS}/tiff2pdf |
| 24 | TIFF2PS=${TOOLS}/tiff2ps |
| 25 | TIFF2RGBA=${TOOLS}/tiff2rgba |
| 26 | TIFFCMP=${TOOLS}/tiffcmp |
| 27 | TIFFCP=${TOOLS}/tiffcp |
| 28 | TIFFCROP=${TOOLS}/tiffcrop |
| 29 | TIFFDITHER=${TOOLS}/tiffdither |
| 30 | TIFFDUMP=${TOOLS}/tiffdump |
| 31 | TIFFINFO=${TOOLS}/tiffinfo |
| 32 | TIFFMEDIAN=${TOOLS}/tiffmedian |
| 33 | TIFFSET=${TOOLS}/tiffset |
| 34 | TIFFSPLIT=${TOOLS}/tiffsplit |
| 35 | |
| 36 | # Aliases for input test files |
| 37 | IMG_MINISBLACK_1C_16B=${IMAGES}/minisblack-1c-16b.tiff |
| 38 | IMG_MINISBLACK_1C_8B=${IMAGES}/minisblack-1c-8b.tiff |
| 39 | IMG_MINISWHITE_1C_1B=${IMAGES}/miniswhite-1c-1b.tiff |
| 40 | IMG_PALETTE_1C_1B=${IMAGES}/palette-1c-1b.tiff |
| 41 | IMG_PALETTE_1C_4B=${IMAGES}/palette-1c-4b.tiff |
| 42 | IMG_PALETTE_1C_8B=${IMAGES}/palette-1c-8b.tiff |
| 43 | IMG_RGB_3C_16B=${IMAGES}/rgb-3c-16b.tiff |
| 44 | IMG_RGB_3C_8B=${IMAGES}/rgb-3c-8b.tiff |
| 45 | IMG_MINISBLACK_2C_8B_ALPHA=${IMAGES}/minisblack-2c-8b-alpha.tiff |
| 46 | |
| 47 | IMG_PALETTE_1C_8B_BMP=${IMAGES}/palette-1c-8b.bmp |
| 48 | IMG_RGB_3C_8B_BMP=${IMAGES}/rgb-3c-8b.bmp |
| 49 | |
| 50 | IMG_PALETTE_1C_8B_GIF=${IMAGES}/palette-1c-8b.gif |
| 51 | |
| 52 | IMG_MINISWHITE_1C_1B_PBM=${IMAGES}/miniswhite-1c-1b.pbm |
| 53 | IMG_MINISBLACK_1C_8B_PGM=${IMAGES}/minisblack-1c-8b.pgm |
| 54 | IMG_RGB_3C_8B_PPM=${IMAGES}/rgb-3c-8b.ppm |
| 55 | |
| 56 | # All uncompressed image files |
| 57 | 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}" |
| 58 | |
| 59 | # |
| 60 | # Test a simple convert-like command. |
| 61 | # |
| 62 | # f_test_convert command infile outfile |
| 63 | f_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 |
| 83 | f_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 |
| 103 | f_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 |
| 120 | f_tiffinfo_validate () |
| 121 | { |
| 122 | f_test_reader "$TIFFINFO -D" $1 |
| 123 | } |
| 124 | |
| 125 | if test "$VERBOSE" = TRUE |
| 126 | then |
| 127 | set -x |
| 128 | fi |
| 129 | |