File: CMakeTests.cmake

package info (click to toggle)
libhdf4 4.3.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 30,384 kB
  • sloc: ansic: 128,700; sh: 15,015; fortran: 12,444; java: 5,863; xml: 1,205; makefile: 794; yacc: 678; pascal: 418; perl: 360; javascript: 203; lex: 163; csh: 41
file content (206 lines) | stat: -rw-r--r-- 6,992 bytes parent folder | download | duplicates (2)
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

##############################################################################
##############################################################################
###           T E S T I N G                                                ###
##############################################################################
##############################################################################

# --------------------------------------------------------------------
# This executable is used to generate test files for the hdiff tests.
# It should only be run during development when new test files are needed
# --------------------------------------------------------------------
if (HDF4_BUILD_GENERATORS AND NOT ONLY_SHARED_LIBS)
  set (hdifftst_SRCS
      ${HDF4_MFHDF_HDIFF_SOURCE_DIR}/hdifftst.c
  )

  add_executable (hdifftst ${hdifftst_SRCS})
  target_include_directories(hdifftst PRIVATE "${HDF4_HDF_BINARY_DIR};${HDF4_BINARY_DIR}")
  if (BUILD_SHARED_LIBS)
    TARGET_C_PROPERTIES (hdifftst STATIC)
    target_link_libraries (hdifftst PRIVATE ${HDF4_MF_LIB_TARGET})
  else ()
    TARGET_C_PROPERTIES (hdifftst SHARED)
    target_link_libraries (hdifftst PRIVATE ${HDF4_MF_LIBSH_TARGET})
  endif ()

  # Remove any output file left over from previous test run
  add_test (
      NAME HDIFF-GEN-clearall-objects
      COMMAND ${CMAKE_COMMAND} -E remove
          hdifftst1.hdf
          hdifftst2.hdf
          hdifftst3.hdf
          hdifftst4.hdf
          hdifftst5.hdf
          hdifftst6.hdf
          hdifftst7.hdf
  )
  set (last_test "HDIFF-GEN-clearall-objects")

  add_test (NAME hdifftst COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:hdifftst>)
  set_tests_properties (hdifftst PROPERTIES DEPENDS ${last_test} LABELS ${PROJECT_NAME})
  set (last_test "hdifftst")
endif ()

macro (ADD_H4_TEST resultfile resultcode)
  if (HDF4_ENABLE_USING_MEMCHECKER)
    add_test (NAME HDIFF-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:hdiff> ${ARGN})
    if (NOT ${resultcode} STREQUAL "0")
      set_tests_properties (HDIFF-${resultfile} PROPERTIES LABELS ${PROJECT_NAME} WILL_FAIL "true")
    else ()
      set_tests_properties (HDIFF-${resultfile} PROPERTIES LABELS ${PROJECT_NAME})
    endif ()
  else ()
    add_test (
        NAME HDIFF-${resultfile}
        COMMAND "${CMAKE_COMMAND}"
            -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}"
            -D "TEST_PROGRAM=$<TARGET_FILE:hdiff>"
            -D "TEST_ARGS:STRING=${ARGN}"
            -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles"
            -D "TEST_OUTPUT=${resultfile}.out"
            -D "TEST_EXPECT=${resultcode}"
            -D "TEST_REFERENCE=${resultfile}.txt"
            -P "${HDF_RESOURCES_DIR}/runTest.cmake"
    )
  endif ()
  if (NOT "${last_test}" STREQUAL "")
    set_tests_properties (HDIFF-${resultfile} PROPERTIES DEPENDS ${last_test} LABELS ${PROJECT_NAME})
  else ()
    set_tests_properties (HDIFF-${resultfile} PROPERTIES LABELS ${PROJECT_NAME})
  endif ()
  set (last_test "HDIFF-${resultfile}")
endmacro ()

#-- Copy all the data files from the test directory into the source directory
set (HDF4_REFERENCE_TEST_FILES
    hdifftst1.hdf
    hdifftst2.hdf
    hdifftst3.hdf
    hdifftst4.hdf
    hdifftst5.hdf
    hdifftst6.hdf
    hdifftst7.hdf
)
set (HDF4_REFERENCE_FILES
    hdiff_01.txt
    hdiff_02.txt
    hdiff_03.txt
    hdiff_04.txt
    hdiff_05.txt
#      hdiff_06.txt
    hdiff_07.txt
    hdiff_08.txt
    hdiff_09.txt
    hdiff_10.txt
    hdiff_11.txt
    hdiff_12.txt
    hdiff_13.txt
    hdiff_14.txt
    hdiff_15.txt
)

