Skip to content

Commit 6e6c4e2

Browse files
committedJan 23, 2022
Correct CMake testing
* Use functions rather than macros to avoid problems with variables in conditions (since macro arguments are not variables) * Conditionally add to file lists and test program lists based upon the configuration options (e.g. JPEG and old-JPEG availability) * Sync tests, files and option usage with current automake usage
1 parent 8a481db commit 6e6c4e2

File tree

3 files changed

+134
-155
lines changed

3 files changed

+134
-155
lines changed
 

‎test/CMakeLists.txt

+107-151
Original file line numberDiff line numberDiff line change
@@ -22,90 +22,12 @@
2222
# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
2323
# OF THIS SOFTWARE.
2424

25-
# Test scripts (not used by CMake)
26-
set(TESTSCRIPTS
27-
bmp2tiff_palette.sh
28-
bmp2tiff_rgb.sh
29-
gif2tiff.sh
30-
ppm2tiff_pbm.sh
31-
ppm2tiff_pgm.sh
32-
ppm2tiff_ppm.sh
33-
fax2tiff.sh
34-
tiffcp-g3.sh
35-
tiffcp-g3-1d.sh
36-
tiffcp-g3-1d-fill.sh
37-
tiffcp-g3-2d.sh
38-
tiffcp-g3-2d-fill.sh
39-
tiffcp-g4.sh
40-
tiffcp-logluv.sh
41-
tiffcp-thumbnail.sh
42-
tiffcp-lzw-compat.sh
43-
tiffcp-lzw-scanline-decode.sh
44-
tiffdump.sh
45-
tiffinfo.sh
46-
tiffcp-split.sh
47-
tiffcp-split-join.sh
48-
tiff2ps-PS1.sh
49-
tiff2ps-PS2.sh
50-
tiff2ps-PS3.sh
51-
tiff2ps-EPS1.sh
52-
tiff2pdf.sh
53-
tiffcrop-doubleflip-logluv-3c-16b.sh
54-
tiffcrop-doubleflip-minisblack-1c-16b.sh
55-
tiffcrop-doubleflip-minisblack-1c-8b.sh
56-
tiffcrop-doubleflip-minisblack-2c-8b-alpha.sh
57-
tiffcrop-doubleflip-miniswhite-1c-1b.sh
58-
tiffcrop-doubleflip-palette-1c-1b.sh
59-
tiffcrop-doubleflip-palette-1c-4b.sh
60-
tiffcrop-doubleflip-palette-1c-8b.sh
61-
tiffcrop-doubleflip-rgb-3c-16b.sh
62-
tiffcrop-doubleflip-rgb-3c-8b.sh
63-
tiffcrop-extract-logluv-3c-16b.sh
64-
tiffcrop-extract-minisblack-1c-16b.sh
65-
tiffcrop-extract-minisblack-1c-8b.sh
66-
tiffcrop-extract-minisblack-2c-8b-alpha.sh
67-
tiffcrop-extract-miniswhite-1c-1b.sh
68-
tiffcrop-extract-palette-1c-1b.sh
69-
tiffcrop-extract-palette-1c-4b.sh
70-
tiffcrop-extract-palette-1c-8b.sh
71-
tiffcrop-extract-rgb-3c-16b.sh
72-
tiffcrop-extract-rgb-3c-8b.sh
73-
tiffcrop-extractz14-logluv-3c-16b.sh
74-
tiffcrop-extractz14-minisblack-1c-16b.sh
75-
tiffcrop-extractz14-minisblack-1c-8b.sh
76-
tiffcrop-extractz14-minisblack-2c-8b-alpha.sh
77-
tiffcrop-extractz14-miniswhite-1c-1b.sh
78-
tiffcrop-extractz14-palette-1c-1b.sh
79-
tiffcrop-extractz14-palette-1c-4b.sh
80-
tiffcrop-extractz14-palette-1c-8b.sh
81-
tiffcrop-extractz14-rgb-3c-16b.sh
82-
tiffcrop-extractz14-rgb-3c-8b.sh
83-
tiffcrop-R90-logluv-3c-16b.sh
84-
tiffcrop-R90-minisblack-1c-16b.sh
85-
tiffcrop-R90-minisblack-1c-8b.sh
86-
tiffcrop-R90-minisblack-2c-8b-alpha.sh
87-
tiffcrop-R90-miniswhite-1c-1b.sh
88-
tiffcrop-R90-palette-1c-1b.sh
89-
tiffcrop-R90-palette-1c-4b.sh
90-
tiffcrop-R90-palette-1c-8b.sh
91-
tiffcrop-R90-rgb-3c-16b.sh
92-
tiffcrop-R90-rgb-3c-8b.sh
93-
tiff2rgba-logluv-3c-16b.sh
94-
tiff2rgba-minisblack-1c-16b.sh
95-
tiff2rgba-minisblack-1c-8b.sh
96-
tiff2rgba-minisblack-2c-8b-alpha.sh
97-
tiff2rgba-miniswhite-1c-1b.sh
98-
tiff2rgba-palette-1c-1b.sh
99-
tiff2rgba-palette-1c-4b.sh
100-
tiff2rgba-palette-1c-8b.sh
101-
tiff2rgba-rgb-3c-16b.sh
102-
tiff2rgba-rgb-3c-8b.sh
103-
tiff2rgba-quad-tile.jpg.sh
104-
tiff2rgba-ojpeg_zackthecat_subsamp22_single_strip.sh
105-
tiff2rgba-ojpeg_chewey_subsamp21_multi_strip.sh
106-
tiff2rgba-ojpeg_single_strip_no_rowsperstrip.sh
107-
testfax4.sh
108-
testdeflatelaststripextradata.sh)
25+
# Images for tiff2bw (8-bit RGB only)
26+
set(RGBIMAGES
27+
images/palette-1c-8b.tiff
28+
images/rgb-3c-8b.tiff
29+
images/quad-lzw-compat.tiff
30+
)
10931

