diff --git a/src/SIOBlock.cc b/src/SIOBlock.cc index 6e06d0405..5bdd1b842 100644 --- a/src/SIOBlock.cc +++ b/src/SIOBlock.cc @@ -122,7 +122,7 @@ SIOBlockLibraryLoader::SIOBlockLibraryLoader() { const auto status = loadLib(lib); switch (status) { case LoadStatus::Success: - std::cout << "Loaded SIOBlocks library \'" << lib << "\' (from " << dir << ")" << std::endl; + std::cerr << "Loaded SIOBlocks library \'" << lib << "\' (from " << dir << ")" << std::endl; break; case LoadStatus::AlreadyLoaded: std::cerr << "SIOBlocks library \'" << lib << "\' already loaded. Not loading again from " << dir << std::endl; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index cae6e31b2..d1e68d9b8 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -242,3 +242,36 @@ else() ) endif() +# Add tests for storing and retrieving the EDM definitions into the produced +# files +add_test(edm_def_store_roundtrip_root ${CMAKE_CURRENT_LIST_DIR}/scripts/dumpModelRoundTrip.sh ${CMAKE_CURRENT_BINARY_DIR}/example_frame.root datamodel) +add_test(edm_def_store_roundtrip_root_extension ${CMAKE_CURRENT_LIST_DIR}/scripts/dumpModelRoundTrip.sh ${CMAKE_CURRENT_BINARY_DIR}/example_frame.root datamodel extension_datamodel) + +add_test(edm_def_store_roundtrip_sio ${CMAKE_CURRENT_LIST_DIR}/scripts/dumpModelRoundTrip.sh ${CMAKE_CURRENT_BINARY_DIR}/example_frame.sio datamodel) +add_test(edm_def_store_roundtrip_sio_extension ${CMAKE_CURRENT_LIST_DIR}/scripts/dumpModelRoundTrip.sh ${CMAKE_CURRENT_BINARY_DIR}/example_frame.sio datamodel extension_datamodel) + +# Need the input files that are produced by other tests +set_tests_properties( + edm_def_store_roundtrip_root + edm_def_store_roundtrip_root_extension + PROPERTIES + DEPENDS write_frame_root + ) +set_tests_properties( + edm_def_store_roundtrip_sio + edm_def_store_roundtrip_sio_extension + PROPERTIES + DEPENDS write_frame_sio + ) + +set_tests_properties( + edm_def_store_roundtrip_root + edm_def_store_roundtrip_root_extension + edm_def_store_roundtrip_sio + edm_def_store_roundtrip_sio_extension + PROPERTIES + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + ENVIRONMENT + "PODIO_BASE=${CMAKE_SOURCE_DIR};LD_LIBRARY_PATH=${CMAKE_CURRENT_BINARY_DIR}:${CMAKE_BINARY_DIR}/src:$ENV{LD_LIBRARY_PATH};PYTHONPATH=${CMAKE_SOURCE_DIR}/python:$ENV{PYTHONPATH};ROOT_INCLUDE_PATH=${CMAKE_SOURCE_DIR}/tests/datamodel:${CMAKE_SOURCE_DIR}/include:$ENV{ROOT_INCLUDE_PATH}" + + ) diff --git a/tests/scripts/dumpModelRoundTrip.sh b/tests/scripts/dumpModelRoundTrip.sh new file mode 100755 index 000000000..b4e199714 --- /dev/null +++ b/tests/scripts/dumpModelRoundTrip.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# Script to check that an EDM definition dumped from a file is "equivalent" to +# the original definition. Essentially does not check that the YAML file is the +# same, but rather that the generated code is the same + +set -eu + +INPUT_FILE=${1} # the datafile +EDM_NAME=${2} # the name of the EDM +COMP_BASE_FOLDER="" # where the source to compare against is +if [ -$# -gt 2 ]; then + COMP_BASE_FOLDER=${3} +fi + +# Create a few temporary but unique files and directories to store output +DUMPED_MODEL=${INPUT_FILE}.dumped_${EDM_NAME}.yaml +OUTPUT_FOLDER=${INPUT_FILE}.dumped_${EDM_NAME} +mkdir -p ${OUTPUT_FOLDER} + +# Dump the model to a yaml file +${PODIO_BASE}/tools/podio-dump --dump-edm ${EDM_NAME} ${INPUT_FILE} > ${DUMPED_MODEL} + +# Regenerate the code via the class generator and the freshly dumped modl +${PODIO_BASE}/python/podio_class_generator.py \ + --clangformat \ + ${DUMPED_MODEL} \ + ${OUTPUT_FOLDER} \ + ${EDM_NAME} \ + ROOT SIO + +# Compare to the originally generated code, that has been used to write the data +# file. Need to diff subfolders explitly here because $PODIO_BASE/tests contains +# more stuff +diff -ru ${OUTPUT_FOLDER}/${EDM_NAME} ${PODIO_BASE}/tests/${COMP_BASE_FOLDER}/${EDM_NAME} +diff -ru ${OUTPUT_FOLDER}/src ${PODIO_BASE}/tests/${COMP_BASE_FOLDER}/src +diff -u ${OUTPUT_FOLDER}/podio_generated_files.cmake ${PODIO_BASE}/tests/podio_generated_files.cmake