GCC Code Coverage Report


Directory: ./
File: unit_tests/test-framework/test_executor.cpp
Date: 2025-10-24 14:26:41
Coverage Exec Excl Total
Lines: 100.0% 32 0 32
Functions: 100.0% 10 0 10
Branches: 100.0% 6 0 6
Decisions: 100.0% 6 - 6

Line Branch Decision Exec Source
1 /*
2 * test_executor.cpp
3 *
4 * @date Dec 8, 2018
5 * @author Andrey Belomutskiy, (c) 2012-2020
6 */
7
8 #include "pch.h"
9 #include "test_executor.h"
10
11 bool debugSignalExecutor = false;
12
13 688 TestExecutor::~TestExecutor() {
14 // Flush the queue and reset all scheduling_s at the end of a test's execution
15 688 clear();
16 688 }
17
18 144 int TestExecutor::executeAll(efitimeus_t nowUs) {
19 144 return executeAllNt(US2NT(nowUs));
20 }
21
22 18649 int TestExecutor::executeAllNt(efitick_t nowNt) {
23 18649 return schedulingQueue.executeAll(nowNt);
24 }
25
26 695 void TestExecutor::clear() {
27 695 schedulingQueue.clear();
28 695 }
29
30 232 int TestExecutor::size() {
31 232 return schedulingQueue.size();
32 }
33
34 612677 scheduling_s* TestExecutor::getHead() {
35 612677 return schedulingQueue.getHead();
36 }
37
38 148 scheduling_s* TestExecutor::getForUnitTest(int index) {
39 148 return schedulingQueue.getElementAtIndexForUnitText(index);
40 }
41
42 27591 void TestExecutor::schedule(const char *msg, scheduling_s* scheduling, efitick_t timeNt, action_s const& action) {
43
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 27575 times.
2/2
✓ Decision 'true' taken 16 times.
✓ Decision 'false' taken 27575 times.
27591 if (m_mockExecutor) {
44 16 m_mockExecutor->schedule(msg, scheduling, timeNt, action);
45 16 return;
46 }
47 // technical debt: NT -> US -> NT in unit test scheduler #7245
48 // by the way we have loss of precision while converting NT to integer US
49 // technical debt: looks like our unit tests were all created with us precision?
50 27575 efitimeus_t scheduleTime = timeNt;
51 extern bool unitTestTaskPrecisionHack;
52
2/2
✓ Branch 0 taken 15634 times.
✓ Branch 1 taken 11941 times.
2/2
✓ Decision 'true' taken 15634 times.
✓ Decision 'false' taken 11941 times.
27575 if(unitTestTaskPrecisionHack) {
53 15634 scheduleTime = US2NT(NT2US(timeNt));
54 }
55 27575 schedulingQueue.insertTask(scheduling, scheduleTime, action);
56 }
57
58 1733 void TestExecutor::cancel(scheduling_s* s) {
59
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1731 times.
2/2
✓ Decision 'true' taken 2 times.
✓ Decision 'false' taken 1731 times.
1733 if (m_mockExecutor) {
60 2 m_mockExecutor->cancel(s);
61 2 return;
62 }
63
64 1731 schedulingQueue.remove(s);
65 }
66
67 7 void TestExecutor::setMockExecutor(Scheduler* exec) {
68 7 m_mockExecutor = exec;
69 7 }
70