From b6455049c42fd466eed7a40feaf2696c700bde00 Mon Sep 17 00:00:00 2001 From: Christian Zimmermann Date: Fri, 13 Jan 2023 15:42:15 +0100 Subject: [PATCH] add hdf5 test build files --- src/opt/hdf5/CMakeLists.txt | 11 ++++++++++- src/opt/hdf5/tests/CMakeLists.txt | 11 +++++++++++ src/opt/hdf5/tests/h5_basic_unit_test.cc | 8 ++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 src/opt/hdf5/tests/CMakeLists.txt create mode 100644 src/opt/hdf5/tests/h5_basic_unit_test.cc diff --git a/src/opt/hdf5/CMakeLists.txt b/src/opt/hdf5/CMakeLists.txt index 2119643..6d6593d 100644 --- a/src/opt/hdf5/CMakeLists.txt +++ b/src/opt/hdf5/CMakeLists.txt @@ -1,8 +1,17 @@ +find_package(HDF5 REQUIRED COMPONENTS C HL) +if(HDF5_FOUND) + include_directories(${HDF5_INCLUDE_DIRS}) +else() + message(FATAL_ERROR "HDF5 not found") +endif() +message(STATUS "hdf5 libs = ${HDF5_LIBRARIES}") +set(HDF5_LIBS ${HDF5_LIBRARIES} ${HDF5_HL_LIBRARIES}) + include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) add_subdirectory(lib) -#add_subdirectory(tests) +add_subdirectory(tests) set(HDF5_INSTALL_PATH ${INSTALL_PATH}/hdf5) install(DIRECTORY include/ DESTINATION ${HDF5_INSTALL_PATH}/include) diff --git a/src/opt/hdf5/tests/CMakeLists.txt b/src/opt/hdf5/tests/CMakeLists.txt new file mode 100644 index 0000000..41d0808 --- /dev/null +++ b/src/opt/hdf5/tests/CMakeLists.txt @@ -0,0 +1,11 @@ + +set(TEST_FILE_BASE "${CMAKE_CURRENT_BINARY_DIR}/test-file-") +message(STATUS "TEST_FILE_BASE = ${TEST_FILE_BASE}") +add_definitions(-DTEST_FILE_BASE=${TEST_FILE_BASE}) + +#add_test(NAME clean COMMAND rm -f ${TEST_FILE_BASE}*) + +add_executable(h5basic h5_basic_unit_test.cc) +add_dependencies(h5basic cnorxz cnorxzhdf5) +target_link_libraries(h5basic ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${HDF5_LIBS} cnorxz cnorxzhdf5) +add_test(NAME h5basic COMMAND rm -f ${TEST_FILE_BASE}* ; h5basic) diff --git a/src/opt/hdf5/tests/h5_basic_unit_test.cc b/src/opt/hdf5/tests/h5_basic_unit_test.cc new file mode 100644 index 0000000..8c49f6a --- /dev/null +++ b/src/opt/hdf5/tests/h5_basic_unit_test.cc @@ -0,0 +1,8 @@ + +// check no file +// check no hdf5 file +// check write to new file +// check read from that file +// check write to existing file +// check again read from that file +