GCC Code Coverage Report


Directory: ./
File: unit_tests/tests/test_hpfp_integrated.cpp
Date: 2025-10-03 00:57:22
Coverage Exec Excl Total
Lines: 100.0% 32 0 32
Functions: 100.0% 4 0 4
Branches: 62.8% 27 0 43
Decisions: -% 0 - 0

Line Branch Decision Exec Source
1 /*
2 * @file test_hpfp_integrated.cpp
3 *
4 * Created on: Jan 18, 2022
5 * More integrated version of HPFP test
6 */
7
8 #include "pch.h"
9 using ::testing::_;
10
11 static int hpfpTotalToggle = 0;
12
13 5 static void assertToggleCounterExtra(EngineTestHelper *eth, int extra, const char *msg) {
14 5 eth->smartFireTriggerEvents2(/*count*/4, /*delay*/ 16);
15
3/9
✓ Branch 3 taken 5 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5 times.
✗ Branch 11 not taken.
✗ Branch 14 not taken.
✗ Branch 19 not taken.
✗ Branch 22 not taken.
✓ Branch 29 taken 5 times.
✗ Branch 30 not taken.
5 ASSERT_EQ(hpfpTotalToggle + extra, enginePins.hpfpValve.pinToggleCounter) << msg;
16 5 hpfpTotalToggle += extra;
17 }
18
19 #if FUEL_RPM_COUNT == 16
20 4 TEST(HPFP, IntegratedSchedule) {
21 extern bool unitTestTaskPrecisionHack;
22 1 unitTestTaskPrecisionHack = true;
23 2 EngineTestHelper eth(engine_type_e::TEST_ENGINE, [](engine_configuration_s* engineConfiguration) {
24 engineConfiguration->hpfpValvePin = Gpio::A2; // arbitrary
25
1/1
✓ Branch 3 taken 1 time.
1 });
26
27 1 engineConfiguration->cylindersCount = 4;
28 1 engineConfiguration->hpfpCamLobes = 3;
29 1 engineConfiguration->hpfpPumpVolume = 0.2; // cc/lobe
30
31
5/5
✓ Branch 3 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 13 taken 1 time.
✓ Branch 17 taken 1 time.
3 EXPECT_CALL(*eth.mockAirmass, getAirmass(_, _))
32
3/3
✓ Branch 5 taken 1 time.
✓ Branch 8 taken 1 time.
✓ Branch 11 taken 1 time.
3 .WillRepeatedly(Return(AirmassResult{/*airmass*/1, /*load*/50.0f}));
33
34 1 engineConfiguration->trigger.customTotalToothCount = 4;
35 1 engineConfiguration->trigger.customSkippedToothCount = 0;
36
1/1
✓ Branch 1 taken 1 time.
1 eth.setTriggerType(trigger_type_e::TT_TOOTHED_WHEEL);
37
1/1
✓ Branch 1 taken 1 time.
1 setCamOperationMode();
38 1 engineConfiguration->isFasterEngineSpinUpEnabled = true;
39 1 engineConfiguration->hpfpCam = HPFP_CAM_IN1;
40
41
1/1
✓ Branch 1 taken 1 time.
1 eth.smartFireTriggerEvents2(/*count*/8, /*delay*/ 16);
42
4/9
✓ Branch 3 taken 1 time.
✓ Branch 7 taken 1 time.
✗ Branch 12 not taken.
✓ Branch 13 taken 1 time.
✗ Branch 16 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
✓ Branch 31 taken 1 time.
✗ Branch 32 not taken.
1 ASSERT_EQ(937, round(Sensor::getOrZero(SensorType::Rpm)));
43
44
45 1 hpfpTotalToggle = 6;
46 /**
47 * overall this is a pretty lame test but helps to know that the whole on/off/on dance does in fact happen for HPFP
48 */
49
3/8
✓ Branch 2 taken 1 time.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 time.
✗ Branch 9 not taken.
✗ Branch 14 not taken.
✗ Branch 17 not taken.
✓ Branch 24 taken 1 time.
✗ Branch 25 not taken.
1 ASSERT_EQ(hpfpTotalToggle, enginePins.hpfpValve.pinToggleCounter);
50
51
1/1
✓ Branch 1 taken 1 time.
1 assertToggleCounterExtra(&eth, 4, "#1");
52
53 1 engine->triggerCentral.vvtPosition[0][0] = -100; // Bank 0
54
55
1/1
✓ Branch 1 taken 1 time.
1 assertToggleCounterExtra(&eth, 7, "#2");
56
57
1/1
✓ Branch 1 taken 1 time.
1 assertToggleCounterExtra(&eth, 6, "#3");
58
59
1/1
✓ Branch 1 taken 1 time.
1 assertToggleCounterExtra(&eth, 6, "#4");
60
61
1/1
✓ Branch 1 taken 1 time.
1 assertToggleCounterExtra(&eth, 6, "#5");
62 1 }
63 #endif //FUEL_RPM_COUNT == 16
64
65