GCC Code Coverage Report


Directory: Svc/Ccsds/SdlsSaRouter/
File: SdlsSaRouter.cpp
Date: 2026-09-23 21:13:21
Exec Total Coverage
Lines: 60 60 100.0%
Functions: 7 7 100.0%
Branches: 57 59 96.6%

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
3/3
✓ Branch 10 taken 9 times.
✓ Branch 16 taken 9 times.
✓ Branch 22 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
1/1
✓ Branch 4 taken 9 times.
9 this->configure(saMap);
21 18 }
22
23 18 SdlsSaRouter ::~SdlsSaRouter() {}
24
25 9 void SdlsSaRouter ::configure(const SdlsCfg::SaMap& saMap) {
26 9 this->m_saMap.clear();
27
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 9 times.
27 for (SdlsCfg::SaMap::SizeType i = 0; i < SdlsCfg::SaMap::SIZE; i++) {
28 18 const Fw::Success status =
29
3/3
✓ Branch 7 taken 18 times.
✓ Branch 19 taken 18 times.
✓ Branch 27 taken 18 times.
18 this->m_saMap.insert(saMap[i].get_securityAssociationIndex(), saMap[i].get_portIndex());
30 18 FW_ASSERT(status == Fw::Success::SUCCESS, static_cast<FwAssertArgType>(i));
31 18 }
32 9 }
33
34 // ----------------------------------------------------------------------
35 // Handler implementations for typed input ports
36 // ----------------------------------------------------------------------
37
38 4220 void SdlsSaRouter ::dataIn_handler(FwIndexType portNum,
39 U16 securityAssociationIndex,
40 Fw::Buffer& data,
41 const ComCfg::FrameContext& context) {
42 4220 FwIndexType outputPort = 0;
43
1/1
✓ Branch 4 taken 4220 times.
4220 const Fw::Success found = this->m_saMap.find(securityAssociationIndex, outputPort);
44
1/1
✓ Branch 2 taken 4220 times.
4220 Svc::Ccsds::SdlsStatus errorStatus = Svc::Ccsds::SdlsStatus::UNKNOWN_SA;
45
2/2
✓ Branch 2 taken 3367 times.
✓ Branch 3 taken 853 times.
4220 if (found == Fw::Success::SUCCESS) {
46
4/6
✓ Branch 0 taken 3367 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 3367 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2573 times.
✓ Branch 6 taken 794 times.
6734 if ((outputPort >= 0) && (outputPort < this->getNum_saDataOut_OutputPorts()) &&
47
3/3
✓ Branch 5 taken 3367 times.
✓ Branch 7 taken 2573 times.
✓ Branch 8 taken 794 times.
3367 (this->isConnected_saDataOut_OutputPort(outputPort))) {
48
1/1
✓ Branch 5 taken 2573 times.
2573 this->saDataOut_out(outputPort, securityAssociationIndex, data, context);
49 2573 return;
50 }
51
1/1
✓ Branch 2 taken 794 times.
794 errorStatus = Svc::Ccsds::SdlsStatus::UNKNOWN_PORT;
52 }
53 // Routing failed: pass the error status forward with the untouched buffer, tracking it
54 // so the eventual ownership return routes back upstream via bufferReturnOut
55
1/1
✓ Branch 6 taken 1647 times.
1647 this->m_outstandingLock.lock();
56 1647 const Fw::Success inserted =
57
2/2
✓ Branch 9 taken 1647 times.
✓ Branch 13 taken 1647 times.
1647 this->m_outstanding.insert(data.getContext(), static_cast<FwIndexType>(ROUTER_ERROR_PORT));
58
1/1
✓ Branch 6 taken 1647 times.
1647 this->m_outstandingLock.unlock();
59
2/2
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1646 times.
1647 if (inserted != Fw::Success::SUCCESS) {
60 // Tracking table full: drop the request and return the buffer upstream immediately
61
1/1
✓ Branch 5 taken 1 times.
1 this->log_WARNING_HI_TrackingTableFull();
62
1/1
✓ Branch 5 taken 1 times.
1 this->bufferReturnOut_out(0, data, context);
63 1 return;
64 }
65
1/1
✓ Branch 5 taken 1646 times.
1646 this->dataOut_out(0, errorStatus, data, context);
66 6795 }
67
68 2471 void SdlsSaRouter ::dataReturnIn_handler(FwIndexType portNum, Fw::Buffer& data, const ComCfg::FrameContext& context) {
69 2471 FwIndexType outputPort = 0;
70
1/1
✓ Branch 6 taken 2471 times.
2471 this->m_outstandingLock.lock();
71
2/2
✓ Branch 8 taken 2471 times.
✓ Branch 12 taken 2471 times.
2471 const Fw::Success found = this->m_outstanding.find(data.getContext(), outputPort);
72
2/2
✓ Branch 2 taken 2470 times.
✓ Branch 3 taken 1 times.
2471 if (found == Fw::Success::SUCCESS) {
73
2/2
✓ Branch 8 taken 2470 times.
✓ Branch 12 taken 2470 times.
2470 (void)this->m_outstanding.remove(data.getContext(), outputPort);
74 }
75
1/1
✓ Branch 6 taken 2471 times.
2471 this->m_outstandingLock.unlock();
76
77
2/2
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2470 times.
2471 if (found != Fw::Success::SUCCESS) {
78 // Untracked buffer (e.g. lost to a context-key collision): return it upstream
79
1/1
✓ Branch 5 taken 1 times.
1 this->log_WARNING_HI_UntrackedBufferReturned();
80
1/1
✓ Branch 5 taken 1 times.
1 this->bufferReturnOut_out(0, data, context);
81
2/2
✓ Branch 0 taken 1641 times.
✓ Branch 1 taken 829 times.
2470 } else if (outputPort == ROUTER_ERROR_PORT) {
82 // Buffer was forwarded by the router itself on a routing error: return it upstream
83
1/1
✓ Branch 5 taken 1641 times.
1641 this->bufferReturnOut_out(0, data, context);
84 } else {
85
1/1
✓ Branch 5 taken 829 times.
829 this->saDataReturnOut_out(outputPort, data, context);
86 }
87 4942 }
88
89 2491 void SdlsSaRouter ::saBufferReturnIn_handler(FwIndexType portNum,
90 Fw::Buffer& data,
91 const ComCfg::FrameContext& context) {
92 2491 this->bufferReturnOut_out(0, data, context);
93 2491 }
94
95 839 void SdlsSaRouter ::saDataIn_handler(FwIndexType portNum,
96 const Svc::Ccsds::SdlsStatus& status,
97 Fw::Buffer& data,
98 const ComCfg::FrameContext& context) {
99
1/1
✓ Branch 6 taken 839 times.
839 this->m_outstandingLock.lock();
100
2/2
✓ Branch 8 taken 839 times.
✓ Branch 12 taken 839 times.
839 const Fw::Success inserted = this->m_outstanding.insert(data.getContext(), portNum);
101
1/1
✓ Branch 6 taken 839 times.
839 this->m_outstandingLock.unlock();
102
2/2
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 838 times.
839 if (inserted != Fw::Success::SUCCESS) {
103 // Tracking table full: drop the data and return ownership to the downstream component
104
1/1
✓ Branch 5 taken 1 times.
1 this->log_WARNING_HI_TrackingTableFull();
105
1/1
✓ Branch 5 taken 1 times.
1 this->saDataReturnOut_out(portNum, data, context);
106 1 return;
107 }
108
1/1
✓ Branch 5 taken 838 times.
838 this->dataOut_out(0, status, data, context);
109 839 }
110
111 } // namespace Ccsds
112
113 } // namespace Svc
114