From 51ba08ceb51c1d2c33f02859deb05f30a364f52f Mon Sep 17 00:00:00 2001 From: Wesley Ketchum Date: Tue, 29 Oct 2024 10:26:20 +0100 Subject: [PATCH] add in unit tests to test the behavior of HSI_FRAME_STRUCT in buffer objects (lower_bound behavior, request handler behavior) --- CMakeLists.txt | 2 ++ include/hsilibs/Types.hpp | 7 +++++- unittest/HSITypeAdapters_test.cxx | 36 +++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 unittest/HSITypeAdapters_test.cxx diff --git a/CMakeLists.txt b/CMakeLists.txt index 85f455a..5d7e393 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,5 +62,7 @@ daq_add_plugin(HSIController duneDAQModule LINK_LIBRARIES hsilibs timing::timing ############################################################################## +daq_add_unit_test(HSITypeAdapters_test LINK_LIBRARIES hsilibs ${BOOST_LIBS}) + ############################################################################## daq_install() diff --git a/include/hsilibs/Types.hpp b/include/hsilibs/Types.hpp index a27347c..aee2cf8 100644 --- a/include/hsilibs/Types.hpp +++ b/include/hsilibs/Types.hpp @@ -55,6 +55,11 @@ class HSI_FRAME_STRUCT frame.set_timestamp(ts); } + void fake_timestamps(uint64_t first_timestamp, uint64_t /*offset*/= 0 ) // NOLINT(build/unsigned) + { + frame.set_timestamp(first_timestamp); + } + FrameType* begin() { return this; } FrameType* end() { return (this + 1); } // NOLINT @@ -68,7 +73,7 @@ class HSI_FRAME_STRUCT static const constexpr daqdataformats::SourceID::Subsystem subsystem = daqdataformats::SourceID::Subsystem::kHwSignalsInterface; static const constexpr daqdataformats::FragmentType fragment_type = daqdataformats::FragmentType::kHardwareSignal; - static const constexpr uint64_t expected_tick_difference = 0; // NOLINT(build/unsigned) + static const constexpr uint64_t expected_tick_difference = 1; // NOLINT(build/unsigned) }; static_assert(sizeof(struct HSI_FRAME_STRUCT) == HSI_FRAME_STRUCT_SIZE, diff --git a/unittest/HSITypeAdapters_test.cxx b/unittest/HSITypeAdapters_test.cxx new file mode 100644 index 0000000..ea20c49 --- /dev/null +++ b/unittest/HSITypeAdapters_test.cxx @@ -0,0 +1,36 @@ +/** + * @file HSITypeAdapters_test.cxx + * + * Unittest for testing lower bound and request handling on HSI_FRAME_STRUCT + * + * 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 HSITypeAdapters_test // NOLINT + +#include "hsilibs/Types.hpp" + +#include "datahandlinglibs/testutils/TestUtilities.hpp" +#include "datahandlinglibs/models/BinarySearchQueueModel.hpp" + +#include "boost/test/unit_test.hpp" + +BOOST_AUTO_TEST_SUITE(HSITypeAdapters_test) + +BOOST_AUTO_TEST_CASE(TBinarySearchQueueModel_HSI_FRAME_STRUCT_TestQueue) +{ + dunedaq::datahandlinglibs::test::test_queue_model< + dunedaq::datahandlinglibs::BinarySearchQueueModel, + dunedaq::hsilibs::HSI_FRAME_STRUCT>(); +} +BOOST_AUTO_TEST_CASE(TBinarySearchQueueModel_HSI_FRAME_STRUCT_TestRequest) +{ + dunedaq::datahandlinglibs::test::test_request_model< + dunedaq::datahandlinglibs::BinarySearchQueueModel, + dunedaq::hsilibs::HSI_FRAME_STRUCT>(); +} +BOOST_AUTO_TEST_SUITE_END() + +