summaryrefslogtreecommitdiff
path: root/test/CMakeLists.txt
blob: c89bb82439e57bd141517b319fe9169470ff2bec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
# CMake build for libtiff
#
# Copyright © 2015 Open Microscopy Environment / University of Dundee
# Written by Roger Leigh <rleigh@codelibre.net>
#
# 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.

include_directories(${PROJECT_SOURCE_DIR}/libtiff
                    ${PROJECT_BINARY_DIR}/libtiff
                    ${CMAKE_CURRENT_BINARY_DIR}
                    ${TIFF_INCLUDES})

# Test scripts (not used by CMake)
set(TESTSCRIPTS
    bmp2tiff_palette.sh
    bmp2tiff_rgb.sh
    gif2tiff.sh
    ppm2tiff_pbm.sh
    ppm2tiff_pgm.sh
    ppm2tiff_ppm.sh
    fax2tiff.sh
    tiffcp-g3.sh
    tiffcp-g3-1d.sh
    tiffcp-g3-1d-fill.sh
    tiffcp-g3-2d.sh
    tiffcp-g3-2d-fill.sh
    tiffcp-g4.sh
    tiffcp-logluv.sh
    tiffcp-thumbnail.sh
    tiffcp-lzw-compat.sh
    tiffcp-lzw-scanline-decode.sh
    tiffdump.sh
    tiffinfo.sh
    tiffcp-split.sh
    tiffcp-split-join.sh
    tiff2ps-PS1.sh
    tiff2ps-PS2.sh
    tiff2ps-PS3.sh
    tiff2ps-EPS1.sh
    tiff2pdf.sh
    tiffcrop-doubleflip-logluv-3c-16b.sh
    tiffcrop-doubleflip-minisblack-1c-16b.sh
    tiffcrop-doubleflip-minisblack-1c-8b.sh
    tiffcrop-doubleflip-minisblack-2c-8b-alpha.sh
    tiffcrop-doubleflip-miniswhite-1c-1b.sh
    tiffcrop-doubleflip-palette-1c-1b.sh
    tiffcrop-doubleflip-palette-1c-4b.sh
    tiffcrop-doubleflip-palette-1c-8b.sh
    tiffcrop-doubleflip-rgb-3c-16b.sh
    tiffcrop-doubleflip-rgb-3c-8b.sh
    tiffcrop-extract-logluv-3c-16b.sh
    tiffcrop-extract-minisblack-1c-16b.sh
    tiffcrop-extract-minisblack-1c-8b.sh
    tiffcrop-extract-minisblack-2c-8b-alpha.sh
    tiffcrop-extract-miniswhite-1c-1b.sh
    tiffcrop-extract-palette-1c-1b.sh
    tiffcrop-extract-palette-1c-4b.sh
    tiffcrop-extract-palette-1c-8b.sh
    tiffcrop-extract-rgb-3c-16b.sh
    tiffcrop-extract-rgb-3c-8b.sh
    tiffcrop-extractz14-logluv-3c-16b.sh
    tiffcrop-extractz14-minisblack-1c-16b.sh
    tiffcrop-extractz14-minisblack-1c-8b.sh
    tiffcrop-extractz14-minisblack-2c-8b-alpha.sh
    tiffcrop-extractz14-miniswhite-1c-1b.sh
    tiffcrop-extractz14-palette-1c-1b.sh
    tiffcrop-extractz14-palette-1c-4b.sh
    tiffcrop-extractz14-palette-1c-8b.sh
    tiffcrop-extractz14-rgb-3c-16b.sh
    tiffcrop-extractz14-rgb-3c-8b.sh
    tiffcrop-R90-logluv-3c-16b.sh
    tiffcrop-R90-minisblack-1c-16b.sh
    tiffcrop-R90-minisblack-1c-8b.sh
    tiffcrop-R90-minisblack-2c-8b-alpha.sh
    tiffcrop-R90-miniswhite-1c-1b.sh
    tiffcrop-R90-palette-1c-1b.sh
    tiffcrop-R90-palette-1c-4b.sh
    tiffcrop-R90-palette-1c-8b.sh
    tiffcrop-R90-rgb-3c-16b.sh
    tiffcrop-R90-rgb-3c-8b.sh
    tiff2rgba-logluv-3c-16b.sh
    tiff2rgba-minisblack-1c-16b.sh
    tiff2rgba-minisblack-1c-8b.sh
    tiff2rgba-minisblack-2c-8b-alpha.sh
    tiff2rgba-miniswhite-1c-1b.sh
    tiff2rgba-palette-1c-1b.sh
    tiff2rgba-palette-1c-4b.sh
    tiff2rgba-palette-1c-8b.sh
    tiff2rgba-rgb-3c-16b.sh
    tiff2rgba-rgb-3c-8b.sh
    tiff2rgba-quad-tile.jpg.sh
    tiff2rgba-ojpeg_zackthecat_subsamp22_single_strip.sh
    tiff2rgba-ojpeg_chewey_subsamp21_multi_strip.sh)

