From 888b698aac1a9898ae76484e7a6038c690d97d20 Mon Sep 17 00:00:00 2001 From: tmadlener Date: Tue, 25 Jul 2023 15:21:43 +0200 Subject: [PATCH] Add a test case show-casing the failure --- tests/read_and_write_frame.h | 36 +++++++++++++++++++++ tests/root_io/CMakeLists.txt | 13 ++++++-- tests/root_io/read_and_write_frame_root.cpp | 9 ++++++ 3 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 tests/read_and_write_frame.h create mode 100644 tests/root_io/read_and_write_frame_root.cpp diff --git a/tests/read_and_write_frame.h b/tests/read_and_write_frame.h new file mode 100644 index 000000000..7c6e6ae12 --- /dev/null +++ b/tests/read_and_write_frame.h @@ -0,0 +1,36 @@ +#ifndef PODIO_TESTS_READ_AND_WRITE_FRAME_H // NOLINT(llvm-header-guard): folder structure not suitable +#define PODIO_TESTS_READ_AND_WRITE_FRAME_H // NOLINT(llvm-header-guard): folder structure not suitable + +#include "read_frame.h" + +#include + +template +int rewrite_frames(const std::string& inputFile, const std::string& newOutput) { + auto reader = ReaderT(); + reader.openFile(inputFile); + + auto writer = WriterT(newOutput); + + const auto frame = podio::Frame(reader.readEntry(podio::Category::Event, 0)); + writer.writeFrame(frame, podio::Category::Event); + + const auto otherFrame = podio::Frame(reader.readEntry("other_events", 0)); + writer.writeFrame(otherFrame, "other_events"); + + return 0; +} + +template +int read_rewritten_frames(const std::string& inputName) { + auto reader = ReaderT(); + reader.openFile(inputName); + + const auto frame = podio::Frame(reader.readEntry(podio::Category::Event, 0)); + + processEvent(frame, 0, reader.currentFileVersion()); + + return 0; +} + +#endif // PODIO_TESTS_READ_AND_WRITE_FRAME_H diff --git a/tests/root_io/CMakeLists.txt b/tests/root_io/CMakeLists.txt index 5c867a9fe..509749643 100644 --- a/tests/root_io/CMakeLists.txt +++ b/tests/root_io/CMakeLists.txt @@ -12,6 +12,7 @@ set(root_dependent_tests read_frame_legacy_root.cpp read_frame_root_multiple.cpp read_python_frame_root.cpp + read_and_write_frame_root.cpp ) if(ENABLE_RNTUPLE) set(root_dependent_tests @@ -33,8 +34,16 @@ set_property(TEST read-multiple PROPERTY DEPENDS write) set_property(TEST read_and_write PROPERTY DEPENDS write) set_property(TEST read_frame_legacy_root PROPERTY DEPENDS write) set_property(TEST read_timed PROPERTY DEPENDS write_timed) -set_property(TEST read_frame_root PROPERTY DEPENDS write_frame_root) -set_property(TEST read_frame_root_multiple PROPERTY DEPENDS write_frame_root) + +set_tests_properties( + read_frame_root + read_frame_root_multiple + read_and_write_frame_root + + PROPERTIES + DEPENDS write_frame_root +) + if(ENABLE_RNTUPLE) set_property(TEST read_rntuple PROPERTY DEPENDS write_rntuple) endif() diff --git a/tests/root_io/read_and_write_frame_root.cpp b/tests/root_io/read_and_write_frame_root.cpp new file mode 100644 index 000000000..c25840289 --- /dev/null +++ b/tests/root_io/read_and_write_frame_root.cpp @@ -0,0 +1,9 @@ +#include "read_and_write_frame.h" + +#include "podio/ROOTFrameReader.h" +#include "podio/ROOTFrameWriter.h" + +int main() { + return rewrite_frames("example_frame.root", "rewritten_frame.root") + + read_rewritten_frames("rewritten_frame.root"); +}