11032
# This list should contain all of the TIFF files in the 'images'
11133
# subdirectory which are intended to be used as input images for
@@ -122,13 +44,23 @@ set(TIFFIMAGES
12244
images/palette-1c-8b.tiff
12345
images/rgb-3c-16b.tiff
12446
images/rgb-3c-8b.tiff
125-
images/quad-tile.jpg.tiff
12647
images/quad-lzw-compat.tiff
12748
images/lzw-single-strip.tiff
128-
images/ojpeg_zackthecat_subsamp22_single_strip.tiff
129-
images/ojpeg_chewey_subsamp21_multi_strip.tiff
130-
images/ojpeg_single_strip_no_rowsperstrip.tiff
13149
images/testfax4.tiff)
50+
# TIFF images using old-jpeg. Unused unless JPEG support is enabled.
51+
set(TIFFIMAGES_OJPEG)
52+
53+
if(JPEG_SUPPORT)
54+
list(APPEND TIFFIMAGES images/quad-tile.jpg.tiff)
55+
endif()
56+
57+
if (OJPEG_SUPPORT)
58+
list(APPEND TIFFIMAGES_OJPEG
59+
images/ojpeg_zackthecat_subsamp22_single_strip.tiff
60+
images/ojpeg_chewey_subsamp21_multi_strip.tiff
61+
images/ojpeg_single_strip_no_rowsperstrip.tiff
62+
)
63+
endif()
13264

