fprime/Drv/Udp/test/ut/UdpTester.hpp
Thomas Boyer-Chammard d0246f148b
Add Framer FPP interface, implement FprimeFramer and adapt ComQueue (#3486)
* 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
2025-04-29 16:40:36 -07:00

130 lines
3.5 KiB
C++

// ======================================================================
// \title TcpClient/test/ut/Tester.hpp
// \author mstarch
// \brief hpp file for ByteStreamDriverModel test harness implementation class
//
// \copyright
// Copyright 2009-2015, by the California Institute of Technology.
// ALL RIGHTS RESERVED. United States Government Sponsorship
// acknowledged.
//
// ======================================================================
#ifndef TESTER_HPP
#define TESTER_HPP
#include "UdpGTestBase.hpp"
#include "Drv/Udp/UdpComponentImpl.hpp"
#include "Drv/Ip/TcpServerSocket.hpp"
#define SEND_DATA_BUFFER_SIZE 1024
namespace Drv {
class UdpTester :
public UdpGTestBase
{
// Maximum size of histories storing events, telemetry, and port outputs
static const U32 MAX_HISTORY_SIZE = 1000;
// Instance ID supplied to the component instance under test
static const FwEnumStoreType TEST_INSTANCE_ID = 0;
// Queue depth supplied to component instance under test
static const FwSizeType TEST_INSTANCE_QUEUE_DEPTH = 100;
// ----------------------------------------------------------------------
// Construction and destruction
// ----------------------------------------------------------------------
public:
//! Construct object UdpTester
//!
UdpTester();
void initSetup();
//! Destroy object UdpTester
//!
~UdpTester();
public:
// ----------------------------------------------------------------------
// Tests
// ----------------------------------------------------------------------
//! Test basic messaging
//!
void test_basic_messaging();
//! Test basic reconnection behavior
//!
void test_multiple_messaging();
//! Test receive via thread
//!
void test_receive_thread();
//! Test advanced (duration) reconnect
//!
void test_advanced_reconnect();
// Helpers
void test_with_loop(U32 iterations, bool recv_thread=false);
bool wait_on_change(Drv::IpSocket &socket, bool open, U32 iterations);
private:
// ----------------------------------------------------------------------
// Handler overrides for typed from ports
// ----------------------------------------------------------------------
//! Handler for from_recv
//!
void from_recv_handler(
const FwIndexType portNum, /*!< The port number*/
Fw::Buffer &recvBuffer,
const ByteStreamStatus &recvStatus
) override;
//! Handler for from_allocate
//!
Fw::Buffer from_allocate_handler(
const FwIndexType portNum, /*!< The port number*/
U32 size
) override;
private:
// ----------------------------------------------------------------------
// Helper methods
// ----------------------------------------------------------------------
//! Connect ports
//!
void connectPorts();
//! Initialize components
//!
void initComponents();
private:
// ----------------------------------------------------------------------
// Variables
// ----------------------------------------------------------------------
//! The component under test
//!
UdpComponentImpl component;
Fw::Buffer m_data_buffer;
Fw::Buffer m_data_buffer2;
U8 m_data_storage[SEND_DATA_BUFFER_SIZE];
std::atomic<bool> m_spinner;
};
} // end namespace Drv
#endif