GCC Code Coverage Report


Directory: ./
File: Svc/Ccsds/SdlsSaRouter/SdlsSaRouter.cpp
Date: 2026-09-03 21:13:48
Exec Total Coverage
Lines: 50 50 100.0%
Functions: 6 6 100.0%
Branches: 47 49 95.9%

Line Branch Exec Source
1 // ======================================================================
2 // \title SdlsSaRouter.cpp
3 // \author lestarch-autobot
4 // \brief cpp file for SdlsSaRouter component implementation class
5 // ======================================================================
6
7 #include "Svc/Ccsds/SdlsSaRouter/SdlsSaRouter.hpp"
8
9 namespace Svc {
10
11 namespace Ccsds {
12
13 // ----------------------------------------------------------------------
14 // Component construction and destruction
15 // ----------------------------------------------------------------------
16
17
2/2
✓ Branch 10 taken 9 times.
✓ Branch 16 taken 9 times.
9 SdlsSaRouter ::SdlsSaRouter(const char* const compName) : SdlsSaRouterComponentBase(compName) {
18 // Load the compile-time SA-to-port map from configuration
19
1/1
✓ Branch 2 taken 9 times.
9 const SdlsCfg::SaMap saMap;
20
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 9 times.
27 for (SdlsCfg::SaMap::SizeType i = 0; i < SdlsCfg::SaMap::SIZE; i++) {
21 18 const Fw::Success status =
22
3/3
✓ Branch 5 taken 18 times.
✓ Branch 15 taken 18 times.
✓ Branch 23 taken 18 times.
18 this->m_saMap.insert(saMap[i].get_securityAssociationIndex(), saMap[i].get_portIndex());
23 18 FW_ASSERT(status == Fw::Success::SUCCESS, static_cast<FwAssertArgType>(i));
24 18 }
25 18 }
26
27 18 SdlsSaRouter ::~SdlsSaRouter() {}
28
29 // ----------------------------------------------------------------------
30 // Handler implementations for typed input ports
31 // ----------------------------------------------------------------------
32
33 4242 void SdlsSaRouter ::dataIn_handler(FwIndexType portNum,
34 U16 securityAssociationIndex,
35 Fw::Buffer& data,
36 const ComCfg::FrameContext& context) {
37 4242 FwIndexType outputPort = 0;
38
1/1
✓ Branch 4 taken 4242 times.
4242 const Fw::Success found = this->m_saMap.find(securityAssociationIndex, outputPort);
39
1/1
✓ Branch 2 taken 4242 times.
4242 Svc::Ccsds::SdlsStatus errorStatus = Svc::Ccsds::SdlsStatus::UNKNOWN_SA;
40
2/2
✓ Branch 2 taken 3410 times.
✓ Branch 3 taken 832 times.
4242 if (found == Fw::Success::SUCCESS) {
41
4/6
✓ Branch 0 taken 3410 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 3410 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2560 times.
✓ Branch 6 taken 850 times.
6820 if ((outputPort >= 0) && (outputPort < this->getNum_saDataOut_OutputPorts()) &&
42
3/3
✓ Branch 5 taken 3410 times.
✓ Branch 7 taken 2560 times.
✓ Branch 8 taken 850 times.
3410 (this->isConnected_saDataOut_OutputPort(outputPort))) {
43
1/1
✓ Branch 5 taken 2560 times.
2560 this->saDataOut_out(outputPort, securityAssociationIndex, data, context);
44 2560 return;
45 }
46
1/1
✓ Branch 2 taken 850 times.
850 errorStatus = Svc::Ccsds::SdlsStatus::UNKNOWN_PORT;
47 }
48 // Routing failed: pass the error status forward with the untouched buffer, tracking it
49 // so the eventual ownership return routes back upstream via bufferReturnOut
50 1682 const Fw::Success inserted =
51
2/2
✓ Branch 9 taken 1682 times.
✓ Branch 13 taken 1682 times.
1682 this->m_outstanding.insert(data.getContext(), static_cast<FwIndexType>(ROUTER_ERROR_PORT));
52
2/2
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1681 times.
1682 if (inserted != Fw::Success::SUCCESS) {
53 // Tracking table full: drop the request and return the buffer upstream immediately
54
1/1
✓ Branch 5 taken 1 times.
1 this->log_WARNING_HI_TrackingTableFull();
55
1/1
✓ Branch 5 taken 1 times.
1 this->bufferReturnOut_out(0, data, context);
56 1 return;
57 }
58
1/1
✓ Branch 5 taken 1681 times.
1681 this->dataOut_out(0, errorStatus, data, context);
59 6804 }
60
61 2503 void SdlsSaRouter ::dataReturnIn_handler(FwIndexType portNum, Fw::Buffer& data, const ComCfg::FrameContext& context) {
62 2503 FwIndexType outputPort = 0;
63
2/2
✓ Branch 8 taken 2503 times.
✓ Branch 12 taken 2503 times.
2503 const Fw::Success found = this->m_outstanding.find(data.getContext(), outputPort);
64
2/2
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2502 times.
2503 if (found != Fw::Success::SUCCESS) {
65 // Untracked buffer (e.g. lost to a context-key collision): return it upstream
66
1/1
✓ Branch 5 taken 1 times.
1 this->log_WARNING_HI_UntrackedBufferReturned();
67
1/1
✓ Branch 5 taken 1 times.
1 this->bufferReturnOut_out(0, data, context);
68 1 return;
69 }
70
2/2
✓ Branch 8 taken 2502 times.
✓ Branch 12 taken 2502 times.
2502 (void)this->m_outstanding.remove(data.getContext(), outputPort);
71
2/2
✓ Branch 0 taken 1678 times.
✓ Branch 1 taken 824 times.
2502 if (outputPort == ROUTER_ERROR_PORT) {
72 // Buffer was forwarded by the router itself on a routing error: return it upstream
73
1/1
✓ Branch 5 taken 1678 times.
1678 this->bufferReturnOut_out(0, data, context);
74 } else {
75
1/1
✓ Branch 5 taken 824 times.
824 this->saDataReturnOut_out(outputPort, data, context);
76 }
77 2503 }
78
79 2441 void SdlsSaRouter ::saBufferReturnIn_handler(FwIndexType portNum,
80 Fw::Buffer& data,
81 const ComCfg::FrameContext& context) {
82 2441 this->bufferReturnOut_out(0, data, context);
83 2441 }
84
85 835 void SdlsSaRouter ::saDataIn_handler(FwIndexType portNum,
86 const Svc::Ccsds::SdlsStatus& status,
87 Fw::Buffer& data,
88 const ComCfg::FrameContext& context) {
89
2/2
✓ Branch 8 taken 835 times.
✓ Branch 12 taken 835 times.
835 const Fw::Success inserted = this->m_outstanding.insert(data.getContext(), portNum);
90
2/2
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 834 times.
835 if (inserted != Fw::Success::SUCCESS) {
91 // Tracking table full: drop the data and return ownership to the downstream component
92
1/1
✓ Branch 5 taken 1 times.
1 this->log_WARNING_HI_TrackingTableFull();
93
1/1
✓ Branch 5 taken 1 times.
1 this->saDataReturnOut_out(portNum, data, context);
94 1 return;
95 }
96
1/1
✓ Branch 5 taken 834 times.
834 this->dataOut_out(0, status, data, context);
97 835 }
98
99 } // namespace Ccsds
100
101 } // namespace Svc
102