|
1 | | -set_directory_properties(PROPERTIES LABELS unit) |
2 | | - |
3 | | -# --- helper functions |
4 | | - |
5 | | -function(nompi_test names) |
6 | | - |
7 | | -foreach(name IN LISTS names) |
8 | | - |
9 | | -add_executable(test_${name} test_${name}.f90) |
10 | | -target_link_libraries(test_${name} PRIVATE h5fortran::h5fortran) |
11 | | - |
12 | | -add_test(NAME ${name} COMMAND test_${name}) |
13 | | - |
14 | | -endforeach() |
15 | | - |
16 | | -set_tests_properties(${names} PROPERTIES |
17 | | -LABELS nompi |
18 | | -) |
19 | | - |
20 | | -endfunction(nompi_test) |
21 | | - |
22 | | - |
23 | | -function(mpi_test names use_runner) |
24 | | - |
25 | | -foreach(name IN LISTS names) |
26 | | - |
27 | | -add_executable(test_${name} test_${name}.f90) |
28 | | -target_link_libraries(test_${name} PRIVATE h5fortran::h5fortran) |
29 | | - |
30 | | -if(use_runner) |
31 | | - set(cmd test_runner -exe $<TARGET_FILE:test_${name}> -mpiexec ${MPIEXEC_EXECUTABLE} -lx 1000) |
32 | | -else() |
33 | | - set(cmd ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} $<TARGET_FILE:test_${name}>) |
34 | | - # these tests could also be -n 2 instead of max_numprocs. |
35 | | - # Just trying to keep aware of possible problems vs. MPI worker count. |
36 | | -endif() |
37 | | - |
38 | | -if(${name} STREQUAL "string_read") |
39 | | - list(APPEND cmd ${string_file}) |
40 | | -endif() |
41 | | - |
42 | | -add_test(NAME ${name} COMMAND ${cmd}) |
43 | | - |
44 | | -endforeach() |
45 | | - |
46 | | -set_tests_properties(${names} PROPERTIES |
47 | | -RESOURCE_LOCK cpu_mpi |
48 | | -LABELS mpi |
49 | | -) |
50 | | - |
51 | | -endfunction(mpi_test) |
52 | | - |
53 | | -# --- test files |
54 | | - |
55 | | -cmake_path(SET string_file ${CMAKE_CURRENT_BINARY_DIR}/test_string_py.h5) |
56 | | - |
57 | | -# --- non-MPI tests |
58 | | - |
59 | | -set(nompi_tests array attributes cast deflate_props deflate_read deflate_write destructor |
60 | | -exist fill |
61 | | -) |
62 | | - |
63 | | -nompi_test("${nompi_tests}") |
64 | | - |
65 | | -set_tests_properties(deflate_write PROPERTIES |
66 | | -FIXTURES_SETUP deflate_files |
67 | | -) |
68 | | - |
69 | | -set_tests_properties(deflate_props deflate_read PROPERTIES |
70 | | -FIXTURES_REQUIRED deflate_files |
71 | | -REQUIRED_FILES ${CMAKE_CURRENT_BINARY_DIR}/deflate1.h5 |
72 | | -) |
73 | | - |
74 | | - |
75 | | -# --- runner |
| 1 | +add_subdirectory(nompi) |
76 | 2 |
|
77 | 3 | if(hdf5_parallel) |
78 | | - |
79 | | -add_executable(test_runner runner.f90 |
80 | | -${PROJECT_SOURCE_DIR}/benchmark/cpu.cpp |
81 | | -${PROJECT_SOURCE_DIR}/benchmark/partition.f90 |
82 | | -${PROJECT_SOURCE_DIR}/benchmark/cli.f90 |
83 | | -) |
84 | | -# not linked as libraries in case benchmarks aren't built |
85 | | -if(CMAKE_Fortran_COMPILER_ID MATCHES "^Intel") |
86 | | - set_target_properties(test_runner PROPERTIES LINKER_LANGUAGE Fortran) |
87 | | -else() |
88 | | - set_target_properties(test_runner PROPERTIES LINKER_LANGUAGE CXX) |
89 | | -endif() |
90 | | - |
91 | | - |
92 | | -# --- MPI tests |
93 | | - |
94 | | -set(mpi_tests array_mpi attributes_mpi cast_mpi destructor_mpi exist_mpi |
95 | | -fill_mpi groups_mpi layout shape |
96 | | -string string_read write |
97 | | -) |
98 | | - |
99 | | -mpi_test("${mpi_tests}" false) |
100 | | - |
101 | | -set(runner_tests deflate_write_mpi deflate_props_mpi deflate_read_mpi) |
102 | | - |
103 | | -mpi_test("${runner_tests}" true) |
104 | | - |
105 | | -# --- test dependencies |
106 | | - |
107 | | -set_tests_properties(write PROPERTIES |
108 | | -FIXTURES_SETUP test_files |
109 | | -) |
110 | | - |
111 | | -set_tests_properties(layout shape PROPERTIES |
112 | | -FIXTURES_REQUIRED test_files |
113 | | -REQUIRED_FILES "${CMAKE_CURRENT_BINARY_DIR}/test_write.h5;${CMAKE_CURRENT_BINARY_DIR}/test_layout.h5" |
114 | | -) |
115 | | - |
116 | | -set_tests_properties(deflate_write_mpi PROPERTIES |
117 | | -FIXTURES_SETUP deflate_files_mpi |
118 | | -) |
119 | | - |
120 | | -set_tests_properties(deflate_props_mpi deflate_read_mpi PROPERTIES |
121 | | -FIXTURES_REQUIRED deflate_files_mpi |
122 | | -REQUIRED_FILES ${CMAKE_CURRENT_BINARY_DIR}/deflate1.h5 |
123 | | -) |
124 | | - |
125 | | -if(ENABLE_COVERAGE) |
126 | | -setup_target_for_coverage_gcovr_html( |
127 | | -NAME coverage |
128 | | -EXECUTABLE ${CMAKE_CTEST_COMMAND} |
129 | | -) |
130 | | -endif() |
131 | | - |
132 | | -# --- Python h5py |
133 | | -find_package(Python COMPONENTS Interpreter) |
134 | | -if(NOT DEFINED h5py_ok) |
135 | | - execute_process(COMMAND ${Python_EXECUTABLE} -c "import h5py" |
136 | | - RESULT_VARIABLE h5py_code |
137 | | - ) |
138 | | - if(h5py_code EQUAL 0) |
139 | | - set(h5py_ok true CACHE BOOL "h5py OK") |
140 | | - else() |
141 | | - set(h5py_ok false CACHE BOOL "h5py not OK") |
142 | | - endif() |
143 | | -endif() |
144 | | - |
145 | | -set_tests_properties(string_read PROPERTIES |
146 | | -FIXTURES_REQUIRED h5str |
147 | | -DISABLED $<NOT:$<BOOL:${h5py_ok}>> |
148 | | -) |
149 | | - |
150 | | -add_test(NAME PythonString |
151 | | -COMMAND ${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_string.py ${string_file} |
152 | | -) |
153 | | - |
154 | | -set_tests_properties(PythonString PROPERTIES |
155 | | -FIXTURES_SETUP h5str |
156 | | -DISABLED $<NOT:$<BOOL:${h5py_ok}>> |
157 | | -) |
158 | | - |
159 | | -endif(hdf5_parallel) |
160 | | - |
161 | | -# --- test properties |
162 | | - |
163 | | -get_property(test_names DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY TESTS) |
164 | | - |
165 | | -set_tests_properties(${test_names} PROPERTIES |
166 | | -TIMEOUT 30 |
167 | | -WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} |
168 | | -) |
169 | | - |
170 | | -# --- Windows shared DLLs |
171 | | -if(WIN32 AND CMAKE_VERSION VERSION_GREATER_EQUAL 3.22) |
172 | | - set_tests_properties(${test_names} PROPERTIES |
173 | | - ENVIRONMENT_MODIFICATION "PATH=path_list_append:${ZLIB_INCLUDE_DIRS}/../bin;PATH=path_list_append:${ZLIB_INCLUDE_DIR}/../bin" |
174 | | - ) |
| 4 | + add_subdirectory(mpi) |
175 | 5 | endif() |
0 commit comments