Skip to content

Commit

Permalink
Make SIO legacy tests run
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadlener committed Dec 12, 2023
1 parent 1fbc233 commit 08a85b5
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 41 deletions.
25 changes: 18 additions & 7 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,27 @@ PODIO_ADD_ROOT_IO_DICT(ExtensionDataModelDict ExtensionDataModel "${ext_headers}

PODIO_ADD_SIO_IO_BLOCKS(ExtensionDataModel "${ext_headers}" "${ext_sources}")

set(legacy_test_versions
v00-16
v00-16-02
v00-16-05
v00-16-06
)

include(ExternalData)
list(APPEND ExternalData_URL_TEMPLATES
"https://key4hep.web.cern.ch:443/testFiles/podio/%(hash)"
)


# Add a legacy test case based on a base executable and a version for which an
# input file exists
macro(ADD_PODIO_LEGACY_TEST version base_test input_file)
ExternalData_Add_Test(legacy_test_cases
NAME ${base_test}_${version}
COMMAND ${base_test} DATA{${PROJECT_SOURCE_DIR}/tests/input_files/${input_file}}
)
set_property(TEST ${base_test}_${version} PROPERTY ENVIRONMENT
LD_LIBRARY_PATH=${PROJECT_BINARY_DIR}/tests:${PROJECT_BINARY_DIR}/src:$ENV{LD_LIBRARY_PATH}
# Clear the ROOT_INCLUDE_PATH for the tests, to avoid potential conflicts
# with existing headers from other installations
ROOT_INCLUDE_PATH=
)
endmacro()

add_subdirectory(root_io)
if (ENABLE_SIO)
add_subdirectory(sio_io)
Expand Down Expand Up @@ -91,3 +100,5 @@ endif()
configure_file(CTestCustom.cmake ${PROJECT_BINARY_DIR}/CTestCustom.cmake @ONLY)

ExternalData_Add_Target(legacy_test_cases)

message(STATUS "Test inputs will be stored in: ${ExternalData_OBJECT_STORES} if they are not already present")
26 changes: 8 additions & 18 deletions tests/root_io/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,16 @@ endif()
add_executable(read_frame_legacy_root read_frame_legacy_root.cpp)
target_link_libraries(read_frame_legacy_root PRIVATE "${root_libs}")

message(STATUS "Test inputs will be stored in: ${ExternalData_OBJECT_STORES} if they are not already present")

# Add a legacy test case based on a base executable and a version for which an
# input file exists
macro(ADD_PODIO_LEGACY_TEST version base_test input_file)
ExternalData_Add_Test(legacy_test_cases
NAME ${base_test}_${version}
COMMAND ${base_test} DATA{${PROJECT_SOURCE_DIR}/tests/input_files/${input_file}}
)
set_property(TEST ${base_test}_${version} PROPERTY ENVIRONMENT
LD_LIBRARY_PATH=${PROJECT_BINARY_DIR}/tests:${PROJECT_BINARY_DIR}/src:$ENV{LD_LIBRARY_PATH}
# Clear the ROOT_INCLUDE_PATH for the tests, to avoid potential conflicts
# with existing headers from other installations
ROOT_INCLUDE_PATH=
)
endmacro()
set(legacy_test_versions
v00-16
v00-16-02
v00-16-05
v00-16-06
)

foreach(version IN LISTS legacy_test_versions)
ADD_PODIO_LEGACY_TEST(${version} read_frame_root ${version}-example_frame.root legacy_test_cases)
ADD_PODIO_LEGACY_TEST(${version} read_frame_legacy_root ${version}-example.root legacy_test_cases)
ADD_PODIO_LEGACY_TEST(${version} read_frame_root ${version}-example_frame.root)
ADD_PODIO_LEGACY_TEST(${version} read_frame_legacy_root ${version}-example.root)
endforeach()

#--- Write via python and the ROOT backend and see if we can read it back in in
Expand Down
18 changes: 9 additions & 9 deletions tests/sio_io/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ set_property(TEST read_python_frame_sio PROPERTY DEPENDS write_python_frame_sio)
add_executable(read_frame_legacy_sio read_frame_legacy_sio.cpp)
target_link_libraries(read_frame_legacy_sio PRIVATE "${sio_libs}" TestDataModel)

# If the variable is cached and defined now, we have inputs and can add the
# legacy file read test
if (DEFINED CACHE{PODIO_TEST_INPUT_DATA_DIR})
message(STATUS "Using test inputs stored in: " ${PODIO_TEST_INPUT_DATA_DIR})

foreach(version IN LISTS "00-16-05;00-16-06")
ADD_PODIO_LEGACY_TEST(${version} read_frame_sio example_frame.sio legacy_test_cases)
ADD_PODIO_LEGACY_TEST(${version} read_frame_legacy_sio example.sio legacy_test_cases)
endforeach()
endif()
set(legacy_test_versions
v00-16-05
v00-16-06
)

foreach(version IN LISTS legacy_test_versions)
ADD_PODIO_LEGACY_TEST(${version} read_frame_sio ${version}-example_frame.sio)
ADD_PODIO_LEGACY_TEST(${version} read_frame_legacy_sio ${version}-example.sio)
endforeach()
7 changes: 0 additions & 7 deletions tests/sio_io/read_frame_legacy_sio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@ int main(int argc, char* argv[]) {
return 1;
}

if (reader.currentFileVersion() != podio::version::build_version) {
std::cerr << "The podio build version could not be read back correctly. "
<< "(expected:" << podio::version::build_version << ", actual: " << reader.currentFileVersion() << ")"
<< std::endl;
return 1;
}

if (reader.getEntries("events") != 2000) {
std::cerr << "Could not read back the number of events correctly. "
<< "(expected:" << 2000 << ", actual: " << reader.getEntries("events") << ")" << std::endl;
Expand Down

0 comments on commit 08a85b5

Please sign in to comment.