Skip to content

Commit

Permalink
Add tests for timed SIO reading/writing
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadlener committed Dec 9, 2020
1 parent a488614 commit 959817a
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 7 deletions.
26 changes: 19 additions & 7 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,37 @@ endforeach()


if (TARGET TestDataModelSioBlocks)
set(sio_dependent_tests write_sio.cpp read_sio.cpp read_and_write_sio.cpp)
set(sio_dependent_tests write_sio.cpp read_sio.cpp read_and_write_sio.cpp write_timed_sio.cpp read_timed_sio.cpp)
set(sio_libs podio::podioSioIO)
foreach( sourcefile ${sio_dependent_tests} )
CREATE_PODIO_TEST(${sourcefile} "${sio_libs}")
endforeach()

# These need to be linked against TTree explicitly, since it is not done
# through another library and the TimedReader/Writer decorators are
# header-only wrappers
target_link_libraries(write_timed_sio ROOT::Tree)
target_link_libraries(read_timed_sio ROOT::Tree)
endif()


#--- set some dependencies between the different tests to ensure input generating ones are run first
set_property(TEST read PROPERTY DEPENDS write)
set_property(TEST read-multiple PROPERTY DEPENDS write)
set_property(TEST read_timed PROPERTY DEPENDS write_timed)

add_executable(check_benchmark_outputs check_benchmark_outputs.cpp)
target_link_libraries(check_benchmark_outputs ROOT::Tree)

add_test(NAME check_benchmark_outputs COMMAND check_benchmark_outputs write_benchmark_root.root read_benchmark_root.root)
set_property(TEST check_benchmark_outputs PROPERTY DEPENDS read_timed write_timed)

if (TARGET read_sio)
set_property(TEST read_sio PROPERTY DEPENDS write_sio)
set_property(TEST read_timed_sio PROPERTY DEPENDS write_timed_sio)

add_test(NAME check_benchmark_outputs_sio COMMAND check_benchmark_outputs write_benchmark_sio.root read_benchmark_sio.root)
set_property(TEST check_benchmark_outputs_sio PROPERTY DEPENDS read_timed_sio write_timed_sio)
endif()

add_test( NAME pyunittest COMMAND python -m unittest discover -s ${CMAKE_SOURCE_DIR}/python)
Expand All @@ -61,9 +79,3 @@ set_property(TEST pyunittest
PYTHONPATH=${CMAKE_SOURCE_DIR}/python:$ENV{PYTHONPATH}
ROOT_INCLUDE_PATH=${CMAKE_SOURCE_DIR}/tests/datamodel:${ROOT_INCLUDE_PATH})
set_property(TEST pyunittest PROPERTY DEPENDS write)

add_executable(check_benchmark_outputs check_benchmark_outputs.cpp)
target_link_libraries(check_benchmark_outputs ROOT::Tree)

add_test(NAME check_benchmark_outputs COMMAND check_benchmark_outputs write_benchmark_root.root read_benchmark_root.root)
set_property(TEST check_benchmark_outputs PROPERTY DEPENDS read_timed write_timed)
16 changes: 16 additions & 0 deletions tests/read_timed_sio.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include "read_test.h"
#include "podio/SIOReader.h"
#include "podio/TimedReader.h"
#include "podio/BenchmarkRecorder.h"

int main() {
podio::benchmark::BenchmarkRecorder recorder("read_benchmark_sio.root");

podio::TimedReader<podio::SIOReader> reader(recorder);
reader.openFile("example_timed.sio");

run_read_test(reader);

reader.closeFile();
return 0;
}
15 changes: 15 additions & 0 deletions tests/write_timed_sio.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "write_test.h"
#include "podio/SIOWriter.h"
#include "podio/EventStore.h"
#include "podio/TimedWriter.h"
#include "podio/BenchmarkRecorder.h"

int main() {
podio::benchmark::BenchmarkRecorder recorder("write_benchmark_sio.root");
podio::EventStore store;
podio::TimedWriter<podio::SIOWriter> writer(recorder, "example_timed.sio", &store);

write(store, writer);

return 0;
}

0 comments on commit 959817a

Please sign in to comment.