# This list should contain all of the TIFF files in the 'images'
# subdirectory which are intended to be used as input images for
# tests.  All of these files should use the extension ".tiff".
set(TIFFIMAGES
    images/logluv-3c-16b.tiff
    images/minisblack-1c-16b.tiff
    images/minisblack-1c-8b.tiff
    images/minisblack-2c-8b-alpha.tiff
    images/miniswhite-1c-1b.tiff
    images/palette-1c-1b.tiff
    images/palette-1c-4b.tiff
    images/palette-1c-8b.tiff
    images/rgb-3c-16b.tiff
    images/rgb-3c-8b.tiff
    images/quad-tile.jpg.tiff
    images/quad-lzw-compat.tiff
    images/lzw-single-strip.tiff
    images/ojpeg_zackthecat_subsamp22_single_strip.tiff
    images/ojpeg_chewey_subsamp21_multi_strip.tiff)

set(BMPIMAGES
    images/palette-1c-8b.bmp
    images/rgb-3c-8b.bmp)

set(GIFIMAGES
    images/palette-1c-8b.gif)

set(PNMIMAGES
    images/minisblack-1c-8b.pgm
    images/miniswhite-1c-1b.pbm
    images/rgb-3c-8b.ppm)

# All uncompressed image files
set(UNCOMPRESSEDIMAGES
    images/minisblack-1c-16b.tiff
    images/minisblack-1c-8b.tiff
    images/miniswhite-1c-1b.tiff
    images/palette-1c-1b.tiff
    images/palette-1c-4b.tiff
    images/palette-1c-8b.tiff
    images/rgb-3c-8b.tiff)

# This list should include all of the files in the 'images'
# subdirectory which are intended to be distributed.  This may include
# files which are not currently used by the tests.
set(IMAGES_EXTRA_DIST
    images/README.txt
    images/miniswhite-1c-1b.g3
    ${BMPIMAGES}
    ${GIFIMAGES}
    ${PNMIMAGES}
    ${TIFFIMAGES})

extra_dist(
    ${TESTSCRIPTS}
    ${IMAGES_EXTRA_DIST}
    common.sh)

set(noinst_HEADERS tifftest.h)

add_executable(ascii_tag ascii_tag.c)
target_link_libraries(ascii_tag tiff port)

add_executable(long_tag long_tag.c check_tag.c)
target_link_libraries(long_tag tiff port)

add_executable(short_tag short_tag.c check_tag.c)
target_link_libraries(short_tag tiff port)

add_executable(strip_rw strip_rw.c strip.c test_arrays.c test_arrays.h)
target_link_libraries(strip_rw tiff port)

add_executable(rewrite rewrite_tag.c)
target_link_libraries(rewrite tiff port)

if(JPEG_SUPPORT)
  add_executable(raw_decode raw_decode.c)
  target_link_libraries(raw_decode tiff port)
endif()

add_executable(custom_dir custom_dir.c)
target_link_libraries(custom_dir tiff port)

add_executable(defer_strile_loading defer_strile_loading.c)
target_link_libraries(defer_strile_loading tiff port)

add_executable(defer_strile_writing defer_strile_writing.c)
target_link_libraries(defer_strile_writing tiff port)

add_executable(testtypes testtypes.c)
target_link_libraries(testtypes tiff port)

