GCC Code Coverage Report


Directory: Svc/Ccsds/SdlsSaRouter/
File: SdlsSaRouter.cpp
Date: 2026-11-03 21:17:59
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 4166 void SdlsSaRouter ::dataIn_handler(FwIndexType portNum,
39 U16 securityAssociationIndex,
40 Fw::Buffer& data,
41 const ComCfg::FrameContext& context) {
42 4166 FwIndexType outputPort = 0;
43
1/1
✓ Branch 4 taken 4166 times.
4166 const Fw::Success found = this->m_saMap.find(securityAssociationIndex, outputPort);
44
1/1
✓ Branch 2 taken 4166 times.
4166 Svc::Ccsds::SdlsStatus errorStatus = Svc::Ccsds::SdlsStatus::UNKNOWN_SA;
45
2/2
✓ Branch 2 taken 3357 times.
✓ Branch 3 taken 809 times.
4166 if (found == Fw::Success::SUCCESS) {
46
4/6
✓ Branch 0 taken 3357 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 3357 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2500 times.
✓ Branch 6 taken 857 times.
6714 if ((outputPort >= 0) && (outputPort < this->getNum_saDataOut_OutputPorts()) &&
47
3/3
✓ Branch 5 taken 3357 times.
✓ Branch 7 taken 2500 times.
✓ Branch 8 taken 857 times.
3357 (this->isConnected_saDataOut_OutputPort(outputPort))) {
48
1/1
✓ Branch 5 taken 2500 times.
2500 this->saDataOut_out(outputPort, securityAssociationIndex, data, context);
49 2500 return;
50 }
51
1/1
✓ Branch 2 taken 857 times.
857 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 1666 times.
1666 this->m_outstandingLock.lock();
56 1666 const Fw::Success inserted =
57
2/2
✓ Branch 9 taken 1666 times.
✓ Branch 13 taken 1666 times.
1666 this->m_outstanding.insert(data.getContext(), static_cast<FwIndexType>(ROUTER_ERROR_PORT));
58
1/1
✓ Branch 6 taken 1666 times.
1666 this->m_outstandingLock.unlock();
59
2/2
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1665 times.
1666 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 1665 times.
1665 this->dataOut_out(0, errorStatus, data, context);
66 6668 }
67
68 2526 void SdlsSaRouter ::dataReturnIn_handler(FwIndexType portNum, Fw::Buffer& data, const ComCfg::FrameContext& context) {
69 2526 FwIndexType outputPort = 0;
70
1/1
✓ Branch 6 taken 2526 times.
2526 this->m_outstandingLock.lock();
71
2/2
✓ Branch 8 taken 2526 times.
✓ Branch 12 taken 2526 times.
2526 const Fw::Success found = this->m_outstanding.find(data.getContext(), outputPort);
72
2/2
✓ Branch 2 taken 2525 times.
✓ Branch 3 taken 1 times.
2526 if (found == Fw::Success::SUCCESS) {
73
2/2
✓ Branch 8 taken 2525 times.
✓ Branch 12 taken 2525 times.
2525 (void)this->m_outstanding.remove(data.getContext(), outputPort);
74 }
75
1/1
✓ Branch 6 taken 2526 times.
2526 this->m_outstandingLock.unlock();
76
77
2/2
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2525 times.
2526 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 1661 times.
✓ Branch 1 taken 864 times.
2525 } 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 1661 times.
1661 this->bufferReturnOut_out(0, data, context);
84 } else {
85
1/1
✓ Branch 5 taken 864 times.
864 this->saDataReturnOut_out(outputPort, data, context);
86 }
87 5052 }
88
89 2455 void SdlsSaRouter ::saBufferReturnIn_handler(FwIndexType portNum,
90 Fw::Buffer& data,
91 const ComCfg::FrameContext& context) {
92 2455 this->bufferReturnOut_out(0, data, context);
93 2455 }
94
95 874 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 874 times.
874 this->m_outstandingLock.lock();
100
2/2
✓ Branch 8 taken 874 times.
✓ Branch 12 taken 874 times.
874 const Fw::Success inserted = this->m_outstanding.insert(data.getContext(), portNum);
101
1/1
✓ Branch 6 taken 874 times.
874 this->m_outstandingLock.unlock();
102
2/2
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 873 times.
874 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 873 times.
873 this->dataOut_out(0, status, data, context);
109 874 }
110
111 } // namespace Ccsds
112
113 } // namespace Svc
114