GCC Code Coverage Report


Directory: ./
File: Svc/Types/EventSeverityFilter/EventSeverityFilter.cpp
Date: 2026-11-03 22:10:14
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 1383 bool EventSeverityFilter::isFiltered(Fw::LogSeverity severity) const {
20 1383 FwSizeType index = 0;
21
3/4
✓ Branch 1 taken 1384 times.
✓ Branch 4 taken 1383 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1384 times.
1383 if (toIndex(severity, index) != Fw::Success::SUCCESS) {
22 // FATAL / unknown are never filtered
23 ✗ return false;
24 }
25 1384 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 1409 Fw::Success EventSeverityFilter::toIndex(Fw::LogSeverity severity, FwSizeType& index) {
48
6/7
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 649 times.
✓ Branch 3 taken 324 times.
✓ Branch 4 taken 142 times.
✓ Branch 5 taken 260 times.
✗ Branch 6 not taken.
1409 switch (severity.e) {
49 16 case Fw::LogSeverity::WARNING_HI:
50 16 index = 0;
51 16 return Fw::Success::SUCCESS;
52 18 case Fw::LogSeverity::WARNING_LO:
53 18 index = 1;
54 18 return Fw::Success::SUCCESS;
55 649 case Fw::LogSeverity::COMMAND:
56 649 index = 2;
57 649 return Fw::Success::SUCCESS;
58 324 case Fw::LogSeverity::ACTIVITY_HI:
59 324 index = 3;
60 324 return Fw::Success::SUCCESS;
61 142 case Fw::LogSeverity::ACTIVITY_LO:
62 142 index = 4;
63 142 return Fw::Success::SUCCESS;
64 260 case Fw::LogSeverity::DIAGNOSTIC:
65 260 index = 5;
66 260 return Fw::Success::SUCCESS;
67 ✗ default:
68 ✗ return Fw::Success::FAILURE;
69 }
70 }
71
72 } // namespace Svc
73