4#include <gtest/gtest.h>
17 [[nodiscard]]
auto get_error_msg() const -> const auto& {
return error_msg_; }
18 [[nodiscard]]
auto get_event_nums() const -> const auto& {
return event_nums_; }
20 void run(
const std::vector<std::string>& output_filenames)
25 auto app = srs::App{};
27 app.set_fec_data_receiv_port(0);
28 app.set_output_filenames(output_filenames);
32 auto* data_reader = app.get_data_reader();
33 auto port_num = data_reader->get_local_port_number();
34 auto emulator = srs::test::SRSEmulator{
"test_data.bin", port_num, app };
36 auto analysis_thread = std::jthread(
39 app.start_workflow(
false);
40 event_nums_ = app.get_workflow_handler().get_processed_hit_number();
44 emulator.start_send_data();
45 error_msg_ = app.get_error_string();
47 catch (std::exception& err)
49 spdlog::critical(
"Exception occurred: {}", err.what());
54 std::string error_msg_;
55 uint64_t event_nums_ = 0;
58 namespace fs = std::filesystem;
60 auto check_if_file_exist(
const std::string& filename) ->
bool
62 auto file_path = fs::path{ filename };
63 return fs::exists(file_path);
68TEST(integration_test_outputfiles, binary_output)
70 const auto filename = std::string{
"test_output.bin" };
72 auto runner = Runner{};
73 ASSERT_NO_THROW(runner.run(std::vector{ filename }));
74 EXPECT_EQ(runner.get_error_msg(),
"");
75 EXPECT_EQ(runner.get_event_nums(), 0);
77 auto res = check_if_file_exist(filename);
81TEST(integration_test_outputfiles, root_output)
83 const auto filename = std::string{
"test_output.root" };
85 auto runner = Runner{};
86 ASSERT_NO_THROW(runner.run(std::vector{ filename }));
87 EXPECT_EQ(runner.get_error_msg(),
"");
88 EXPECT_GT(runner.get_event_nums(), 0);
90 auto res = check_if_file_exist(filename);
98TEST(integration_test_outputfiles, proto_binary_output)
100 const auto filename = std::string{
"test_output.binpb" };
102 auto runner = Runner{};
103 ASSERT_NO_THROW(runner.run(std::vector{ filename }));
104 EXPECT_EQ(runner.get_error_msg(),
"");
105 EXPECT_GT(runner.get_event_nums(), 0);
107 auto res = check_if_file_exist(filename);
111TEST(integration_test_outputfiles, json_output)
113 const auto filename = std::string{
"test_output.json" };
115 auto runner = Runner{};
116 ASSERT_NO_THROW(runner.run(std::vector{ filename }));
117 EXPECT_EQ(runner.get_error_msg(),
"");
118 EXPECT_GT(runner.get_event_nums(), 0);
120 auto res = check_if_file_exist(filename);
128TEST(integration_test_outputfiles, all_outputs)
130 const auto filenames = std::vector<std::string>{
131 "test_output1.bin",
"test_output2.bin",
"test_output1.json",
"test_output1.root",
"test_output1.binpb"
134 auto runner = Runner{};
135 ASSERT_NO_THROW(runner.run(filenames));
136 EXPECT_EQ(runner.get_error_msg(),
"");
137 EXPECT_GT(runner.get_event_nums(), 0);
139 for (
const auto& filename : filenames)
141 auto res = check_if_file_exist(filename);
142 if (filename ==
"test_output1.root")
TEST(integration_test_outputfiles, binary_output)