set(TEST_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/output")
file(MAKE_DIRECTORY "${TEST_OUTPUT}")

set(tiff_test_extra_args
    "-DTIFFCP=$<TARGET_FILE:tiffcp>"
    "-DTIFFINFO=$<TARGET_FILE:tiffinfo>"
    "-DTIFFSPLIT=$<TARGET_FILE:tiffsplit>"
    "-DLIBTIFF=$<TARGET_FILE:tiff>")
if(WIN32)
  list(APPEND tiff_test_extra_args "-DWIN32=${WIN32}")
endif()
if(CYGWIN)
  list(APPEND tiff_test_extra_args "-DCYGWIN=${CYGWIN}")
endif()

macro(tiff_test_convert name command1 command2 command3 infile outfile validate)
  add_test(NAME "${name}"
           COMMAND "${CMAKE_COMMAND}"
           "-DCONVERT_COMMAND1=${command1}"
           "-DCONVERT_COMMAND2=${command2}"
           "-DCONVERT_COMMAND3=${command3}"
           "-DINFILE=${infile}"
           "-DOUTFILE=${outfile}"
           "-DVALIDATE=${validate}"
           ${tiff_test_extra_args}
           -P "${CMAKE_CURRENT_SOURCE_DIR}/TiffTest.cmake")
endmacro()

macro(tiff_test_stdout name command infile outfile)
  add_test(NAME "${name}"
           COMMAND "${CMAKE_COMMAND}"
           "-DSTDOUT_COMMAND=${command}"
           "-DINFILE=${infile}"
           "-DOUTFILE=${outfile}"
           ${tiff_test_extra_args}
           -P "${CMAKE_CURRENT_SOURCE_DIR}/TiffTest.cmake")
endmacro()

macro(tiff_test_reader name command infile)
  add_test(NAME "${name}"
           COMMAND "${CMAKE_COMMAND}"
           "-DREADER_COMMAND=${command}"
           "-DINFILE=${infile}"
           ${tiff_test_extra_args}
           -P "${CMAKE_CURRENT_SOURCE_DIR}/TiffTest.cmake")
endmacro()

macro(add_convert_test_multi commandname1 commandname2 commandname3
      categoryname commandargs1 commandargs2 commandargs3
      image validate)
  string(REPLACE " " "^" escaped_commandargs1 "${commandargs1}")
  string(REPLACE " " "^" escaped_commandargs2 "${commandargs2}")
  string(REPLACE " " "^" escaped_commandargs3 "${commandargs3}")
  get_filename_component(name "${image}" NAME)
  get_filename_component(base "${image}" NAME_WE)
  set(testname "${commandname1}-${categoryname}-${base}")
  if(commandname1)
    set(command1
        "$<TARGET_FILE:${commandname1}>^${escaped_commandargs1}")
  else()
    set(command1)
  endif()
  if(commandname2)
    set(command2
        "$<TARGET_FILE:${commandname2}>^${escaped_commandargs2}")
  else()
    set(command2)
  endif()
  if(commandname3)
    set(command3
        "$<TARGET_FILE:${commandname3}>^${escaped_commandargs3}")
  else()
    set(command3)
  endif()
  set(infile "${CMAKE_CURRENT_SOURCE_DIR}/${image}")
  set(outfile "${TEST_OUTPUT}/${commandname1}-${categoryname}-${name}")
  string(REGEX REPLACE "\\.tiff\$" "" name "${name}")
  tiff_test_convert("${testname}" "${command1}" "${command2}" "${command3}"
                    "${infile}" "${outfile}" "${validate}")
endmacro()

macro(add_convert_test commandname
      categoryname commandargs
      image validate)
    add_convert_test_multi("${commandname}" "" ""
                           "${categoryname}" "${commandargs}" "" ""
                           "${image}" "${validate}")
endmacro()

macro(add_convert_tests_multi commandname commandname2 commandname3
      categoryname
      commandargs1 commandargs2 commandargs3
      images validate)
  foreach(file ${${images}})
    add_convert_test_multi("${commandname1}" "${commandname2}"
                           "${commandname3}" "${categoryname}"
                           "${commandargs1}" "${commandargs2}"
                           "${commandargs3}" "${file}" "${validate}")
  endforeach()
endmacro()

macro(add_convert_tests commandname categoryname commandargs images validate)
  foreach(file ${${images}})
    add_convert_test("${commandname}" "${categoryname}"
                     "${commandargs}" "${file}" "${validate}")
  endforeach()
endmacro()

macro(add_stdout_test commandname commandargs image)
  string(REPLACE " " "^" escaped_commandargs "${commandargs}")
  get_filename_component(name "${image}" NAME)
  get_filename_component(base "${image}" NAME_WE)
  set(testname "${commandname}-${base}")
  set(command "$<TARGET_FILE:${commandname}>^${escaped_commandargs}")
  set(infile "${CMAKE_CURRENT_SOURCE_DIR}/${image}")
  set(outfile "${TEST_OUTPUT}/${commandname}-${name}")
  string(REGEX REPLACE "\\.tiff\$" "" name "${name}")
  tiff_test_stdout("${testname}" "${command}" "${infile}" "${outfile}")
endmacro()

macro(add_reader_test commandname commandargs image)
  string(REPLACE " " "^" escaped_commandargs "${commandargs}")
  get_filename_component(name "${image}" NAME)
  get_filename_component(base "${image}" NAME_WE)
  set(testname "${commandname}-${base}")
  set(command "$<TARGET_FILE:${commandname}>^${escaped_commandargs}")
  set(infile "${CMAKE_CURRENT_SOURCE_DIR}/${image}")
  string(REGEX REPLACE "\\.tiff\$" "" name "${name}")
  tiff_test_reader("${testname}" "${command}" "${infile}")
endmacro()

# BMP
add_convert_test(bmp2tiff palette "" "images/palette-1c-8b.bmp" TRUE)
add_convert_test(bmp2tiff rgb     "" "images/rgb-3c-8b.bmp"     TRUE)

# GIF
add_convert_test(gif2tiff palette "" "images/palette-1c-8b.gif" TRUE)

# PPM
add_convert_test(ppm2tiff miniswhite "" "images/miniswhite-1c-1b.pbm" TRUE)
add_convert_test(ppm2tiff minisblack "" "images/minisblack-1c-8b.pgm" TRUE)
add_convert_test(ppm2tiff rgb        "" "images/rgb-3c-8b.ppm"        TRUE)

# tiffcp
add_convert_test(tiffcp   g3         "-c g3"         "images/miniswhite-1c-1b.tiff" FALSE)
add_convert_test(tiffcp   g31d       "-c g3:1d"      "images/miniswhite-1c-1b.tiff" FALSE)
add_convert_test(tiffcp   g31dfill   "-c g3:1d:fill" "images/miniswhite-1c-1b.tiff" FALSE)
add_convert_test(tiffcp   g32d       "-c g3:2d"      "images/miniswhite-1c-1b.tiff" FALSE)
add_convert_test(tiffcp   g32dfill   "-c g3:2d:fill" "images/miniswhite-1c-1b.tiff" FALSE)
add_convert_test(tiffcp   g4         "-c g4"         "images/miniswhite-1c-1b.tiff" FALSE)
add_convert_test(tiffcp   none       "-c none"       "images/quad-lzw-compat.tiff" FALSE)
add_convert_test(tiffcp   noner1     "-c none -r 1"  "images/lzw-single-strip.tiff" FALSE)
add_convert_test_multi(tiffcp tiffcp "" logluv "-c none" "-c sgilog" ""
                       "images/logluv-3c-16b.tiff"    FALSE)
add_convert_test_multi(tiffcp thumbnail "" thumbnail "g3:1d" "" ""
                       "images/miniswhite-1c-1b.tiff"    FALSE)

# tiffdump
add_reader_test(tiffdump "" "images/miniswhite-1c-1b.tiff")

# tiffinfo
add_reader_test(tiffinfo "-c -D -d -j -s" "images/minisblack-1c-16b.tiff")

# tiffcp split/join
foreach(image ${UNCOMPRESSEDIMAGES})
  list(APPEND ESCAPED_UNCOMPRESSED "${CMAKE_CURRENT_SOURCE_DIR}/${image}")
endforeach()
string(REPLACE ";" "^" ESCAPED_UNCOMPRESSED "${ESCAPED_UNCOMPRESSED}")
add_test(NAME "tiffcp-split"
         COMMAND "${CMAKE_COMMAND}"
         "-DTESTFILES=${ESCAPED_UNCOMPRESSED}"
         "-DCONJOINED=${TEST_OUTPUT}/tiffcp-split-conjoined.tif"
         "-DSPLITFILE=${TEST_OUTPUT}/tiffcp-split-split-"
         ${tiff_test_extra_args}
         -P "${CMAKE_CURRENT_SOURCE_DIR}/TiffSplitTest.cmake")
add_test(NAME "tiffcp-split-join"
         COMMAND "${CMAKE_COMMAND}"
         "-DTESTFILES=${ESCAPED_UNCOMPRESSED}"
         "-DCONJOINED=${TEST_OUTPUT}/tiffcp-split-join-conjoined.tif"
         "-DSPLITFILE=${TEST_OUTPUT}/tiffcp-split-join-split-"
         "-DRECONJOINED=${TEST_OUTPUT}/tiffcp-split-join-reconjoined.tif"
         ${tiff_test_extra_args}
         -P "${CMAKE_CURRENT_SOURCE_DIR}/TiffSplitTest.cmake")

# PDF
add_stdout_test(tiff2pdf "" "images/miniswhite-1c-1b.tiff" TRUE)

# RGBA
add_convert_tests(tiff2rgba default    ""                         TIFFIMAGES TRUE)
# Test rotations
add_convert_tests(tiffcrop  R90        "-R90"                     TIFFIMAGES TRUE)
# Test flip (mirror)
add_convert_tests(tiffcrop  doubleflip "-F both"                  TIFFIMAGES TRUE)
# Test extracting a section 60 pixels wide and 60 pixels high
add_convert_tests(tiffcrop  extract    "-U px -E top -X 60 -Y 60" TIFFIMAGES TRUE)
# Test extracting the first and fourth quarters from the left side.
add_convert_tests(tiffcrop  extractz14 "-E left -Z1:4,2:4"        TIFFIMAGES TRUE)

# test types
add_test(NAME "testtypes"
         COMMAND "testtypes")