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 | 687 | TestExecutor::~TestExecutor() { | ||
14 | // Flush the queue and reset all scheduling_s at the end of a test's execution | |||
15 | 687 | clear(); | ||
16 | 687 | } | ||
17 | ||||
18 | 13297 | int TestExecutor::executeAll(efitimeus_t nowUs) { | ||
19 | 13297 | return schedulingQueue.executeAll(US2NT(nowUs)); | ||
20 | } | |||
21 | ||||
22 | 694 | void TestExecutor::clear() { | ||
23 | 694 | schedulingQueue.clear(); | ||
24 | 694 | } | ||
25 | ||||
26 | 232 | int TestExecutor::size() { | ||
27 | 232 | return schedulingQueue.size(); | ||
28 | } | |||
29 | ||||
30 | 599201 | scheduling_s* TestExecutor::getHead() { | ||
31 | 599201 | return schedulingQueue.getHead(); | ||
32 | } | |||
33 | ||||
34 | 148 | scheduling_s* TestExecutor::getForUnitTest(int index) { | ||
35 | 148 | return schedulingQueue.getElementAtIndexForUnitText(index); | ||
36 | } | |||
37 | ||||
38 | 25380 | void TestExecutor::schedule(const char *msg, scheduling_s* scheduling, efitick_t timeNt, action_s const& action) { | ||
39 |
2/2✓ Branch 0 taken 16 times.
✓ Branch 1 taken 25364 times.
|
2/2✓ Decision 'true' taken 16 times.
✓ Decision 'false' taken 25364 times.
|
25380 | if (m_mockExecutor) { |
40 | 16 | m_mockExecutor->schedule(msg, scheduling, timeNt, action); | ||
41 | 16 | return; | ||
42 | } | |||
43 | // technical debt: NT -> US -> NT in unit test scheduler #7245 | |||
44 | // by the way we have loss of precision while converting NT to integer US | |||
45 | // technical debt: looks like our unit tests were all created with us precision? | |||
46 | 25364 | efitimeus_t scheduleTime = timeNt; | ||
47 | extern bool unitTestTaskPrecisionHack; | |||
48 |
2/2✓ Branch 0 taken 13418 times.
✓ Branch 1 taken 11946 times.
|
2/2✓ Decision 'true' taken 13418 times.
✓ Decision 'false' taken 11946 times.
|
25364 | if(unitTestTaskPrecisionHack) { |
49 | 13418 | scheduleTime = US2NT(NT2US(timeNt)); | ||
50 | } | |||
51 | 25364 | schedulingQueue.insertTask(scheduling, scheduleTime, action); | ||
52 | } | |||
53 | ||||
54 | 1268 | void TestExecutor::cancel(scheduling_s* s) { | ||
55 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1266 times.
|
2/2✓ Decision 'true' taken 2 times.
✓ Decision 'false' taken 1266 times.
|
1268 | if (m_mockExecutor) { |
56 | 2 | m_mockExecutor->cancel(s); | ||
57 | 2 | return; | ||
58 | } | |||
59 | ||||
60 | 1266 | schedulingQueue.remove(s); | ||
61 | } | |||
62 | ||||
63 | 7 | void TestExecutor::setMockExecutor(Scheduler* exec) { | ||
64 | 7 | m_mockExecutor = exec; | ||
65 | 7 | } | ||
66 |