mirror of
https://github.com/nasa/fprime.git
synced 2025-12-10 17:47:10 -06:00
* Initial FprimeFramer and FprimePacketizer * Code clarity + set up UTs * Rework ComQueue and ComStub to use DataWithContext * Add packets to RefPackets.fppi * Fix ComQueue tests * Add hotfix to FileDownlink instead of ComQueue * Fix cancelPacket as well * Fix ComQueue UTs by removing hotfix * Refactor DataWithContext to use an FPP object for context instead of Fw.Buffer * Touch up testing * Add docs * more docs * More docs * Rework buffer deallocation pattern to pass-through ComQueue * Update ComStub UTs * Restore original FileDownlink.cpp * Formatting tweak * Update deprecated getSerializeRepr() calls * deserialization methods * Fix spelling * add cast for safety * CMakefile change * Bump ComQueue depth * Update RPI deployment with new Downlink stack * Rename comQueueIn port to comPktQueueIn * Fix comQueueIn to comPktQueueIn change * Remove legacy Svc.Framer * Fix CMake UTs * Fix RPI topology config * Fix FprimeProtocol.fpp module * Fix namespacing * Use const reference for FrameContext port * Review comments EXCEPT port passback refactor * Rework ComStub with new ByteStream * New ByteStream - ComInterface model * Rework TcpClient / TcpServer with new bytestream * Adapt UDP component for new ByteStream * Adapt FrameAccumulator for new ByteStream * Adapt FprimeFramer for new ByteStream * Update Ref topology with new ByteStream model * Remove all legacy deallocates from Drivers; reintroduce DEPRECATED model types * Fix spelling and include error * More spelling.... * RPI and RpiDemo fixes * Fix conversion warning on RPI * static_cast for short int on RPI * Standardize port names * Remove legacy Drv types and merge RECV/SEND enum type, delete StreamCrossover * Update SDDs * Update SDDs * Fix ComInterface <-> Framer interfaction, clarify comments and fix annotations * Switch ComStub from ASSERT to log failure and return buffer * Add history size check + clarify test handler overrides * Fix RPI topology to wire comStub on Uplink * Rename comm to comDriver in RPI topology * Update communication adapter interface docs
102 lines
4.6 KiB
C++
102 lines
4.6 KiB
C++
// ======================================================================
|
|
// \title FprimeRouterTester.cpp
|
|
// \author thomas-bc
|
|
// \brief cpp file for FprimeRouter component test harness implementation class
|
|
// ======================================================================
|
|
|
|
#include "FprimeRouterTester.hpp"
|
|
|
|
namespace Svc {
|
|
|
|
// ----------------------------------------------------------------------
|
|
// Construction and destruction
|
|
// ----------------------------------------------------------------------
|
|
|
|
FprimeRouterTester ::FprimeRouterTester(bool disconnect_unknownData_port)
|
|
: FprimeRouterGTestBase("FprimeRouterTester", FprimeRouterTester::MAX_HISTORY_SIZE), component("FprimeRouter") {
|
|
this->initComponents();
|
|
if (disconnect_unknownData_port) {
|
|
this->connectPortsExceptUnknownData(); // hand-coded function connecting all ports except unknownData
|
|
} else {
|
|
this->connectPorts(); // autocoded function connecting all ports
|
|
}
|
|
}
|
|
|
|
FprimeRouterTester ::~FprimeRouterTester() {}
|
|
|
|
// ----------------------------------------------------------------------
|
|
// Test Cases
|
|
// ----------------------------------------------------------------------
|
|
|
|
void FprimeRouterTester ::testRouteComInterface() {
|
|
this->mockReceivePacketType(Fw::ComPacket::FW_PACKET_COMMAND);
|
|
ASSERT_from_commandOut_SIZE(1); // one command packet emitted
|
|
ASSERT_from_fileOut_SIZE(0); // no file packet emitted
|
|
ASSERT_from_unknownDataOut_SIZE(0); // no unknown data emitted
|
|
ASSERT_from_bufferDeallocate_SIZE(1); // command packets are deallocated by the router
|
|
}
|
|
|
|
void FprimeRouterTester ::testRouteFileInterface() {
|
|
this->mockReceivePacketType(Fw::ComPacket::FW_PACKET_FILE);
|
|
ASSERT_from_commandOut_SIZE(0); // no command packet emitted
|
|
ASSERT_from_fileOut_SIZE(1); // one file packet emitted
|
|
ASSERT_from_unknownDataOut_SIZE(0); // no unknown data emitted
|
|
ASSERT_from_bufferDeallocate_SIZE(0); // no deallocation (file packets' ownership is transferred to the receiver)
|
|
}
|
|
|
|
void FprimeRouterTester ::testRouteUnknownPacket() {
|
|
this->mockReceivePacketType(Fw::ComPacket::FW_PACKET_UNKNOWN);
|
|
ASSERT_from_commandOut_SIZE(0); // no command packet emitted
|
|
ASSERT_from_fileOut_SIZE(0); // no file packet emitted
|
|
ASSERT_from_unknownDataOut_SIZE(1); // one unknown data emitted
|
|
ASSERT_from_bufferDeallocate_SIZE(0); // no deallocation (unknown data ownership is transferred to the receiver)
|
|
}
|
|
|
|
void FprimeRouterTester ::testRouteUnknownPacketUnconnected() {
|
|
this->mockReceivePacketType(Fw::ComPacket::FW_PACKET_UNKNOWN);
|
|
ASSERT_from_commandOut_SIZE(0); // no command packet emitted
|
|
ASSERT_from_fileOut_SIZE(0); // no file packet emitted
|
|
ASSERT_from_unknownDataOut_SIZE(0); // zero unknown data emitted
|
|
ASSERT_from_bufferDeallocate_SIZE(1); // test that buffer is deallocated when output port is not connected
|
|
}
|
|
|
|
void FprimeRouterTester ::testCommandResponse() {
|
|
const U32 opcode = 0;
|
|
const U32 cmdSeq = 0;
|
|
const Fw::CmdResponse cmdResp(Fw::CmdResponse::OK);
|
|
this->invoke_to_cmdResponseIn(0, opcode, cmdSeq, cmdResp);
|
|
ASSERT_FROM_PORT_HISTORY_SIZE(0);
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
// Test Helper
|
|
// ----------------------------------------------------------------------
|
|
|
|
void FprimeRouterTester::mockReceivePacketType(Fw::ComPacket::ComPacketType packetType) {
|
|
const FwPacketDescriptorType descriptorType = packetType;
|
|
U8 data[sizeof descriptorType];
|
|
Fw::Buffer buffer(data, sizeof(data));
|
|
ComCfg::FrameContext nullContext;
|
|
Fw::SerializeStatus status = buffer.getSerializer().serialize(descriptorType);
|
|
FW_ASSERT(status == Fw::FW_SERIALIZE_OK);
|
|
this->invoke_to_dataIn(0, buffer, nullContext);
|
|
}
|
|
|
|
void FprimeRouterTester::connectPortsExceptUnknownData() {
|
|
// Connect special output ports
|
|
this->component.set_logOut_OutputPort(0, this->get_from_logOut(0));
|
|
this->component.set_logTextOut_OutputPort(0, this->get_from_logTextOut(0));
|
|
this->component.set_timeCaller_OutputPort(0, this->get_from_timeCaller(0));
|
|
|
|
// Connect typed input ports
|
|
this->connect_to_cmdResponseIn(0, this->component.get_cmdResponseIn_InputPort(0));
|
|
this->connect_to_dataIn(0, this->component.get_dataIn_InputPort(0));
|
|
|
|
// Connect typed output ports
|
|
this->component.set_bufferDeallocate_OutputPort(0, this->get_from_bufferDeallocate(0));
|
|
this->component.set_commandOut_OutputPort(0, this->get_from_commandOut(0));
|
|
this->component.set_fileOut_OutputPort(0, this->get_from_fileOut(0));
|
|
}
|
|
|
|
} // namespace Svc
|