13365
set(BMPIMAGES
13466
images/palette-1c-8b.bmp
@@ -166,83 +98,91 @@ set(IMAGES_EXTRA_DIST
16698

16799
set(noinst_HEADERS tifftest.h)
168100

101+
set(simple_tests)
102+
169103
add_executable(ascii_tag ../placeholder.h)
170104
target_sources(ascii_tag PRIVATE ascii_tag.c)
171105
target_link_libraries(ascii_tag PRIVATE tiff port)
106+
list(APPEND simple_tests ascii_tag)
172107

173108
add_executable(long_tag ../placeholder.h)
174109
target_sources(long_tag PRIVATE long_tag.c check_tag.c)
175110
target_link_libraries(long_tag PRIVATE tiff port)
111+
list(APPEND simple_tests long_tag)
176112

177113
add_executable(short_tag ../placeholder.h)
178114
target_sources(short_tag PRIVATE short_tag.c check_tag.c)
179115
target_link_libraries(short_tag PRIVATE tiff port)
116+
list(APPEND simple_tests short_tag)
180117

181118
add_executable(strip_rw ../placeholder.h)
182119
target_sources(strip_rw PRIVATE strip_rw.c strip.c test_arrays.c test_arrays.h)
183120
target_link_libraries(strip_rw PRIVATE tiff port)
121+
list(APPEND simple_tests strip_rw)
184122

185123
add_executable(rewrite ../placeholder.h)
186124
target_sources(rewrite PRIVATE rewrite_tag.c)
187125
target_link_libraries(rewrite PRIVATE tiff port)
126+
list(APPEND simple_tests rewrite)
188127

189128
if(JPEG_SUPPORT)
190129
add_executable(raw_decode ../placeholder.h)
191130
target_sources(raw_decode PRIVATE raw_decode.c)
192131
target_link_libraries(raw_decode PRIVATE tiff port JPEG::JPEG)
132+
list(APPEND simple_tests raw_decode)
193133
endif()
194134

195135
add_executable(custom_dir ../placeholder.h)
196136
target_sources(custom_dir PRIVATE custom_dir.c)
197137
target_link_libraries(custom_dir PRIVATE tiff port)
138+
list(APPEND simple_tests custom_dir)
198139

140+
# Uses private functions from static library
199141
if(NOT BUILD_SHARED_LIBS)
200-
add_executable(rational_precision2double ../placeholder.h)
201-
target_sources(rational_precision2double PRIVATE rational_precision2double.c)
202-
target_link_libraries(rational_precision2double PRIVATE tiff port)
203-
add_test(NAME "rational_precision2double"
204-
COMMAND "rational_precision2double")
142+
add_executable(rational_precision2double ../placeholder.h)
143+
target_sources(rational_precision2double PRIVATE rational_precision2double.c)
144+
target_link_libraries(rational_precision2double PRIVATE tiff port)
145+
list(APPEND simple_tests rational_precision2double)
205146
endif()
206147

207-
if(NOT BUILD_SHARED_LIBS)
208148
add_executable(custom_dir_EXIF_231 ../placeholder.h)
209149
target_sources(custom_dir_EXIF_231 PRIVATE custom_dir_EXIF_231.c)
210150
target_link_libraries(custom_dir_EXIF_231 PRIVATE tiff port)
211-
add_test(NAME "custom_dir_EXIF_231"
212-
COMMAND "custom_dir_EXIF_231")
213-
endif()
214-
215-
if(NOT BUILD_SHARED_LIBS)
216-
add_executable(test_directory ../placeholder.h)
217-
target_sources(test_directory PRIVATE test_directory.c)
218-
target_link_libraries(test_directory PRIVATE tiff port)
219-
add_test(NAME "test_directory"
220-
COMMAND "test_directory")
221-
endif()
151+
list(APPEND simple_tests custom_dir_EXIF_231)
222152

223153
add_executable(defer_strile_loading ../placeholder.h)
224154
target_sources(defer_strile_loading PRIVATE defer_strile_loading.c)
225155
target_link_libraries(defer_strile_loading PRIVATE tiff port)
156+
list(APPEND simple_tests defer_strile_loading)
226157

227158
add_executable(defer_strile_writing ../placeholder.h)
228159
target_sources(defer_strile_writing PRIVATE defer_strile_writing.c)
229160
target_link_libraries(defer_strile_writing PRIVATE tiff port)
161+
list(APPEND simple_tests defer_strile_writing)
162+
163+
add_executable(test_directory ../placeholder.h)
164+
target_sources(test_directory PRIVATE test_directory.c)
165+
target_link_libraries(test_directory PRIVATE tiff port)
166+
list(APPEND simple_tests test_directory)
230167

231168
add_executable(testtypes ../placeholder.h)
232169
target_sources(testtypes PRIVATE testtypes.c)
233170
target_link_libraries(testtypes PRIVATE tiff port)
171+
list(APPEND simple_tests testtypes)
234172

235173
if(WEBP_SUPPORT AND EMSCRIPTEN)
236174
# Emscripten is pretty finnicky about linker flags.
237175
# It needs --shared-memory if and only if atomics or bulk-memory is used.
238-
foreach(target ascii_tag
239-
custom_dir
240-
defer_strile_loading
241-
defer_strile_writing
242-
long_tag
243-
rewrite
244-
short_tag
245-
strip_rw)
176+
foreach(target
177+
ascii_tag
178+
long_tag
179+
short_tag
180+
strip_rw
181+
rewrite
182+
custom_dir
183+
defer_strile_loading
184+
defer_strile_writing
185+
)
246186
target_link_options(${target} PUBLIC "-Wl,--shared-memory")
247187
endforeach()
248188
if(JPEG_SUPPORT)
@@ -265,7 +205,7 @@ if(CYGWIN)
265205
list(APPEND tiff_test_extra_args "-DCYGWIN=${CYGWIN}")
266206
endif()
267207

268-
macro(tiff_test_convert name command1 command2 command3 infile outfile validate)
208+
function(tiff_test_convert name command1 command2 command3 infile outfile validate)
269209
add_test(NAME "${name}"
270210
COMMAND "${CMAKE_COMMAND}"
271211
"-DCONVERT_COMMAND1=${command1}"
@@ -276,28 +216,40 @@ macro(tiff_test_convert name command1 command2 command3 infile outfile validate)
276216
"-DVALIDATE=${validate}"
277217
${tiff_test_extra_args}
278218
-P "${CMAKE_CURRENT_SOURCE_DIR}/TiffTest.cmake")
279-
endmacro()
219+
endfunction()
280220

281-
macro(tiff_test_stdout name command infile outfile)
221+
function(tiff_test_stdout name suffix command infile outfile)
222+
if (suffix)
223+
set(name "${name}-${suffix}")
224+
endif()
282225
add_test(NAME "${name}"
283226
COMMAND "${CMAKE_COMMAND}"
284227
"-DSTDOUT_COMMAND=${command}"
285228
"-DINFILE=${infile}"
286229
"-DOUTFILE=${outfile}"
287230
${tiff_test_extra_args}
288231
-P "${CMAKE_CURRENT_SOURCE_DIR}/TiffTest.cmake")
289-
endmacro()
232+
endfunction()
290233

291-
macro(tiff_test_reader name command infile)
234+
function(tiff_test_stdout_noargs name command)
235+
add_test(NAME "${name}"
236+
COMMAND "${CMAKE_COMMAND}"
237+
"-DSTDOUT_COMMAND=$<TARGET_FILE:${command}>"
238+
${tiff_test_extra_args}
239+
-P "${CMAKE_CURRENT_SOURCE_DIR}/TiffTest.cmake"
240+
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
241+
endfunction()
242+
243+
function(tiff_test_reader name command infile)
292244
add_test(NAME "${name}"
293245
COMMAND "${CMAKE_COMMAND}"
294246
"-DREADER_COMMAND=${command}"
295247
"-DINFILE=${infile}"
296248
${tiff_test_extra_args}
297249
-P "${CMAKE_CURRENT_SOURCE_DIR}/TiffTest.cmake")
298-
endmacro()
250+
endfunction()
299251

300-
macro(add_convert_test_multi commandname1 commandname2 commandname3
252+
function(add_convert_test_multi commandname1 commandname2 commandname3
301253
categoryname commandargs1 commandargs2 commandargs3
302254
image validate)
303255
string(REPLACE " " "^" escaped_commandargs1 "${commandargs1}")
@@ -325,21 +277,20 @@ macro(add_convert_test_multi commandname1 commandname2 commandname3
325277
set(command3)
326278
endif()
327279
set(infile "${CMAKE_CURRENT_SOURCE_DIR}/${image}")
328-
set(outfile "${TEST_OUTPUT}/${commandname1}-${categoryname}-${name}")
329-
string(REGEX REPLACE "\\.tiff\$" "" name "${name}")
280+
set(outfile "${TEST_OUTPUT}/${commandname1}-${categoryname}-${base}.tiff")
330281
tiff_test_convert("${testname}" "${command1}" "${command2}" "${command3}"
331282
"${infile}" "${outfile}" "${validate}")
332-
endmacro()
283+
endfunction()
333284

334-
macro(add_convert_test commandname
285+
function(add_convert_test commandname
335286
categoryname commandargs
336287
image validate)
337288
add_convert_test_multi("${commandname}" "" ""
338289
"${categoryname}" "${commandargs}" "" ""
339290
"${image}" "${validate}")
340-
endmacro()
291+
endfunction()
341292

342-
macro(add_convert_tests_multi commandname commandname2 commandname3
293+
function(add_convert_tests_multi commandname1 commandname2 commandname3
343294
categoryname
344295
commandargs1 commandargs2 commandargs3
345296
images validate)
@@ -349,16 +300,16 @@ macro(add_convert_tests_multi commandname commandname2 commandname3
349300
"${commandargs1}" "${commandargs2}"
350301
"${commandargs3}" "${file}" "${validate}")
351302
endforeach()
352-
endmacro()
303+
endfunction()
353304

354-
macro(add_convert_tests commandname categoryname commandargs images validate)
305+
function(add_convert_tests commandname categoryname commandargs images validate)
355306
foreach(file ${${images}})
356307
add_convert_test("${commandname}" "${categoryname}"
357308
"${commandargs}" "${file}" "${validate}")
358309
endforeach()
359-
endmacro()
310+
endfunction()
360311

361-
macro(add_stdout_test commandname commandargs image)
312+
function(add_stdout_test commandname suffix commandargs image)
362313
string(REPLACE " " "^" escaped_commandargs "${commandargs}")
363314
get_filename_component(name "${image}" NAME)
364315
get_filename_component(base "${image}" NAME_WE)
@@ -367,26 +318,24 @@ macro(add_stdout_test commandname commandargs image)
367318
set(infile "${CMAKE_CURRENT_SOURCE_DIR}/${image}")
368319
set(outfile "${TEST_OUTPUT}/${commandname}-${name}")
369320
string(REGEX REPLACE "\\.tiff\$" "" name "${name}")
370-
tiff_test_stdout("${testname}" "${command}" "${infile}" "${outfile}")
371-
endmacro()
321+
tiff_test_stdout("${testname}" "${suffix}" "${command}" "${infile}" "${outfile}")
322+
endfunction()
372323

373-
macro(add_reader_test commandname commandargs image)
324+
function(add_reader_test commandname commandargs image)
374325
string(REPLACE " " "^" escaped_commandargs "${commandargs}")
375326
get_filename_component(name "${image}" NAME)
376327
get_filename_component(base "${image}" NAME_WE)
377328
set(testname "${commandname}-${base}")
378329
set(command "$<TARGET_FILE:${commandname}>^${escaped_commandargs}")
379330
set(infile "${CMAKE_CURRENT_SOURCE_DIR}/${image}")
380-
string(REGEX REPLACE "\\.tiff\$" "" name "${name}")
381331
tiff_test_reader("${testname}" "${command}" "${infile}")
382-
endmacro()
332+
endfunction()
383333

384-
# BMP
385-
add_convert_test(bmp2tiff palette "" "images/palette-1c-8b.bmp" TRUE)
386-
add_convert_test(bmp2tiff rgb "" "images/rgb-3c-8b.bmp" TRUE)
334+
# Plain executables with no arguments
335+
foreach(target IN LISTS simple_tests)
336+
tiff_test_stdout_noargs("${target}" "${target}")
337+
endforeach()
387338

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

391340
# PPM
392341
add_convert_test(ppm2tiff miniswhite "" "images/miniswhite-1c-1b.pbm" TRUE)
@@ -401,12 +350,12 @@ add_convert_test(tiffcp g31dfill "-c g3:1d:fill" "images/miniswhite-1c-1b.ti
401350
add_convert_test(tiffcp g32d "-c g3:2d" "images/miniswhite-1c-1b.tiff" FALSE)
402351
add_convert_test(tiffcp g32dfill "-c g3:2d:fill" "images/miniswhite-1c-1b.tiff" FALSE)
403352
add_convert_test(tiffcp g4 "-c g4" "images/miniswhite-1c-1b.tiff" FALSE)
404-
add_convert_test(tiffcp none "-c none" "images/quad-lzw-compat.tiff" FALSE)
405-
add_convert_test(tiffcp noner1 "-c none -r 1" "images/lzw-single-strip.tiff" FALSE)
406353
add_convert_test_multi(tiffcp tiffcp "" logluv "-c none" "-c sgilog" ""
407354
"images/logluv-3c-16b.tiff" FALSE)
408-
add_convert_test_multi(tiffcp thumbnail "" thumbnail "g3:1d" "" ""
355+
add_convert_test_multi(tiffcp thumbnail "" thumbnail "-c g3:1d" "" ""
409356
"images/miniswhite-1c-1b.tiff" FALSE)
357+
add_convert_test(tiffcp none "-c none" "images/quad-lzw-compat.tiff" FALSE)
358+
add_convert_test(tiffcp noner1 "-c none -r 1" "images/lzw-single-strip.tiff" FALSE)
410359

411360
# tiffdump
412361
add_reader_test(tiffdump "" "images/miniswhite-1c-1b.tiff")
@@ -423,24 +372,35 @@ string(REPLACE ";" "^" ESCAPED_UNCOMPRESSED "${ESCAPED_UNCOMPRESSED}")
423372
add_test(NAME "tiffcp-split"
424373
COMMAND "${CMAKE_COMMAND}"
425374
"-DTESTFILES=${ESCAPED_UNCOMPRESSED}"
426-
"-DCONJOINED=${TEST_OUTPUT}/tiffcp-split-conjoined.tif"
375+
"-DCONJOINED=${TEST_OUTPUT}/tiffcp-split-conjoined.tiff"
427376
"-DSPLITFILE=${TEST_OUTPUT}/tiffcp-split-split-"
428377
${tiff_test_extra_args}
429378
-P "${CMAKE_CURRENT_SOURCE_DIR}/TiffSplitTest.cmake")
430379
add_test(NAME "tiffcp-split-join"
431380
COMMAND "${CMAKE_COMMAND}"
432381
"-DTESTFILES=${ESCAPED_UNCOMPRESSED}"
433-
"-DCONJOINED=${TEST_OUTPUT}/tiffcp-split-join-conjoined.tif"
382+
"-DCONJOINED=${TEST_OUTPUT}/tiffcp-split-join-conjoined.tiff"
434383
"-DSPLITFILE=${TEST_OUTPUT}/tiffcp-split-join-split-"
435-
"-DRECONJOINED=${TEST_OUTPUT}/tiffcp-split-join-reconjoined.tif"
384+
"-DRECONJOINED=${TEST_OUTPUT}/tiffcp-split-join-reconjoined.tiff"
436385
${tiff_test_extra_args}
437386
-P "${CMAKE_CURRENT_SOURCE_DIR}/TiffSplitTest.cmake")
438387

439388
# PDF
440-
add_stdout_test(tiff2pdf "" "images/miniswhite-1c-1b.tiff" TRUE)
389+
add_stdout_test(tiff2pdf "" "" "images/miniswhite-1c-1b.tiff" TRUE)
390+
391+
# PS
392+
add_stdout_test(tiff2ps "ps-1" "-a -p -1" "images/miniswhite-1c-1b.tiff" TRUE)
393+
add_stdout_test(tiff2ps "ps-2" "-a -p -2" "images/miniswhite-1c-1b.tiff" TRUE)
394+
add_stdout_test(tiff2ps "ps-3" "-a -p -3" "images/miniswhite-1c-1b.tiff" TRUE)
395+
add_stdout_test(tiff2ps "eps-1" "-e -1" "images/miniswhite-1c-1b.tiff" TRUE)
396+
397+
# BW
398+
add_convert_tests(tiff2bw default "" RGBIMAGES TRUE)
441399

442400
# RGBA
443401
add_convert_tests(tiff2rgba default "" TIFFIMAGES TRUE)
402+
# RGBA (old-jpeg)
403+
add_convert_tests(tiff2rgba default "" TIFFIMAGES_OJPEG TRUE)
444404
# Test rotations
445405
add_convert_tests(tiffcrop R90 "-R90" TIFFIMAGES TRUE)
446406
# Test flip (mirror)
@@ -449,7 +409,3 @@ add_convert_tests(tiffcrop doubleflip "-F both" TIFFIMAGES TRU
449409
add_convert_tests(tiffcrop extract "-U px -E top -X 60 -Y 60" TIFFIMAGES TRUE)
450410
# Test extracting the first and fourth quarters from the left side.
451411
add_convert_tests(tiffcrop extractz14 "-E left -Z1:4,2:4" TIFFIMAGES TRUE)
452-
453-
# test types
454-
add_test(NAME "testtypes"
455-
COMMAND "testtypes")

‎test/TiffTest.cmake

+13-4
Original file line numberDiff line numberDiff line change
@@ -30,32 +30,41 @@ string(REPLACE "^" ";" CONVERT_COMMAND3 "${CONVERT_COMMAND3}")
3030
string(REPLACE "^" ";" STDOUT_COMMAND "${STDOUT_COMMAND}")
3131
string(REPLACE "^" ";" READER_COMMAND "${READER_COMMAND}")
3232

33+
if(NOT CONVERT_COMMAND1 AND NOT STDOUT_COMMAND AND NOT READER_COMMAND)
34+
message(FATAL_ERROR "No test command specified")
35+
endif()
36+
3337
if(CONVERT_COMMAND1)
3438
test_convert("${CONVERT_COMMAND1}" "${INFILE}" "${OUTFILE}")
3539
if(VALIDATE)
3640
tiffinfo_validate("${OUTFILE}")
3741
endif()
3842
endif()
3943

40-
get_filename_component(base "${OUTFILE}" NAME)
44+
get_filename_component(dir "${OUTFILE}" DIRECTORY)
45+
get_filename_component(base "${OUTFILE}" NAME_WE)
4146
get_filename_component(ext "${OUTFILE}" EXT)
4247

4348
if(CONVERT_COMMAND2)
44-
test_convert("${CONVERT_COMMAND2}" "${OUTFILE}" "${base}-2${ext}")
49+
test_convert("${CONVERT_COMMAND2}" "${OUTFILE}" "${dir}/${base}-2${ext}")
4550
if(VALIDATE)
4651
tiffinfo_validate("${base}-2${ext}")
4752
endif()
4853
endif()
4954

5055
if(CONVERT_COMMAND3)
51-
test_convert("${CONVERT_COMMAND3}" "${base}-2${ext}" "${base}-3${ext}")
56+
test_convert("${CONVERT_COMMAND3}" "${dir}/${base}-2${ext}" "${dir}/${base}-3${ext}")
5257
if(VALIDATE)
5358
tiffinfo_validate("${base}-3${ext}")
5459
endif()
5560
endif()
5661

5762
if(STDOUT_COMMAND)
58-
test_stdout("${STDOUT_COMMAND}" "${INFILE}" "${OUTFILE}")
63+
if(INFILE)
64+
test_stdout("${STDOUT_COMMAND}" "${INFILE}" "${OUTFILE}")
65+
else()
66+
test_stdout_noargs("${STDOUT_COMMAND}")
67+
endif()
5968
endif()
6069

6170
if(READER_COMMAND)

‎test/TiffTestCommon.cmake

+14
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ macro(test_convert_multi command infile outfile)
5656
message(FATAL_ERROR "Returned failed status ${TEST_STATUS}! Output (if any) is in \"${native_outfile}\"")
5757
endif()
5858
endmacro()
59+
5960
#
6061
# Test a simple command which sends output to stdout
6162
#
@@ -73,6 +74,19 @@ macro(test_stdout command infile outfile)
7374
endif()
7475
endmacro()
7576

77+
#
78+
# Test a simple command which sends output to stdout
79+
#
80+
# test_stdout command infile outfile
81+
macro(test_stdout_noargs command)
82+
message(STATUS "Running ${MEMCHECK} ${command}")
83+
execute_process(COMMAND ${MEMCHECK} ${command}
84+
RESULT_VARIABLE TEST_STATUS)
85+
if(TEST_STATUS)
86+
message(FATAL_ERROR "Returned failed status ${TEST_STATUS}!")
87+
endif()
88+
endmacro()
89+
7690
#
7791
# Execute a simple command (e.g. tiffinfo) with one input file
7892
#

0 commit comments

Comments
 (0)
Please sign in to comment.