Skip to content

Commit

Permalink
add in unit tests to test the behavior of HSI_FRAME_STRUCT in buffer …
Browse files Browse the repository at this point in the history
…objects (lower_bound behavior, request handler behavior)
  • Loading branch information
wesketchum committed Oct 29, 2024
1 parent d6f1af8 commit 51ba08c
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
7 changes: 6 additions & 1 deletion include/hsilibs/Types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down
36 changes: 36 additions & 0 deletions unittest/HSITypeAdapters_test.cxx
Original file line number Diff line number Diff line change
@@ -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()


0 comments on commit 51ba08c

Please sign in to comment.