GCC Code Coverage Report


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