From 08a85b5a24e821169f2f8e8afa15dd14ae234f8a Mon Sep 17 00:00:00 2001 From: tmadlener Date: Tue, 12 Dec 2023 13:25:49 +0100 Subject: [PATCH] Make SIO legacy tests run --- tests/CMakeLists.txt | 25 ++++++++++++++++++------- tests/root_io/CMakeLists.txt | 26 ++++++++------------------ tests/sio_io/CMakeLists.txt | 18 +++++++++--------- tests/sio_io/read_frame_legacy_sio.cpp | 7 ------- 4 files changed, 35 insertions(+), 41 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index ae0208500..c4ae542bb 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -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) @@ -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") diff --git a/tests/root_io/CMakeLists.txt b/tests/root_io/CMakeLists.txt index 8aea717c7..d09383e4b 100644 --- a/tests/root_io/CMakeLists.txt +++ b/tests/root_io/CMakeLists.txt @@ -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 diff --git a/tests/sio_io/CMakeLists.txt b/tests/sio_io/CMakeLists.txt index 4345af654..10a377d71 100644 --- a/tests/sio_io/CMakeLists.txt +++ b/tests/sio_io/CMakeLists.txt @@ -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() diff --git a/tests/sio_io/read_frame_legacy_sio.cpp b/tests/sio_io/read_frame_legacy_sio.cpp index 6809d13c0..5dbc123d3 100644 --- a/tests/sio_io/read_frame_legacy_sio.cpp +++ b/tests/sio_io/read_frame_legacy_sio.cpp @@ -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;