GCC Code Coverage Report


Directory: ./
File: unit_tests/tests/actuators/test_aux_valves.cpp
Date: 2025-10-03 00:57:22
Coverage Exec Excl Total
Lines: 100.0% 27 0 27
Functions: 100.0% 3 0 3
Branches: 100.0% 20 0 20
Decisions: -% 0 - 0

Line Branch Decision Exec Source
1 /*
2 * @file test_aux_valves.cpp
3 *
4 * @date: Nov 23, 2019
5 * @author Andrey Belomutskiy, (c) 2012-2020
6 */
7
8 #include "pch.h"
9
10 #include "aux_valves.h"
11
12 4 TEST(Actuators, AuxValves) {
13
1/1
✓ Branch 2 taken 1 time.
1 EngineTestHelper eth(engine_type_e::TEST_ENGINE);
14 1 engineConfiguration->auxValves[0] = Gpio::E14;
15 1 engineConfiguration->auxValves[1] = Gpio::E12;
16
1/1
✓ Branch 1 taken 1 time.
1 eth.setTriggerType(trigger_type_e::TT_NISSAN_SR20VE);
17
1/1
✓ Branch 1 taken 1 time.
1 Sensor::setMockValue(SensorType::DriverThrottleIntent, 0);
18
19 // force recalculation of aux valves:
20
1/1
✓ Branch 1 taken 1 time.
1 initAuxValves();
21 // Engine must be "spinning" for scheduleByAngle to work
22
1/1
✓ Branch 1 taken 1 time.
1 engine->rpmCalculator.setRpmValue(1000);
23
24 1 auto const auxPlainPinTurnOnAction{ action_s::make<auxPlainPinTurnOn>((AuxActor*){}) };
25
26 // TODO: This whole block is passing some expected values which are ignored by check implementation, fix?
27
28
1/1
✓ Branch 1 taken 1 time.
1 eth.assertTriggerEvent("a0", 0, &engine->auxValves[0][0].open, auxPlainPinTurnOnAction, 0);
29
1/1
✓ Branch 1 taken 1 time.
1 eth.assertTriggerEvent("a1", 1, &engine->auxValves[0][1].open, auxPlainPinTurnOnAction, 360);
30
1/1
✓ Branch 1 taken 1 time.
1 eth.assertTriggerEvent("a2", 2, &engine->auxValves[1][0].open, auxPlainPinTurnOnAction, 180);
31
1/1
✓ Branch 1 taken 1 time.
1 eth.assertTriggerEvent("a3", 3, &engine->auxValves[1][1].open, auxPlainPinTurnOnAction, 540);
32
33 // Execute the first one, ensure scheduling for the "close" event happens
34
2/2
✓ Branch 1 taken 1 time.
✓ Branch 5 taken 1 time.
1 engine->module<TriggerScheduler>()->scheduleEventsUntilNextTriggerTooth(1000, 0, 0, 1);
35
36 // Old head should now be missing - we just ran it
37
1/1
✓ Branch 1 taken 1 time.
1 eth.assertTriggerEvent("a1", 0, &engine->auxValves[0][1].open, auxPlainPinTurnOnAction, 360);
38
1/1
✓ Branch 1 taken 1 time.
1 eth.assertTriggerEvent("a2", 1, &engine->auxValves[1][0].open, auxPlainPinTurnOnAction, 180);
39
1/1
✓ Branch 1 taken 1 time.
1 eth.assertTriggerEvent("a3", 2, &engine->auxValves[1][1].open, auxPlainPinTurnOnAction, 540);
40
41 // Execute the action it put on the regular scheduler
42
1/1
✓ Branch 1 taken 1 time.
1 eth.setTimeAndInvokeEventsUs(999999);
43
44
1/1
✓ Branch 1 taken 1 time.
1 eth.assertTriggerEvent("a1", 0, &engine->auxValves[0][1].open, auxPlainPinTurnOnAction, 360);
45
1/1
✓ Branch 1 taken 1 time.
1 eth.assertTriggerEvent("a2", 1, &engine->auxValves[1][0].open, auxPlainPinTurnOnAction, 180);
46
1/1
✓ Branch 1 taken 1 time.
1 eth.assertTriggerEvent("a3", 2, &engine->auxValves[1][1].open, auxPlainPinTurnOnAction, 540);
47 // same event is back at the end of the list
48
1/1
✓ Branch 1 taken 1 time.
1 eth.assertTriggerEvent("a0", 3, &engine->auxValves[0][0].open, auxPlainPinTurnOnAction, 0);
49 // PLUS the turn off event!
50 1 action_s const noneAction{};
51
1/1
✓ Branch 1 taken 1 time.
1 eth.assertTriggerEvent("off", 4, &engine->auxValves[0][0].close, noneAction, 30);
52 2 }
53