#ifndef TESTCOMMON_H #define TESTCOMMON_H #include "BasicUDPSocket.h" #include "CompilerTypes.h" #include "StreamString.h" namespace MARTe { extern const char8 * const debug_test_config; bool SendCommandGAM(uint16 port, const char8* cmd, StreamString &reply); void TestMessageCommand(); /** * @brief Reads DebugService trace telemetry off @p sock until a real * UDPS DATA packet (Common/UDP/UDPSProtocol.h) is decoded or * @p overallTimeoutMs elapses, and extracts the value of the first * (and, for these single-signal integration tests, only) traced * signal — a scalar at wire offset 0, right after the 8-byte HRT * timestamp that opens every DATA payload. * * DebugService's real UDP telemetry (DebugService::Streamer) speaks the * shared UDPS protocol, not the legacy TraceHeader format declared in * DebugCore.h (that struct is now dead code, kept only for historical * reference) — callers must not reinterpret raw datagrams as * TraceHeader. CONFIG packets (sent once when the traced-signal set * changes) are silently skipped so callers don't need to special-case * them. * * @param sock DebugService's StreamPort/UdpPort listener, already Open()+Listen()ed. * @param overallTimeoutMs total time budget across all read attempts. * @param value output: the decoded scalar value. * @return true if a DATA packet was decoded within the budget. */ bool ReadUDPSTraceScalar(BasicUDPSocket &sock, uint32 overallTimeoutMs, uint32 &value); /** * @brief Grows the OS receive buffer (SO_RCVBUF) on an already-Open()ed * UDP socket. * * BasicUDPSocket never touches SO_RCVBUF, so listeners are left at the * Linux default (net.core.rmem_default, ~208 KiB on most systems). At * sustained 1 kHz+ trace rates a single scheduling delay in the test * process (e.g. a printf, a GC pass, or just being descheduled) is * enough to overflow that default buffer, causing silent kernel-level * datagram drops (visible as RcvbufErrors in /proc/net/snmp) that show * up as false "discontinuities" even though DebugService sent every * sample. UDPSClient already works around this for production code * (UDPSClient::SetRecvBufferSize); integration tests that Listen() * directly on a raw BasicUDPSocket need the same treatment. * * Best-effort: a failure here just leaves the OS default in place. */ void GrowUDPRecvBuffer(BasicUDPSocket &sock, uint32 bytes = 4194304u); } #endif