blob: cec245893a7107bda30fc5340331e537f2baf83d (
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
|
cmake_minimum_required (VERSION 3.12)
project (HDF5_HL_TEST C)
# --------------------------------------------------------------------
# Notes: When creating unit test executables they should be prefixed
# with "hl_". This allows for easier filtering of the test suite when
# using ctest. An example would be
# ctest -R hl_
# which would only run the High Level based unit tests.
# --------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Generate the H5srcdir_str.h file containing user settings needed by compilation
#-----------------------------------------------------------------------------
set (srcdir ${CMAKE_CURRENT_SOURCE_DIR})
configure_file (${HDF5_HL_TEST_SOURCE_DIR}/H5srcdir_str.h.in H5srcdir_str.h @ONLY)
# --------------------------------------------------------------------
# Macro used to add a unit test
# --------------------------------------------------------------------
macro (HL_ADD_EXE hl_name)
add_executable (hl_${hl_name} ${hl_name}.c)
target_compile_options(hl_${hl_name} PRIVATE "${HDF5_CMAKE_C_FLAGS}")
target_include_directories (hl_${hl_name} PRIVATE "${HDF5_TEST_SRC_DIR};${HDF5_SRC_INCLUDE_DIRS};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
if (NOT BUILD_SHARED_LIBS)
TARGET_C_PROPERTIES (hl_${hl_name} STATIC)
target_link_libraries (hl_${hl_name} PRIVATE
${HDF5_HL_LIB_TARGET}
${HDF5_TEST_LIB_TARGET}
${HDF5_LIB_TARGET}
)
else ()
TARGET_C_PROPERTIES (hl_${hl_name} SHARED)
target_link_libraries (hl_${hl_name} PRIVATE
${HDF5_HL_LIBSH_TARGET}
${HDF5_TEST_LIBSH_TARGET}
${HDF5_LIBSH_TARGET}
)
endif ()
set_target_properties (hl_${hl_name} PROPERTIES FOLDER test/hl)
#-----------------------------------------------------------------------------
# Add Target to clang-format
#-----------------------------------------------------------------------------
if (HDF5_ENABLE_FORMATTERS)
clang_format (HDF5_HL_TEST_${hl_name}_FORMAT hl_${hl_name})
endif ()
endmacro ()
HL_ADD_EXE (test_lite)
HL_ADD_EXE (test_image)
HL_ADD_EXE (test_file_image)
HL_ADD_EXE (test_table)
HL_ADD_EXE (test_ds)
HL_ADD_EXE (test_ld)
HL_ADD_EXE (test_dset_append)
HL_ADD_EXE (test_h5do_compat)
# test_packet has two source files
add_executable (hl_test_packet test_packet.c test_packet_vlen.c)
target_compile_options(hl_test_packet PRIVATE "${HDF5_CMAKE_C_FLAGS}")
target_include_directories (hl_test_packet PRIVATE "${HDF5_TEST_SRC_DIR};${HDF5_SRC_INCLUDE_DIRS};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
if (NOT BUILD_SHARED_LIBS)
TARGET_C_PROPERTIES (hl_test_packet STATIC)
target_link_libraries (hl_test_packet PRIVATE
${HDF5_HL_LIB_TARGET}
${HDF5_TEST_LIB_TARGET}
${HDF5_LIB_TARGET}
)
else ()
TARGET_C_PROPERTIES (hl_test_packet SHARED)
target_link_libraries (hl_test_packet PRIVATE
${HDF5_HL_LIBSH_TARGET}
${HDF5_TEST_LIBSH_TARGET}
${HDF5_LIBSH_TARGET}
)
endif ()
set_target_properties (hl_test_packet PROPERTIES FOLDER test/hl)
#-----------------------------------------------------------------------------
# Add Target to clang-format
#-----------------------------------------------------------------------------
if (HDF5_ENABLE_FORMATTERS)
clang_format (HDF5_HL_TEST_hl_test_packet_FORMAT hl_test_packet)
endif ()
# --------------------------------------------------------------------
# This executable is used to generate test files for the test_ds test.
# It should only be run during development when new test files are needed
# --------------------------------------------------------------------
if (HDF5_BUILD_GENERATORS AND BUILD_STATIC_LIBS)
add_executable (hl_gen_test_ds gen_test_ds.c)
target_compile_options(hl_gen_test_ds PRIVATE "${HDF5_CMAKE_C_FLAGS}")
target_include_directories (hl_gen_test_ds PRIVATE "${HDF5_SRC_INCLUDE_DIRS};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
TARGET_C_PROPERTIES (hl_gen_test_ds STATIC)
target_link_libraries (hl_gen_test_ds PRIVATE
${HDF5_HL_LIB_TARGET}
${HDF5_TEST_LIB_TARGET}
${HDF5_LIB_TARGET}
)
set_target_properties (hl_gen_test_ds PROPERTIES FOLDER test/hl/gen)
#-----------------------------------------------------------------------------
# Add Target to clang-format
#-----------------------------------------------------------------------------
if (HDF5_ENABLE_FORMATTERS)
clang_format (HDF5_HL_TEST_hl_gen_test_ds_FORMAT hl_gen_test_ds)
endif ()
add_executable (hl_gen_test_ld gen_test_ld.c)
target_compile_options(hl_gen_test_ld PRIVATE "${HDF5_CMAKE_C_FLAGS}")
target_include_directories (hl_gen_test_ld PRIVATE "${HDF5_SRC_INCLUDE_DIRS};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
TARGET_C_PROPERTIES (hl_gen_test_ld STATIC)
target_link_libraries (hl_gen_test_ld PRIVATE
${HDF5_HL_LIB_TARGET}
${HDF5_TEST_LIB_TARGET}
${HDF5_LIB_TARGET}
)
set_target_properties (hl_gen_test_ld PROPERTIES FOLDER test/hl/gen)
#-----------------------------------------------------------------------------
# Add Target to clang-format
#-----------------------------------------------------------------------------
if (HDF5_ENABLE_FORMATTERS)
clang_format (HDF5_HL_TEST_hl_gen_test_ld_FORMAT hl_gen_test_ld)
endif ()
endif ()
if (HDF5_TEST_SERIAL)
include (CMakeTests.cmake)
endif ()
|