Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit Tests for trigger object behavior in buffers/requests #353

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ daq_add_application( generate_tpset_from_hdf5 generate_tpset_from_hdf5.cxx TEST
#daq_add_unit_test(TriggerZipper_test LINK_LIBRARIES trigger)
#daq_add_unit_test(TriggerObjectOverlay_test LINK_LIBRARIES trigger)
#daq_add_unit_test(AlgorithmPlugins_test LINK_LIBRARIES trigger)
daq_add_unit_test(TriggerTypeAdapters_test LINK_LIBRARIES trigger)

##############################################################################

Expand Down
14 changes: 11 additions & 3 deletions include/trigger/TAWrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,21 @@
#include "triggeralgs/TriggerObjectOverlay.hpp"
#include "triggeralgs/TriggerPrimitive.hpp"
#include "triggeralgs/TriggerActivity.hpp"
#include "trigger/Issues.hpp"

namespace dunedaq {
namespace trigger {
struct TAWrapper
{

using FrameType = TAWrapper;

triggeralgs::TriggerActivity activity;
std::vector<uint8_t> activity_overlay_buffer;

// Don't really want this default ctor, but IterableQueueModel requires it
TAWrapper() {}
//TAWrapper() {}

TAWrapper(triggeralgs::TriggerActivity a)
TAWrapper(triggeralgs::TriggerActivity a = triggeralgs::TriggerActivity())
: activity(a)
{
populate_buffer();
Expand Down Expand Up @@ -54,6 +56,12 @@ namespace trigger {
activity.time_start = ts;
}

void fake_timestamps(uint64_t first_timestamp, uint64_t /*offset */ = 0) // NOLINT(build/unsigned)
{
activity.time_start = first_timestamp;
populate_buffer();
}

size_t get_payload_size() { return activity_overlay_buffer.size(); }

size_t get_num_frames() { return 1; }
Expand Down
12 changes: 9 additions & 3 deletions include/trigger/TCWrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@
#include "triggeralgs/TriggerObjectOverlay.hpp"
#include "triggeralgs/TriggerActivity.hpp"
#include "triggeralgs/TriggerCandidate.hpp"
#include "trigger/Issues.hpp"

namespace dunedaq {
namespace trigger {
struct TCWrapper
{
using FrameType = TCWrapper;
triggeralgs::TriggerCandidate candidate;
std::vector<uint8_t> candidate_overlay_buffer;
// Don't really want this default ctor, but IterableQueueModel requires it
TCWrapper() {}
//TCWrapper() {}

TCWrapper(triggeralgs::TriggerCandidate c)
TCWrapper(triggeralgs::TriggerCandidate c = triggeralgs::TriggerCandidate())
: candidate(c)
{
populate_buffer();
Expand Down Expand Up @@ -53,6 +53,12 @@ namespace trigger {
candidate.time_start = ts;
}

void fake_timestamps(uint64_t first_timestamp, uint64_t /*offset */ = 0) // NOLINT(build/unsigned)
{
candidate.time_start = first_timestamp;
populate_buffer();
}

size_t get_payload_size() { return candidate_overlay_buffer.size(); }

size_t get_num_frames() { return 1; }
Expand Down
2 changes: 1 addition & 1 deletion include/trigger/TriggerPrimitiveTypeAdapter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct TriggerPrimitiveTypeAdapter
tp.time_start = ts;
}

void fake_timestamps(uint64_t first_timestamp, uint64_t /*offset = 25*/) // NOLINT(build/unsigned)
void fake_timestamps(uint64_t first_timestamp, uint64_t /*offset */ = 0) // NOLINT(build/unsigned)
{
tp.time_start = first_timestamp;
}
Expand Down
64 changes: 64 additions & 0 deletions unittest/TriggerTypeAdapters_test.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/**
* @file TriggerTypeAdapters_test.cxx
*
* Unittest for testing lower bound and request handling on trigger type adapters/wrappers.
*
* This is part of the DUNE DAQ Application Framework, copyright 2022.
* Licensing/copyright details are in the COPYING file that you should have
* received with this code.
*/

#define BOOST_TEST_MODULE TriggerTypeAdapters_test // NOLINT

#include "trigger/TriggerPrimitiveTypeAdapter.hpp"
#include "trigger/TAWrapper.hpp"
#include "trigger/TCWrapper.hpp"

#include "datahandlinglibs/testutils/TestUtilities.hpp"
#include "datahandlinglibs/models/SkipListLatencyBufferModel.hpp"

#include "boost/test/unit_test.hpp"

BOOST_AUTO_TEST_SUITE(TriggerTypeAdapters_test)

BOOST_AUTO_TEST_CASE(SkipListLatencyBufferModel_TriggerPrimitiveTypeAdapter_TestQueue)
{
dunedaq::datahandlinglibs::test::test_queue_model<
dunedaq::datahandlinglibs::SkipListLatencyBufferModel,
dunedaq::trigger::TriggerPrimitiveTypeAdapter>();
}
BOOST_AUTO_TEST_CASE(SkipListLatencyBufferModel_TriggerPrimitiveTypeAdapter_TestRequest)
{
dunedaq::datahandlinglibs::test::test_request_model<
dunedaq::datahandlinglibs::SkipListLatencyBufferModel,
dunedaq::trigger::TriggerPrimitiveTypeAdapter>();
}

BOOST_AUTO_TEST_CASE(SkipListLatencyBufferModel_TAWrapper_TestQueue)
{
dunedaq::datahandlinglibs::test::test_queue_model<
dunedaq::datahandlinglibs::SkipListLatencyBufferModel,
dunedaq::trigger::TAWrapper>();
}
BOOST_AUTO_TEST_CASE(SkipListLatencyBufferModel_TAWrapper_TestRequest)
{
dunedaq::datahandlinglibs::test::test_request_model<
dunedaq::datahandlinglibs::SkipListLatencyBufferModel,
dunedaq::trigger::TAWrapper>();
}

BOOST_AUTO_TEST_CASE(SkipListLatencyBufferModel_TCWrapper_TestQueue)
{
dunedaq::datahandlinglibs::test::test_queue_model<
dunedaq::datahandlinglibs::SkipListLatencyBufferModel,
dunedaq::trigger::TCWrapper>();
}
BOOST_AUTO_TEST_CASE(SkipListLatencyBufferModel_TCWrapper_TestRequest)
{
dunedaq::datahandlinglibs::test::test_request_model<
dunedaq::datahandlinglibs::SkipListLatencyBufferModel,
dunedaq::trigger::TCWrapper>();
}
BOOST_AUTO_TEST_SUITE_END()


Loading