GCC Code Coverage Report


Directory: ./
File: Svc/Types/EventSeverityFilter/EventSeverityFilter.cpp
Date: 2026-09-03 22:12:29
Exec Total Coverage
Lines: 37 46 80.4%
Functions: 5 6 83.3%
Branches: 15 23 65.2%

Line Branch Exec Source
1 #include <Fw/Types/Assert.hpp>
2 #include <Svc/Types/EventSeverityFilter/EventSeverityFilter.hpp>
3
4 namespace Svc {
5
6 2 EventSeverityFilter::EventSeverityFilter() {
7
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 2 times.
14 for (FwSizeType i = 0; i < NUM_FILTER_LEVELS; i++) {
8 12 this->m_enabled[i] = true;
9 }
10 2 }
11
12 25 void EventSeverityFilter::setFilter(Fw::LogSeverity severity, bool enabled) {
13 25 FwSizeType index = 0;
14
3/4
✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
✓ Branch 9 taken 25 times.
✗ Branch 10 not taken.
25 if (toIndex(severity, index) == Fw::Success::SUCCESS) {
15 25 this->m_enabled[index] = enabled;
16 }
17 25 }
18
19 1110 bool EventSeverityFilter::isFiltered(Fw::LogSeverity severity) const {
20 1110 FwSizeType index = 0;
21
3/4
✓ Branch 1 taken 1110 times.
✓ Branch 4 taken 1110 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1110 times.
1110 if (toIndex(severity, index) != Fw::Success::SUCCESS) {
22 // FATAL / unknown are never filtered
23 return false;
24 }
25 1110 return !this->m_enabled[index];
26 }
27
28 bool EventSeverityFilter::isEnabled(Fw::LogSeverity severity) const {
29 FwSizeType index = 0;
30 if (toIndex(severity, index) != Fw::Success::SUCCESS) {
31 // FATAL is always enabled
32 return true;
33 }
34 return this->m_enabled[index];
35 }
36
37 constexpr Fw::LogSeverity::t EventSeverityFilter::SEVERITY_ORDER[EventSeverityFilter::NUM_FILTER_LEVELS];
38
39 13 Fw::Success EventSeverityFilter::fromIndex(FwSizeType index, Fw::LogSeverity& severity) {
40
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if (index >= NUM_FILTER_LEVELS) {
41 return Fw::Success::FAILURE;
42 }
43 13 severity = SEVERITY_ORDER[index];
44 13 return Fw::Success::SUCCESS;
45 }
46
47 1135 Fw::Success EventSeverityFilter::toIndex(Fw::LogSeverity severity, FwSizeType& index) {
48
6/7
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 585 times.
✓ Branch 3 taken 248 times.
✓ Branch 4 taken 60 times.
✓ Branch 5 taken 218 times.
✗ Branch 6 not taken.
1135 switch (severity.e) {
49 10 case Fw::LogSeverity::WARNING_HI:
50 10 index = 0;
51 10 return Fw::Success::SUCCESS;
52 14 case Fw::LogSeverity::WARNING_LO:
53 14 index = 1;
54 14 return Fw::Success::SUCCESS;
55 585 case Fw::LogSeverity::COMMAND:
56 585 index = 2;
57 585 return Fw::Success::SUCCESS;
58 248 case Fw::LogSeverity::ACTIVITY_HI:
59 248 index = 3;
60 248 return Fw::Success::SUCCESS;
61 60 case Fw::LogSeverity::ACTIVITY_LO:
62 60 index = 4;
63 60 return Fw::Success::SUCCESS;
64 218 case Fw::LogSeverity::DIAGNOSTIC:
65 218 index = 5;
66 218 return Fw::Success::SUCCESS;
67 default:
68 return Fw::Success::FAILURE;
69 }
70 }
71
72 } // namespace Svc
73