foreach (h4_file ${HDF4_REFERENCE_TEST_FILES} ${HDF4_REFERENCE_FILES})
  HDFTEST_COPY_FILE("${HDF4_MFHDF_HDIFF_SOURCE_DIR}/testfiles/${h4_file}" "${PROJECT_BINARY_DIR}/testfiles/${h4_file}" "hdiff_files")
endforeach ()

if (WIN32 AND MSVC_VERSION LESS 1900)
  HDFTEST_COPY_FILE("${HDF4_MFHDF_HDIFF_SOURCE_DIR}/testfiles/hdiff_06w.txt" "${PROJECT_BINARY_DIR}/testfiles/hdiff_06.txt" "hdiff_files")
else ()
  HDFTEST_COPY_FILE("${HDF4_MFHDF_HDIFF_SOURCE_DIR}/testfiles/hdiff_06.txt" "${PROJECT_BINARY_DIR}/testfiles/hdiff_06.txt" "hdiff_files")
endif ()

add_custom_target(hdiff_files ALL COMMENT "Copying files needed by hdiff tests" DEPENDS ${hdiff_files_list})

##############################################################################
##############################################################################
###           T H E   T E S T S                                            ###
##############################################################################
##############################################################################
# Remove any output file left over from previous test run
add_test (
    NAME HDIFF-clearall-objects
    COMMAND ${CMAKE_COMMAND} -E remove
        hdiff_01.out
        hdiff_02.out
        hdiff_03.out
        hdiff_04.out
        hdiff_05.out
        hdiff_06.out
        hdiff_07.out
        hdiff_08.out
        hdiff_09.out
        hdiff_10.out
        hdiff_11.out
        hdiff_12.out
        hdiff_13.out
        hdiff_14.out
        hdiff_15.out
        hdiff_01.out.err
        hdiff_02.out.err
        hdiff_03.out.err
        hdiff_04.out.err
        hdiff_05.out.err
        hdiff_06.out.err
        hdiff_07.out.err
        hdiff_08.out.err
        hdiff_09.out.err
        hdiff_10.out.err
        hdiff_11.out.err
        hdiff_12.out.err
        hdiff_13.out.err
        hdiff_14.out.err
        hdiff_15.out.err
)
if (NOT "${last_test}" STREQUAL "")
  set_tests_properties (HDIFF-clearall-objects PROPERTIES DEPENDS ${last_test} LABELS ${PROJECT_NAME})
else ()
  set_tests_properties (HDIFF-clearall-objects PROPERTIES LABELS ${PROJECT_NAME})
endif ()
set (last_test "HDIFF-clearall-objects")

# help message
ADD_H4_TEST (hdiff_01 1)

# Compare global attributes only
ADD_H4_TEST (hdiff_02 1 -g hdifftst1.hdf hdifftst2.hdf)

# Compare SD local attributes only
ADD_H4_TEST (hdiff_03 1 -s hdifftst1.hdf hdifftst2.hdf)

# Compare SD data only
ADD_H4_TEST (hdiff_04 1 -d hdifftst1.hdf hdifftst2.hdf)

# Compare Vdata data only
ADD_H4_TEST (hdiff_05 1 -D hdifftst1.hdf hdifftst2.hdf)

# Print statistics
ADD_H4_TEST (hdiff_06 1 -d -S hdifftst1.hdf hdifftst2.hdf)

# Compare SD data on variable(s)
ADD_H4_TEST (hdiff_07 1 -d -v dset1 hdifftst1.hdf hdifftst2.hdf)

# Compare vdata on variable(s)
ADD_H4_TEST (hdiff_08 1 -D -u vdata1 hdifftst1.hdf hdifftst2.hdf)

# Print difference up to count number
ADD_H4_TEST (hdiff_09 1 -d -e 2 hdifftst1.hdf hdifftst2.hdf)

# Print difference when it is greater than limit
ADD_H4_TEST (hdiff_10 1 -d -t 2 hdifftst1.hdf hdifftst2.hdf)

# no options
ADD_H4_TEST (hdiff_11 1 hdifftst1.hdf hdifftst2.hdf)

# percent (relative)
ADD_H4_TEST (hdiff_12 1 -d -p 0.05 -v dset3 hdifftst1.hdf hdifftst2.hdf)

# hyperslab reading
ADD_H4_TEST (hdiff_13 0 hdifftst3.hdf hdifftst4.hdf)

# lone dim
ADD_H4_TEST (hdiff_14 1 hdifftst5.hdf hdifftst6.hdf)

# group loop
ADD_H4_TEST (hdiff_15 0 -b hdifftst7.hdf hdifftst7.hdf)