GCC Code Coverage Report


Directory: ./
File: unit_tests/tests/trigger/test_real_noisy_trigger.cpp
Date: 2025-10-03 00:57:22
Warnings: 1 unchecked decisions!
Coverage Exec Excl Total
Lines: 100.0% 73 0 73
Functions: 100.0% 26 0 26
Branches: 55.9% 19 0 34
Decisions: 66.7% 4 - 6

Line Branch Decision Exec Source
1 #include "pch.h"
2 #include "logicdata_csv_reader.h"
3
4 8 static void testNoOverdwell(const char* file, bool instantRpm, const int expectedBailedOnDwellCount) {
5
1/1
✓ Branch 2 taken 8 times.
8 CsvReader reader(1, /* vvtCount */ 0);
6
7
1/1
✓ Branch 1 taken 8 times.
8 reader.open(file);
8
1/1
✓ Branch 2 taken 8 times.
8 EngineTestHelper eth(engine_type_e::TEST_ENGINE);
9 8 engineConfiguration->isFasterEngineSpinUpEnabled = true;
10 8 engineConfiguration->alwaysInstantRpm = instantRpm;
11
12 8 engineConfiguration->cylindersCount = 6;
13 8 engineConfiguration->firingOrder = FO_1_5_3_6_2_4;
14 8 engineConfiguration->globalTriggerAngleOffset = 155;
15 8 engineConfiguration->ignitionMode = IM_INDIVIDUAL_COILS;
16
17 8 engineConfiguration->timingMode = TM_FIXED;
18 8 engineConfiguration->fixedTiming = 14.69;
19
20 8 engineConfiguration->trigger.customTotalToothCount = 36;
21 8 engineConfiguration->trigger.customSkippedToothCount = 2;
22
1/1
✓ Branch 1 taken 8 times.
8 eth.setTriggerType(trigger_type_e::TT_TOOTHED_WHEEL);
23
24 8 engineConfiguration->isIgnitionEnabled = true;
25 8 engineConfiguration->isInjectionEnabled = false;
26
27
1/1
✓ Branch 3 taken 8 times.
24 std::vector<efitick_t> coilStartTimes(12);
28
29 16 engine->onIgnitionEvent = [&](IgnitionEvent* event, bool state) {
30 547 efitick_t startTime = coilStartTimes[event->coilIndex];
31
32
2/2
✓ Branch 0 taken 254 times.
✓ Branch 1 taken 293 times.
2/2
✓ Decision 'true' taken 254 times.
✓ Decision 'false' taken 293 times.
547 if (state) {
33 254 coilStartTimes[event->coilIndex] = getTimeNowNt();
34
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 251 times.
2/2
✓ Decision 'true' taken 42 times.
✓ Decision 'false' taken 251 times.
293 } else if (startTime == 0) {
35 42 printf("Interesting: goes LOW without ever going HIGH %d\n", event->coilIndex);
36 } else {
37
1/1
✓ Branch 2 taken 251 times.
251 auto actualDwell = 1e-3 * NT2USF(getTimeNowNt() - startTime);
38 251 coilStartTimes[event->coilIndex] = 0;
39
40
2/11
✓ Branch 3 taken 251 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 251 times.
✗ Branch 11 not taken.
✗ Branch 14 not taken.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
✗ Branch 27 not taken.
✗ Branch 32 not taken.
✗ Branch 35 not taken.
251 EXPECT_LT(actualDwell, 50) << "Overdwell on cylinder " << (int)event->coilIndex << " of " << actualDwell << " ms";
41 }
42 555 };
43
44
3/3
✓ Branch 1 taken 6342 times.
✓ Branch 3 taken 6334 times.
✓ Branch 4 taken 8 times.
0/1
? Decision couldn't be analyzed.
6342 while (reader.haveMore()) {
45
1/1
✓ Branch 1 taken 6334 times.
6334 reader.processLine(&eth);
46 }
47
48
2/6
✓ Branch 4 taken 8 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 8 times.
✗ Branch 12 not taken.
✗ Branch 16 not taken.
✗ Branch 19 not taken.
8 ASSERT_EQ(expectedBailedOnDwellCount, engine->getBailedOnDwellCount())
49
1/3
✗ Branch 1 not taken.
✓ Branch 5 taken 8 times.
✗ Branch 6 not taken.
8 << "Please check if our dwell algorithm have really got better.";
50 8 }
51
52 // noisy-trigger-min.csv contains lines 53-61 from noisy-trigger-1.csv - minimal subset to reproduce the single
53 // bailed-on dwell
54 4 TEST(RealNoisyTrigger, AvoidOverdwellMinNoInstant) {
55 1 testNoOverdwell("tests/trigger/resources/noisy-trigger-min.csv", false, 0);
56 1 }
57
58 4 TEST(RealNoisyTrigger, AvoidOverdwellMinWithInstant) {
59 1 testNoOverdwell("tests/trigger/resources/noisy-trigger-min.csv", true, 1);
60 1 }
61
62 4 TEST(RealNoisyTrigger, AvoidOverdwell1NoInstant) {
63 1 testNoOverdwell("tests/trigger/resources/noisy-trigger-1.csv", false, 24);
64 1 }
65
66 4 TEST(RealNoisyTrigger, AvoidOverdwell1WithInstant) {
67 1 testNoOverdwell("tests/trigger/resources/noisy-trigger-1.csv", true, 23);
68 1 }
69
70 4 TEST(RealNoisyTrigger, AvoidOverdwell2NoInstant) {
71 1 testNoOverdwell("tests/trigger/resources/noisy-trigger-2.csv", false, 89);
72 1 }
73
74 4 TEST(RealNoisyTrigger, AvoidOverdwell2WithInstant) {
75 1 testNoOverdwell("tests/trigger/resources/noisy-trigger-2.csv", true, 85);
76 1 }
77
78 4 TEST(RealNoisyTrigger, AvoidOverdwell3NoInstant) {
79 1 testNoOverdwell("tests/trigger/resources/noisy-trigger-3.csv", false, 25);
80 1 }
81
82 4 TEST(RealNoisyTrigger, AvoidOverdwell3WithInstant) {
83 1 testNoOverdwell("tests/trigger/resources/noisy-trigger-3.csv", true, 22);
84 1 }
85