fprime/Svc/DpWriter/test/ut/DpWriterTester.hpp
Rob Bocchino b89b5d91c4
Add DpWriter (#2593)
* Pull in framework changes from data-products branch

* Pull in changes to DpManager from data-products branch

* Pull in DpWriter from data-products branch

* Fix spelling

* Revise FileNameString

* Fix warnings in CI

* Fix static analysis warnings

* Fix static analysis warnings

* Revise formatting and comments

* Revise banner comments

* Revise FileNameString per PR comment

* Revise path names in config headers

If a header H.hpp exists in the F Prime source base, then

is dangerous. Because [project root] and [fprime root] are both
in the list of include paths, it's not clear whether this means "include
[project root]/config/H.hpp" or "include [fprime root]/config/H.hpp."

On the other hand,

or

has no such ambiguity, because only one of [project root]/config
and [fprime root]/config is in the list of include paths.

* Revise path names in config headers

If a header H.hpp exists in the F Prime source base, then

`#include "config/H.hpp"`

is dangerous. Because [project root] and [fprime root] are both
in the list of include paths, it's not clear whether this means "include
[project root]/config/H.hpp" or "include [fprime root]/config/H.hpp."

On the other hand,

include <config/H.hpp>

or

`#include "config/H.hpp"`

has no such ambiguity, because only one of [project root]/config
and [fprime root]/config is in the list of include paths.
2024-03-28 16:09:38 -07:00

120 lines
4.2 KiB
C++

// ======================================================================
// \title DpWriterTester.hpp
// \author bocchino
// \brief hpp file for DpWriter component test harness implementation class
// ======================================================================
#ifndef Svc_DpWriterTester_HPP
#define Svc_DpWriterTester_HPP
#include "Svc/DpWriter/DpWriter.hpp"
#include "Svc/DpWriter/DpWriterGTestBase.hpp"
#include "Svc/DpWriter/test/ut/AbstractState.hpp"
namespace Svc {
class DpWriterTester : public DpWriterGTestBase {
public:
// ----------------------------------------------------------------------
// Constants
// ----------------------------------------------------------------------
// Maximum size of histories storing events, telemetry, and port outputs
static const NATIVE_INT_TYPE MAX_HISTORY_SIZE = 10;
// Instance ID supplied to the component instance under test
static const NATIVE_INT_TYPE TEST_INSTANCE_ID = 0;
// Queue depth supplied to the component instance under test
static const NATIVE_INT_TYPE TEST_INSTANCE_QUEUE_DEPTH = 10;
public:
// ----------------------------------------------------------------------
// Construction and destruction
// ----------------------------------------------------------------------
//! Construct object DpWriterTester
DpWriterTester();
//! Destroy object DpWriterTester
~DpWriterTester();
private:
// ----------------------------------------------------------------------
// Handlers for typed from ports
// ----------------------------------------------------------------------
//! Handler implementation for deallocBufferSendOut
void from_deallocBufferSendOut_handler(NATIVE_INT_TYPE portNum, //!< The port number
Fw::Buffer& fwBuffer //!< The buffer
);
//! Handler implementation for dpWrittenOut
void from_dpWrittenOut_handler(NATIVE_INT_TYPE portNum, //!< The port number
const Svc::DpWrittenPortStrings::StringSize256& fileName, //!< The file name
FwDpPriorityType priority, //!< The priority
FwSizeType size //!< The file size
);
//! Handler implementation for procBufferSendOut
void from_procBufferSendOut_handler(NATIVE_INT_TYPE portNum, //!< The port number
Fw::Buffer& fwBuffer //!< The buffer
);
public:
// ----------------------------------------------------------------------
// Public member functions
// ----------------------------------------------------------------------
//! Print events
void printEvents();
protected:
// ----------------------------------------------------------------------
// Protected helper functions
// ----------------------------------------------------------------------
//! Pick an Os status other than OP_OK
//! \return The status
static Os::File::Status pickOsFileError();
//! Construct a DP file name
static void constructDpFileName(FwDpIdType id, //!< The container ID (input)
const Fw::Time& timeTag, //!< The time tag (input)
Fw::StringBase& fileName //!< The file name (output)
);
//! Check processing types
void checkProcTypes(const Fw::DpContainer& container //!< The container
);
//! Check telemetry
void checkTelemetry();
private:
// ----------------------------------------------------------------------
// Private helper functions
// ----------------------------------------------------------------------
//! Connect ports
void connectPorts();
//! Initialize components
void initComponents();
protected:
// ----------------------------------------------------------------------
// Member variables
// ----------------------------------------------------------------------
//! The abstract state for testing
AbstractState abstractState;
//! The component under test
DpWriter component;
};
} // namespace Svc
#endif