diff --git a/test/Makefile.am b/test/Makefile.am index ff823cf3..77d2c994 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -33,9 +33,9 @@ check_PROGRAMS = ascii_tag long_tag short_tag strip_rw ascii_tag_SOURCES = ascii_tag.c ascii_tag_LDADD = $(LIBTIFF) -long_tag_SOURCES = long_tag.c +long_tag_SOURCES = long_tag.c check_tag.c long_tag_LDADD = $(LIBTIFF) -short_tag_SOURCES = short_tag.c +short_tag_SOURCES = short_tag.c check_tag.c short_tag_LDADD = $(LIBTIFF) strip_rw_SOURCES = strip_rw.c test_arrays.c test_arrays.h strip_rw_LDADD = $(LIBTIFF) diff --git a/test/Makefile.in b/test/Makefile.in index a70db5e4..6477e966 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.9.1 from Makefile.am. +# Makefile.in generated by automake 1.8.5 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -60,9 +60,7 @@ POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : -build_triplet = @build@ host_triplet = @host@ -target_triplet = @target@ check_PROGRAMS = ascii_tag$(EXEEXT) long_tag$(EXEEXT) \ short_tag$(EXEEXT) strip_rw$(EXEEXT) subdir = test @@ -80,10 +78,10 @@ am_ascii_tag_OBJECTS = ascii_tag.$(OBJEXT) ascii_tag_OBJECTS = $(am_ascii_tag_OBJECTS) am__DEPENDENCIES_1 = ascii_tag_DEPENDENCIES = $(am__DEPENDENCIES_1) -am_long_tag_OBJECTS = long_tag.$(OBJEXT) +am_long_tag_OBJECTS = long_tag.$(OBJEXT) check_tag.$(OBJEXT) long_tag_OBJECTS = $(am_long_tag_OBJECTS) long_tag_DEPENDENCIES = $(am__DEPENDENCIES_1) -am_short_tag_OBJECTS = short_tag.$(OBJEXT) +am_short_tag_OBJECTS = short_tag.$(OBJEXT) check_tag.$(OBJEXT) short_tag_OBJECTS = $(am_short_tag_OBJECTS) short_tag_DEPENDENCIES = $(am__DEPENDENCIES_1) am_strip_rw_OBJECTS = strip_rw.$(OBJEXT) test_arrays.$(OBJEXT) @@ -92,13 +90,17 @@ strip_rw_DEPENDENCIES = $(am__DEPENDENCIES_1) DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/libtiff -I$(top_builddir)/libtiff depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles +@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/ascii_tag.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/check_tag.Po ./$(DEPDIR)/long_tag.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/short_tag.Po ./$(DEPDIR)/strip_rw.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/test_arrays.Po COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) --mode=compile --tag=CC $(CC) $(DEFS) \ +LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) -LINK = $(LIBTOOL) --mode=link --tag=CC $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ +LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ SOURCES = $(ascii_tag_SOURCES) $(long_tag_SOURCES) \ $(short_tag_SOURCES) $(strip_rw_SOURCES) @@ -198,8 +200,6 @@ am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ @@ -238,9 +238,9 @@ LIBTIFF = -L$(top_builddir)/libtiff -ltiff TESTS = $(check_PROGRAMS) ascii_tag_SOURCES = ascii_tag.c ascii_tag_LDADD = $(LIBTIFF) -long_tag_SOURCES = long_tag.c +long_tag_SOURCES = long_tag.c check_tag.c long_tag_LDADD = $(LIBTIFF) -short_tag_SOURCES = short_tag.c +short_tag_SOURCES = short_tag.c check_tag.c short_tag_LDADD = $(LIBTIFF) strip_rw_SOURCES = strip_rw.c test_arrays.c test_arrays.h strip_rw_LDADD = $(LIBTIFF) @@ -305,6 +305,7 @@ distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ascii_tag.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_tag.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/long_tag.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/short_tag.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strip_rw.Po@am__quote@ @@ -314,21 +315,24 @@ distclean-compile: @am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/$*.Plo' tmpdepfile='$(DEPDIR)/$*.TPlo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: @@ -514,7 +518,7 @@ mostlyclean-generic: clean-generic: distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" diff --git a/test/check_tag.c b/test/check_tag.c new file mode 100644 index 00000000..a8adae6c --- /dev/null +++ b/test/check_tag.c @@ -0,0 +1,72 @@ +/* $Id: check_tag.c,v 1.1 2004-10-01 14:16:37 dron Exp $ */ + +/* + * Copyright (c) 2004, Andrey Kiselev + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +/* + * TIFF Library + * + * Module to test LONG tags read/write functions. + */ + +#include "tiffio.h" + +int +CheckShortField(TIFF *tif, ttag_t field, uint16 value) +{ + uint16 tmp = 0; + + if (!TIFFGetField(tif, field, &tmp)) { + fprintf (stderr, "Problem fetching tag %lu.\n", + (unsigned long) field); + return -1; + } + if (tmp != value) { + fprintf (stderr, "Wrong SHORT value fetched for tag %lu.\n", + (unsigned long) field); + return -1; + } + + return 0; +} + +int +CheckLongField(TIFF *tif, ttag_t field, uint32 value) +{ + uint32 tmp = 0; + + if (!TIFFGetField(tif, field, &tmp)) { + fprintf (stderr, "Problem fetching tag %lu.\n", + (unsigned long) field); + return -1; + } + if (tmp != value) { + fprintf (stderr, "Wrong LONG value fetched for tag %lu.\n", + (unsigned long) field); + return -1; + } + + return 0; +} + + diff --git a/test/long_tag.c b/test/long_tag.c index 86206bbb..9c5d05aa 100644 --- a/test/long_tag.c +++ b/test/long_tag.c @@ -1,4 +1,4 @@ -/* $Id: long_tag.c,v 1.1 2004-09-10 13:47:08 dron Exp $ */ +/* $Id: long_tag.c,v 1.2 2004-10-01 14:16:37 dron Exp $ */ /* * Copyright (c) 2004, Andrey Kiselev @@ -39,6 +39,8 @@ #include "tiffio.h" +extern int CheckLongField(TIFF *, ttag_t, uint32); + const char *filename = "long_test.tiff"; static struct Tags { @@ -60,7 +62,6 @@ main(int argc, char **argv) TIFF *tif; int i; unsigned char buf[3] = { 0, 127, 255 }; - uint32 value; /* Test whether we can write tags. */ tif = TIFFOpen(filename, "w"); @@ -122,31 +123,19 @@ main(int argc, char **argv) return 1; } - if (!TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &value) - || value != width) { - fprintf (stderr, "Can't get tag %d.\n", TIFFTAG_IMAGEWIDTH); + if (CheckLongField(tif, TIFFTAG_IMAGEWIDTH, width) < 0) goto failure; - } - if (!TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &value) - || value != length) { - fprintf (stderr, "Can't get tag %d.\n", TIFFTAG_IMAGELENGTH); + if (CheckLongField(tif, TIFFTAG_IMAGELENGTH, length) < 0) goto failure; - } - if (!TIFFGetField(tif, TIFFTAG_ROWSPERSTRIP, &value) - || value != rows_per_strip) { - fprintf (stderr, "Can't get tag %d.\n", TIFFTAG_ROWSPERSTRIP); + if (CheckLongField(tif, TIFFTAG_ROWSPERSTRIP, rows_per_strip) < 0) goto failure; - } for (i = 0; i < NTAGS; i++) { - if (!TIFFGetField(tif, long_tags[i].tag, &value) - || value != long_tags[i].value) { - fprintf(stderr, "Can't get tag %d.\n", - (int)long_tags[i].tag); + if (CheckLongField(tif, long_tags[i].tag, + long_tags[i].value) < 0) goto failure; - } } TIFFClose(tif); diff --git a/test/short_tag.c b/test/short_tag.c index 49d93dd9..9c82e0ff 100644 --- a/test/short_tag.c +++ b/test/short_tag.c @@ -1,4 +1,4 @@ -/* $Id: short_tag.c,v 1.2 2004-09-14 15:14:21 dron Exp $ */ +/* $Id: short_tag.c,v 1.3 2004-10-01 14:16:37 dron Exp $ */ /* * Copyright (c) 2004, Andrey Kiselev @@ -39,6 +39,8 @@ #include "tiffio.h" +extern int CheckShortField(TIFF *, ttag_t, uint16); + const char *filename = "short_test.tiff"; #define SPP 3 /* Samples per pixel */ @@ -73,7 +75,6 @@ main(int argc, char **argv) TIFF *tif; int i; unsigned char buf[3] = { 0, 127, 255 }; - uint16 value; /* Test whether we can write tags. */ tif = TIFFOpen(filename, "w"); @@ -134,49 +135,32 @@ main(int argc, char **argv) fprintf (stderr, "Can't open test TIFF file %s.\n", filename); return 1; } - if (!TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &value) - || value != width) { - fprintf (stderr, "Can't get tag %d.\n", TIFFTAG_IMAGEWIDTH); + + if (CheckShortField(tif, TIFFTAG_IMAGEWIDTH, width) < 0) goto failure; - } - if (!TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &value) - || value != length) { - fprintf (stderr, "Can't get tag %d.\n", TIFFTAG_IMAGELENGTH); + + if (CheckShortField(tif, TIFFTAG_IMAGELENGTH, length) < 0) goto failure; - } - if (!TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &value) - || value != bps) { - fprintf (stderr, "Can't get tag %d.\n", TIFFTAG_BITSPERSAMPLE); + + if (CheckShortField(tif, TIFFTAG_BITSPERSAMPLE, bps) < 0) goto failure; - } - if (!TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &value) - || value != photometric) { - fprintf (stderr, "Can't get tag %d.\n", TIFFTAG_PHOTOMETRIC); + + if (CheckShortField(tif, TIFFTAG_PHOTOMETRIC, photometric) < 0) goto failure; - } - if (!TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &value) - || value != SPP) { - fprintf (stderr, "Can't get tag %d.\n", TIFFTAG_SAMPLESPERPIXEL); + + if (CheckShortField(tif, TIFFTAG_SAMPLESPERPIXEL, SPP) < 0) goto failure; - } - if (!TIFFGetField(tif, TIFFTAG_ROWSPERSTRIP, &value) - || value != rows_per_strip) { - fprintf (stderr, "Can't get tag %d.\n", TIFFTAG_ROWSPERSTRIP); + + if (CheckShortField(tif, TIFFTAG_ROWSPERSTRIP, rows_per_strip) < 0) goto failure; - } - if (!TIFFGetField(tif, TIFFTAG_PLANARCONFIG, &value) - || value != planarconfig) { - fprintf (stderr, "Can't get tag %d.\n", TIFFTAG_PLANARCONFIG); + + if (CheckShortField(tif, TIFFTAG_PLANARCONFIG, planarconfig) < 0) goto failure; - } for (i = 0; i < NSINGLETAGS; i++) { - if (!TIFFGetField(tif, short_single_tags[i].tag, &value) - || value != short_single_tags[i].value) { - fprintf(stderr, "Can't get tag %d.\n", - (int)short_single_tags[i].tag); + if (CheckShortField(tif, short_single_tags[i].tag, + short_single_tags[i].value) < 0) goto failure; - } } TIFFClose(tif); diff --git a/test/strip_rw.c b/test/strip_rw.c index 7820abc5..3788e9b6 100644 --- a/test/strip_rw.c +++ b/test/strip_rw.c @@ -1,4 +1,4 @@ -/* $Id: strip_rw.c,v 1.2 2004-09-15 13:00:02 dron Exp $ */ +/* $Id: strip_rw.c,v 1.3 2004-10-01 14:16:37 dron Exp $ */ /* * Copyright (c) 2004, Andrey Kiselev @@ -320,9 +320,9 @@ main(int argc, char **argv) goto failure; } if (read_image_stripped(filename, XSIZE * YSIZE, 1, rowsperstrip, - compression, spp, bps, photometric, - sampleformat, planarconfig, - (const tdata_t) byte_array1, byte_array1_size) < 0) { + compression, spp, bps, photometric, + sampleformat, planarconfig, + (const tdata_t) byte_array1, byte_array1_size) < 0) { fprintf (stderr, "Can't read TIFF file %s.\n", filename); goto failure; } @@ -336,9 +336,9 @@ main(int argc, char **argv) goto failure; } if (read_image_stripped(filename, 1, XSIZE * YSIZE, rowsperstrip, - compression, spp, bps, photometric, - sampleformat, planarconfig, - (const tdata_t) byte_array1, byte_array1_size) < 0) { + compression, spp, bps, photometric, + sampleformat, planarconfig, + (const tdata_t) byte_array1, byte_array1_size) < 0) { fprintf (stderr, "Can't read TIFF file %s.\n", filename); goto failure; } @@ -362,9 +362,9 @@ main(int argc, char **argv) goto failure; } if (read_image_stripped(filename, XSIZE, YSIZE, rowsperstrip, - compression, spp, bps, photometric, - sampleformat, planarconfig, - (const tdata_t) byte_array1, byte_array1_size) < 0) { + compression, spp, bps, photometric, + sampleformat, planarconfig, + (const tdata_t) byte_array1, byte_array1_size) < 0) { fprintf (stderr, "Can't read TIFF file %s.\n", filename); goto failure; } @@ -379,9 +379,9 @@ main(int argc, char **argv) goto failure; } if (read_image_stripped(filename, XSIZE, YSIZE, rowsperstrip, - compression, spp, bps, photometric, - sampleformat, planarconfig, - (const tdata_t) byte_array1, byte_array1_size) < 0) { + compression, spp, bps, photometric, + sampleformat, planarconfig, + (const tdata_t) byte_array1, byte_array1_size) < 0) { fprintf (stderr, "Can't read TIFF file %s.\n", filename); goto failure; }