GCC Code Coverage Report


Directory: ./
File: Svc/Ccsds/SdlsSaRouter/SdlsSaRouter.cpp
Date: 2026-09-23 21:11:01
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 4105 void SdlsSaRouter ::dataIn_handler(FwIndexType portNum,
39 U16 securityAssociationIndex,
40 Fw::Buffer& data,
41 const ComCfg::FrameContext& context) {
42 4105 FwIndexType outputPort = 0;
43
1/1
✓ Branch 4 taken 4105 times.
4105 const Fw::Success found = this->m_saMap.find(securityAssociationIndex, outputPort);
44
1/1
✓ Branch 2 taken 4105 times.
4105 Svc::Ccsds::SdlsStatus errorStatus = Svc::Ccsds::SdlsStatus::UNKNOWN_SA;
45
2/2
✓ Branch 2 taken 3294 times.
✓ Branch 3 taken 811 times.
4105 if (found == Fw::Success::SUCCESS) {
46
4/6
✓ Branch 0 taken 3294 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 3294 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2495 times.
✓ Branch 6 taken 799 times.
6588 if ((outputPort >= 0) && (outputPort < this->getNum_saDataOut_OutputPorts()) &&
47
3/3
✓ Branch 5 taken 3294 times.
✓ Branch 7 taken 2495 times.
✓ Branch 8 taken 799 times.
3294 (this->isConnected_saDataOut_OutputPort(outputPort))) {
48
1/1
✓ Branch 5 taken 2495 times.
2495 this->saDataOut_out(outputPort, securityAssociationIndex, data, context);
49 2495 return;
50 }
51
1/1
✓ Branch 2 taken 799 times.
799 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 1610 times.
1610 this->m_outstandingLock.lock();
56 1610 const Fw::Success inserted =
57
2/2
✓ Branch 9 taken 1610 times.
✓ Branch 13 taken 1610 times.
1610 this->m_outstanding.insert(data.getContext(), static_cast<FwIndexType>(ROUTER_ERROR_PORT));
58
1/1
✓ Branch 6 taken 1610 times.
1610 this->m_outstandingLock.unlock();
59
2/2
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1609 times.
1610 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 1609 times.
1609 this->dataOut_out(0, errorStatus, data, context);
66 6602 }
67
68 2478 void SdlsSaRouter ::dataReturnIn_handler(FwIndexType portNum, Fw::Buffer& data, const ComCfg::FrameContext& context) {
69 2478 FwIndexType outputPort = 0;
70
1/1
✓ Branch 6 taken 2478 times.
2478 this->m_outstandingLock.lock();
71
2/2
✓ Branch 8 taken 2478 times.
✓ Branch 12 taken 2478 times.
2478 const Fw::Success found = this->m_outstanding.find(data.getContext(), outputPort);
72
2/2
✓ Branch 2 taken 2477 times.
✓ Branch 3 taken 1 times.
2478 if (found == Fw::Success::SUCCESS) {
73
2/2
✓ Branch 8 taken 2477 times.
✓ Branch 12 taken 2477 times.
2477 (void)this->m_outstanding.remove(data.getContext(), outputPort);
74 }
75
1/1
✓ Branch 6 taken 2478 times.
2478 this->m_outstandingLock.unlock();
76
77
2/2
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2477 times.
2478 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 1603 times.
✓ Branch 1 taken 874 times.
2477 } 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 1603 times.
1603 this->bufferReturnOut_out(0, data, context);
84 } else {
85
1/1
✓ Branch 5 taken 874 times.
874 this->saDataReturnOut_out(outputPort, data, context);
86 }
87 4956 }
88
89 2555 void SdlsSaRouter ::saBufferReturnIn_handler(FwIndexType portNum,
90 Fw::Buffer& data,
91 const ComCfg::FrameContext& context) {
92 2555 this->bufferReturnOut_out(0, data, context);
93 2555 }
94
95 883 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 883 times.
883 this->m_outstandingLock.lock();
100
2/2
✓ Branch 8 taken 883 times.
✓ Branch 12 taken 883 times.
883 const Fw::Success inserted = this->m_outstanding.insert(data.getContext(), portNum);
101
1/1
✓ Branch 6 taken 883 times.
883 this->m_outstandingLock.unlock();
102
2/2
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 882 times.
883 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 882 times.
882 this->dataOut_out(0, status, data, context);
109 883 }
110
111 } // namespace Ccsds
112
113 } // namespace Svc
114