@@ -16,49 +16,62 @@ endif()
1616
1717# --- h5fortran unit tests
1818
19- function (setup_test names use_runner)
19+ function (nompi_test names )
20+
21+ foreach (name IN LISTS names )
22+
23+ add_executable (test_${name} test_${name} .f90)
24+ target_link_libraries (test_${name} PRIVATE h5mpi::h5mpi)
25+
26+ add_test (NAME ${name} COMMAND test_${name} )
27+
28+ endforeach ()
29+
30+ endfunction (nompi_test)
31+
32+
33+ function (mpi_test names use_runner)
2034
2135foreach (name IN LISTS names )
2236
2337add_executable (test_${name} test_${name} .f90)
2438target_link_libraries (test_${name} PRIVATE h5mpi::h5mpi)
2539
2640if (use_runner)
27- set (cmd test_runner -exe $<TARGET_FILE:test_${name} > -mpiexec ${MPIEXEC_EXECUTABLE} -lx 1000)
41+ set (cmd test_runner -exe $<TARGET_FILE:test_${name} > -mpiexec ${MPIEXEC_EXECUTABLE} -lx 1000)
2842else ()
29- set (cmd ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} $<TARGET_FILE:test_${name} >)
30- # these tests could also be -n 2 instead of max_numprocs.
31- # Just trying to keep aware of possible problems vs. MPI worker count.
43+ set (cmd ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} $<TARGET_FILE:test_${name} >)
44+ # these tests could also be -n 2 instead of max_numprocs.
45+ # Just trying to keep aware of possible problems vs. MPI worker count.
46+ endif ()
47+
3248if (${name} STREQUAL "string_read" )
3349 list (APPEND cmd ${string_file} )
3450endif ()
35- endif ()
36-
37-
3851
3952add_test (NAME ${name} COMMAND ${cmd} )
4053
54+ set_tests_properties (${name} PROPERTIES
55+ RESOUCE_LOCK cpu_mpi
56+ )
57+
4158endforeach ()
4259
43- endfunction (setup_test )
60+ endfunction (mpi_test )
4461
4562cmake_path(SET string_file ${CMAKE_CURRENT_BINARY_DIR} /test_string_py.h5)
4663
4764# --- write test data
48- add_executable (test_write test_write.f90)
49- target_link_libraries (test_write PRIVATE h5mpi::h5mpi)
50-
51- add_test (NAME write COMMAND test_write)
5265
53- set (test_names array attributes cast destructor exist fill groups layout shape
54- string string_read
66+ set (mpi_tests array_mpi attributes cast destructor exist fill groups layout shape
67+ string string_read write
5568)
5669
57- setup_test ("${test_names } " false )
70+ mpi_test ("${mpi_tests } " false )
5871
5972set (runner_tests deflate_write deflate_props deflate_read)
6073
61- setup_test ("${runner_tests} " true )
74+ mpi_test ("${runner_tests} " true )
6275
6376# --- test dependencies
6477
@@ -68,7 +81,7 @@ FIXTURES_SETUP test_files
6881
6982set_tests_properties (layout shape PROPERTIES
7083FIXTURES_REQUIRED test_files
71- REQUIRED_FILES ${CMAKE_CURRENT_BINARY_DIR} /test_write.h5
84+ REQUIRED_FILES " ${CMAKE_CURRENT_BINARY_DIR} /test_write.h5; ${CMAKE_CURRENT_BINARY_DIR} /test_layout.h5"
7285)
7386
7487set_tests_properties (deflate_write PROPERTIES
@@ -87,13 +100,6 @@ EXECUTABLE ${CMAKE_CTEST_COMMAND}
87100)
88101endif ()
89102
90- # --- Windows shared DLLs
91- if (WIN32 AND CMAKE_VERSION VERSION_GREATER_EQUAL 3.22)
92- set_tests_properties (${test_names} PROPERTIES
93- ENVIRONMENT_MODIFICATION "PATH=path_list_append:${ZLIB_INCLUDE_DIRS} /../bin;PATH=path_list_append:${ZLIB_INCLUDE_DIR} /../bin"
94- )
95- endif ()
96-
97103# --- Python h5py
98104find_package (Python COMPONENTS Interpreter)
99105if (NOT DEFINED h5py_ok)
@@ -117,14 +123,22 @@ COMMAND ${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_string.py ${string
117123)
118124
119125set_tests_properties (PythonString PROPERTIES
120- FIXTURES_REQUIRED h5lib
121126FIXTURES_SETUP h5str
122127DISABLED $<NOT :$<BOOL :${h5py_ok} >>
123128)
124129
130+ # --- test properties
131+
125132get_property (test_names DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY TESTS)
126133
127134set_tests_properties (${test_names} PROPERTIES
128135TIMEOUT 30
129136WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
130137)
138+
139+ # --- Windows shared DLLs
140+ if (WIN32 AND CMAKE_VERSION VERSION_GREATER_EQUAL 3.22)
141+ set_tests_properties (${test_names} PROPERTIES
142+ ENVIRONMENT_MODIFICATION "PATH=path_list_append:${ZLIB_INCLUDE_DIRS} /../bin;PATH=path_list_append:${ZLIB_INCLUDE_DIR} /../bin"
143+ )
144+ endif ()
0 commit comments