GCC Code Coverage Report


Directory: ./
File: unit_tests/test-framework/test_executor.cpp
Date: 2025-11-16 14:52:24
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 694 TestExecutor::~TestExecutor() {
14 // Flush the queue and reset all scheduling_s at the end of a test's execution
15 694 clear();
16 694 }
17
18 144 int TestExecutor::executeAll(efitimeus_t nowUs) {
19 144 return executeAllNt(US2NT(nowUs));
20 }
21
22 21405 int TestExecutor::executeAllNt(efitick_t nowNt) {
23 21405 return schedulingQueue.executeAll(nowNt);
24 }
25
26 701 void TestExecutor::clear() {
27 701 schedulingQueue.clear();
28 701 }
29
30 232 int TestExecutor::size() {
31 232 return schedulingQueue.size();
32 }
33
34 620241 scheduling_s* TestExecutor::getHead() {
35 620241 return schedulingQueue.getHead();
36 }
37
38 152 scheduling_s* TestExecutor::getForUnitTest(int index) {
39 152 return schedulingQueue.getElementAtIndexForUnitText(index);
40 }
41
42 30412 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 30396 times.
2/2
✓ Decision 'true' taken 16 times.
✓ Decision 'false' taken 30396 times.
30412 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 30396 efitimeus_t scheduleTime = timeNt;
51 extern bool unitTestTaskPrecisionHack;
52
2/2
✓ Branch 0 taken 18443 times.
✓ Branch 1 taken 11953 times.
2/2
✓ Decision 'true' taken 18443 times.
✓ Decision 'false' taken 11953 times.
30396 if(unitTestTaskPrecisionHack) {
53 18443 scheduleTime = US2NT(NT2US(timeNt));
54 }
55 30396 schedulingQueue.insertTask(scheduling, scheduleTime, action);
56 }
57
58 1769 void TestExecutor::cancel(scheduling_s* s) {
59
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1767 times.
2/2
✓ Decision 'true' taken 2 times.
✓ Decision 'false' taken 1767 times.
1769 if (m_mockExecutor) {
60 2 m_mockExecutor->cancel(s);
61 2 return;
62 }
63
64 1767 schedulingQueue.remove(s);
65 }
66
67 7 void TestExecutor::setMockExecutor(Scheduler* exec) {
68 7 m_mockExecutor = exec;
69 7 }
70