| Line | Branch | Decision | Exec | Source |
|---|---|---|---|---|
| 1 | #include "pch.h" | |||
| 2 | ||||
| 3 | #include "engine_csv_reader.h" | |||
| 4 | ||||
| 5 | 4 | TEST(real, SubaruEj20gcranking_only_cam7) { | ||
| 6 |
1/1✓ Branch 2 taken 1 time.
|
1 | EngineCsvReader reader(/*triggerCount*/ 1, /* vvtCount */ 0); | |
| 7 | ||||
| 8 | /* 0 - cam | |||
| 9 | * 1 - crank */ | |||
| 10 |
1/1✓ Branch 1 taken 1 time.
|
1 | reader.open("tests/trigger/resources/subaru_6_7.csv"); | |
| 11 | ||||
| 12 |
1/1✓ Branch 2 taken 1 time.
|
1 | EngineTestHelper eth(engine_type_e::TEST_ENGINE); | |
| 13 | 1 | engineConfiguration->invertPrimaryTriggerSignal = true; | ||
| 14 | ||||
| 15 | // setVerboseTrigger(true); | |||
| 16 |
1/1✓ Branch 1 taken 1 time.
|
1 | eth.setTriggerType(trigger_type_e::TT_VVT_SUBARU_7_WITHOUT_6); | |
| 17 | ||||
| 18 |
3/3✓ Branch 1 taken 242 times.
✓ Branch 3 taken 241 times.
✓ Branch 4 taken 1 time.
|
0/1? Decision couldn't be analyzed.
|
242 | while (reader.haveMore()) { |
| 19 |
1/1✓ Branch 1 taken 241 times.
|
241 | reader.processLine(ð); | |
| 20 |
1/1✓ Branch 1 taken 241 times.
|
241 | reader.assertFirstRpm(240, /*expectedFirstRpmAtIndex*/38); | |
| 21 | } | |||
| 22 | ||||
| 23 |
2/8✗ Branch 3 not taken.
✓ Branch 4 taken 1 time.
✗ Branch 7 not taken.
✗ Branch 12 not taken.
✗ Branch 16 not taken.
✗ Branch 19 not taken.
✓ Branch 28 taken 1 time.
✗ Branch 29 not taken.
|
1 | ASSERT_TRUE(reader.gotRpm); | |
| 24 |
2/8✗ Branch 5 not taken.
✓ Branch 6 taken 1 time.
✗ Branch 9 not taken.
✗ Branch 14 not taken.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
✓ Branch 30 taken 1 time.
✗ Branch 31 not taken.
|
1 | ASSERT_FALSE(reader.gotSync); | |
| 25 | ||||
| 26 | // this currently fails | |||
| 27 | //ASSERT_EQ(0u, eth.recentWarnings()->getCount()); | |||
| 28 | 1 | } | ||
| 29 | ||||
| 30 | 4 | TEST(real, SubaruEj20gDefaultCranking) { | ||
| 31 |
1/1✓ Branch 2 taken 1 time.
|
1 | EngineCsvReader reader(/*triggerCount*/ 2, /* vvtCount */ 0); | |
| 32 | ||||
| 33 | /* 0 - cam | |||
| 34 | * 1 - crank */ | |||
| 35 |
1/1✓ Branch 1 taken 1 time.
|
1 | reader.open("tests/trigger/resources/subaru_6_7.csv"); | |
| 36 | ||||
| 37 |
1/1✓ Branch 2 taken 1 time.
|
1 | EngineTestHelper eth(engine_type_e::TEST_ENGINE); | |
| 38 | //setVerboseTrigger(true); | |||
| 39 |
1/1✓ Branch 1 taken 1 time.
|
1 | eth.setTriggerType(trigger_type_e::TT_SUBARU_7_6); | |
| 40 | 1 | engineConfiguration->invertPrimaryTriggerSignal = true; | ||
| 41 | 1 | engineConfiguration->invertSecondaryTriggerSignal = true; | ||
| 42 | ||||
| 43 | 1 | engineConfiguration->isFasterEngineSpinUpEnabled = true; | ||
| 44 | 1 | engineConfiguration->alwaysInstantRpm = true; | ||
| 45 | ||||
| 46 | 1 | int n = 0; | ||
| 47 | 1 | bool firstRpm = false; | ||
| 48 |
3/3✓ Branch 1 taken 242 times.
✓ Branch 3 taken 241 times.
✓ Branch 4 taken 1 time.
|
0/1? Decision couldn't be analyzed.
|
242 | while (reader.haveMore()) { |
| 49 |
1/1✓ Branch 1 taken 241 times.
|
241 | reader.processLine(ð); | |
| 50 | ||||
| 51 |
1/1✓ Branch 1 taken 241 times.
|
241 | reader.assertFirstRpm(193, /*expectedFirstRpmAtIndex*/38); | |
| 52 | ||||
| 53 | //printf("%5d: RPM %f\n", n++, Sensor::getOrZero(SensorType::Rpm)); | |||
| 54 |
1/1✓ Branch 1 taken 241 times.
|
241 | auto rpm = Sensor::getOrZero(SensorType::Rpm); | |
| 55 |
4/4✓ Branch 0 taken 204 times.
✓ Branch 1 taken 37 times.
✓ Branch 2 taken 1 time.
✓ Branch 3 taken 203 times.
|
2/2✓ Decision 'true' taken 1 time.
✓ Decision 'false' taken 240 times.
|
241 | if ((rpm) && (!firstRpm)) { |
| 56 |
1/1✓ Branch 1 taken 1 time.
|
1 | printf("Got first RPM %f, at %d\n", rpm, n); | |
| 57 | 1 | firstRpm = true; | ||
| 58 | } | |||
| 59 |
3/4✓ Branch 0 taken 37 times.
✓ Branch 1 taken 204 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 37 times.
|
1/2✗ Decision 'true' not taken.
✓ Decision 'false' taken 241 times.
|
241 | if ((rpm == 0) && (firstRpm)) { |
| 60 | ✗ | printf("Lost RPM at %d\n", n); | ||
| 61 | ✗ | firstRpm = false; | ||
| 62 | } | |||
| 63 | 241 | n++; | ||
| 64 | } | |||
| 65 | 2 | } | ||
| 66 | ||||
| 67 | 4 | TEST(real, SubaruEj20gCrankingWot) { | ||
| 68 |
1/1✓ Branch 2 taken 1 time.
|
1 | EngineCsvReader reader(/*triggerCount*/ 2, /* vvtCount */ 0); | |
| 69 | ||||
| 70 | /* 0 - cam | |||
| 71 | * 1 - crank */ | |||
| 72 |
1/1✓ Branch 1 taken 1 time.
|
1 | reader.open("tests/trigger/resources/subaru_6_7_wot.csv"); | |
| 73 | ||||
| 74 |
1/1✓ Branch 2 taken 1 time.
|
1 | EngineTestHelper eth(engine_type_e::TEST_ENGINE); | |
| 75 | //setVerboseTrigger(true); | |||
| 76 |
1/1✓ Branch 1 taken 1 time.
|
1 | eth.setTriggerType(trigger_type_e::TT_SUBARU_7_6); | |
| 77 | 1 | engineConfiguration->invertPrimaryTriggerSignal = true; | ||
| 78 | 1 | engineConfiguration->invertSecondaryTriggerSignal = true; | ||
| 79 | ||||
| 80 | 1 | engineConfiguration->isFasterEngineSpinUpEnabled = true; | ||
| 81 | 1 | engineConfiguration->alwaysInstantRpm = true; | ||
| 82 | ||||
| 83 | 1 | int n = 0; | ||
| 84 | 1 | bool firstRpm = false; | ||
| 85 |
3/3✓ Branch 1 taken 245 times.
✓ Branch 3 taken 244 times.
✓ Branch 4 taken 1 time.
|
0/1? Decision couldn't be analyzed.
|
245 | while (reader.haveMore()) { |
| 86 |
1/1✓ Branch 1 taken 244 times.
|
244 | reader.processLine(ð); | |
| 87 | ||||
| 88 |
1/1✓ Branch 1 taken 244 times.
|
244 | reader.assertFirstRpm(188, /*expectedFirstRpmAtIndex*/32); | |
| 89 | ||||
| 90 | //printf("%5d: RPM %f\n", n++, Sensor::getOrZero(SensorType::Rpm)); | |||
| 91 |
1/1✓ Branch 1 taken 244 times.
|
244 | auto rpm = Sensor::getOrZero(SensorType::Rpm); | |
| 92 |
4/4✓ Branch 0 taken 213 times.
✓ Branch 1 taken 31 times.
✓ Branch 2 taken 1 time.
✓ Branch 3 taken 212 times.
|
2/2✓ Decision 'true' taken 1 time.
✓ Decision 'false' taken 243 times.
|
244 | if ((rpm) && (!firstRpm)) { |
| 93 |
1/1✓ Branch 1 taken 1 time.
|
1 | printf("Got first RPM %f, at %d\n", rpm, n); | |
| 94 | 1 | firstRpm = true; | ||
| 95 | } | |||
| 96 |
3/4✓ Branch 0 taken 31 times.
✓ Branch 1 taken 213 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31 times.
|
1/2✗ Decision 'true' not taken.
✓ Decision 'false' taken 244 times.
|
244 | if ((rpm == 0) && (firstRpm)) { |
| 97 | ✗ | printf("Lost RPM at %d\n", n); | ||
| 98 | ✗ | firstRpm = false; | ||
| 99 | } | |||
| 100 | 244 | n++; | ||
| 101 | } | |||
| 102 | 2 | } | ||
| 103 | ||||
| 104 | 4 | TEST(real, SubaruEj20gDefaultCranking_only_crank) { | ||
| 105 |
1/1✓ Branch 2 taken 1 time.
|
1 | EngineCsvReader reader(/*triggerCount*/ 1, /* vvtCount */ 0); | |
| 106 | ||||
| 107 | /* 1 - cam | |||
| 108 | * 0 - crank */ | |||
| 109 |
1/1✓ Branch 1 taken 1 time.
|
1 | reader.open("tests/trigger/resources/subaru_6_7_crank_first.csv"); | |
| 110 | ||||
| 111 |
1/1✓ Branch 2 taken 1 time.
|
1 | EngineTestHelper eth(engine_type_e::TEST_ENGINE); | |
| 112 | //setVerboseTrigger(true); | |||
| 113 |
1/1✓ Branch 1 taken 1 time.
|
1 | eth.setTriggerType(trigger_type_e::TT_SUBARU_7_6_CRANK); | |
| 114 | 1 | engineConfiguration->invertPrimaryTriggerSignal = true; | ||
| 115 | ||||
| 116 | 1 | engineConfiguration->isFasterEngineSpinUpEnabled = true; | ||
| 117 | 1 | engineConfiguration->alwaysInstantRpm = true; | ||
| 118 | ||||
| 119 |
3/3✓ Branch 1 taken 242 times.
✓ Branch 3 taken 241 times.
✓ Branch 4 taken 1 time.
|
0/1? Decision couldn't be analyzed.
|
242 | while (reader.haveMore()) { |
| 120 |
1/1✓ Branch 1 taken 241 times.
|
241 | reader.processLine(ð); | |
| 121 | ||||
| 122 |
1/1✓ Branch 1 taken 241 times.
|
241 | auto rpm = Sensor::getOrZero(SensorType::Rpm); | |
| 123 |
1/1✓ Branch 1 taken 241 times.
|
241 | bool hasFullSync = getTriggerCentral()->triggerState.hasSynchronizedPhase(); | |
| 124 | ||||
| 125 |
1/1✓ Branch 1 taken 241 times.
|
241 | reader.assertFirstRpm(182, /*expectedFirstRpmAtIndex*/13); | |
| 126 | } | |||
| 127 | 2 | } | ||
| 128 | ||||
| 129 | 4 | TEST(real, SubaruEj20gDefaultCrankingSeparateTrigger) { | ||
| 130 |
1/1✓ Branch 2 taken 1 time.
|
1 | EngineCsvReader reader(/*triggerCount*/ 1, /* vvtCount */ 1); | |
| 131 | ||||
| 132 | /* 1 - cam | |||
| 133 | * 0 - crank */ | |||
| 134 |
1/1✓ Branch 1 taken 1 time.
|
1 | reader.open("tests/trigger/resources/subaru_6_7_crank_first.csv"); | |
| 135 | // test CSV file was captured without inversion of cam and crank signals. | |||
| 136 | // triggers are defined with SyncEdge::RiseOnly, while with real VR sensor we should rely on falling edges only. | |||
| 137 | // FallOnly is not supported (yet?). So trigger is defined as SyncEdge::RiseOnly and with 1 degree tooth width. | |||
| 138 | // setting both crank and cam inversion allows us to feed trigger decoder with correct (falling) edges. | |||
| 139 | ||||
| 140 |
1/1✓ Branch 2 taken 1 time.
|
1 | EngineTestHelper eth(engine_type_e::TEST_ENGINE); | |
| 141 | //setVerboseTrigger(true); | |||
| 142 | 1 | engineConfiguration->vvtMode[0] = VVT_SUBARU_7TOOTH; | ||
| 143 |
1/1✓ Branch 1 taken 1 time.
|
1 | eth.setTriggerType(trigger_type_e::TT_SUBARU_7_6_CRANK); | |
| 144 | 1 | engineConfiguration->invertPrimaryTriggerSignal = true; | ||
| 145 | 1 | engineConfiguration->invertCamVVTSignal = true; | ||
| 146 | ||||
| 147 | 1 | engineConfiguration->isFasterEngineSpinUpEnabled = true; | ||
| 148 | 1 | engineConfiguration->alwaysInstantRpm = true; | ||
| 149 | ||||
| 150 | 1 | bool gotFullSync = false; | ||
| 151 |
3/3✓ Branch 1 taken 242 times.
✓ Branch 3 taken 241 times.
✓ Branch 4 taken 1 time.
|
0/1? Decision couldn't be analyzed.
|
242 | while (reader.haveMore()) { |
| 152 |
1/1✓ Branch 1 taken 241 times.
|
241 | reader.processLine(ð); | |
| 153 | ||||
| 154 |
1/1✓ Branch 1 taken 241 times.
|
241 | auto rpm = Sensor::getOrZero(SensorType::Rpm); | |
| 155 |
1/1✓ Branch 1 taken 241 times.
|
241 | bool hasFullSync = getTriggerCentral()->triggerState.hasSynchronizedPhase(); | |
| 156 | ||||
| 157 |
1/1✓ Branch 1 taken 241 times.
|
241 | reader.assertFirstRpm(182, /*expectedFirstRpmAtIndex*/13); | |
| 158 | if (0) { | |||
| 159 | float vvt = engine->triggerCentral.getVVTPosition(/*bankIndex*/0, /*camIndex*/0); | |||
| 160 | printf("%5d: RPM %f, hasFullSync %d, vvt = %f\n", reader.lineIndex(), Sensor::getOrZero(SensorType::Rpm), hasFullSync, vvt); | |||
| 161 | } | |||
| 162 | ||||
| 163 |
5/6✓ Branch 0 taken 38 times.
✓ Branch 1 taken 203 times.
✓ Branch 2 taken 1 time.
✓ Branch 3 taken 37 times.
✓ Branch 4 taken 1 time.
✗ Branch 5 not taken.
|
2/2✓ Decision 'true' taken 1 time.
✓ Decision 'false' taken 240 times.
|
241 | if (!gotFullSync && hasFullSync && rpm) { |
| 164 | 1 | gotFullSync = true; | ||
| 165 | ||||
| 166 | // Should get full sync and non-zero RPM | |||
| 167 |
2/6✓ Branch 5 taken 1 time.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 time.
✗ Branch 14 not taken.
✗ Branch 19 not taken.
✗ Branch 22 not taken.
|
1 | EXPECT_EQ(reader.lineIndex(), 38); | |
| 168 |
2/6✓ 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.
|
1 | EXPECT_NEAR(rpm, 220.0f, 1.0f); | |
| 169 | } | |||
| 170 | } | |||
| 171 | 2 | } | ||
| 172 | ||||
| 173 | // Following test loses hasFullSync twice | |||
| 174 | // Test also has RPM falling to zero twice | |||
| 175 | // While real car was runnig fine while capturing this CSV | |||
| 176 | // TODO: investigate | |||
| 177 | 4 | TEST(real, SubaruEj20gDefaultRev) { | ||
| 178 |
1/1✓ Branch 2 taken 1 time.
|
1 | EngineCsvReader reader(/*triggerCount*/ 1, /* vvtCount */ 1); | |
| 179 | ||||
| 180 | /* 1 - cam | |||
| 181 | * 0 - crank */ | |||
| 182 |
1/1✓ Branch 1 taken 1 time.
|
1 | reader.open("tests/trigger/resources/subaru_6_7_rev.csv"); | |
| 183 | ||||
| 184 |
1/1✓ Branch 2 taken 1 time.
|
1 | EngineTestHelper eth(engine_type_e::TEST_ENGINE); | |
| 185 | //setVerboseTrigger(true); | |||
| 186 | 1 | engineConfiguration->vvtMode[0] = VVT_SUBARU_7TOOTH; | ||
| 187 |
1/1✓ Branch 1 taken 1 time.
|
1 | eth.setTriggerType(trigger_type_e::TT_SUBARU_7_6_CRANK); | |
| 188 | 1 | engineConfiguration->invertPrimaryTriggerSignal = false; | ||
| 189 | 1 | engineConfiguration->invertCamVVTSignal = false; | ||
| 190 | ||||
| 191 | 1 | engineConfiguration->isFasterEngineSpinUpEnabled = true; | ||
| 192 | 1 | engineConfiguration->alwaysInstantRpm = true; | ||
| 193 | ||||
| 194 | 1 | bool gotFullSync = false; | ||
| 195 |
3/3✓ Branch 1 taken 7699 times.
✓ Branch 3 taken 7698 times.
✓ Branch 4 taken 1 time.
|
0/1? Decision couldn't be analyzed.
|
7699 | while (reader.haveMore()) { |
| 196 |
1/1✓ Branch 1 taken 7698 times.
|
7698 | reader.processLine(ð); | |
| 197 | ||||
| 198 |
1/1✓ Branch 1 taken 7698 times.
|
7698 | auto rpm = Sensor::getOrZero(SensorType::Rpm); | |
| 199 |
1/1✓ Branch 1 taken 7698 times.
|
7698 | bool hasFullSync = getTriggerCentral()->triggerState.hasSynchronizedPhase(); | |
| 200 | ||||
| 201 | //reader.assertFirstRpm(182, /*expectedFirstRpmAtIndex*/13); | |||
| 202 | if (0) { | |||
| 203 | float vvt = engine->triggerCentral.getVVTPosition(/*bankIndex*/0, /*camIndex*/0); | |||
| 204 | printf("%5d: RPM %f, hasFullSync %d, vvt = %f\n", reader.lineIndex(), Sensor::getOrZero(SensorType::Rpm), hasFullSync, vvt); | |||
| 205 | } | |||
| 206 | ||||
| 207 |
5/6✓ Branch 0 taken 37 times.
✓ Branch 1 taken 7661 times.
✓ Branch 2 taken 1 time.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 1 time.
✗ Branch 5 not taken.
|
2/2✓ Decision 'true' taken 1 time.
✓ Decision 'false' taken 7697 times.
|
7698 | if (!gotFullSync && hasFullSync && rpm) { |
| 208 | 1 | gotFullSync = true; | ||
| 209 | ||||
| 210 | // Should get full sync and non-zero RPM | |||
| 211 |
2/6✓ Branch 5 taken 1 time.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 time.
✗ Branch 14 not taken.
✗ Branch 19 not taken.
✗ Branch 22 not taken.
|
1 | EXPECT_EQ(reader.lineIndex(), 37); | |
| 212 |
2/6✓ 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.
|
1 | EXPECT_NEAR(rpm, 2174.0f, 1.0f); | |
| 213 | } | |||
| 214 | } | |||
| 215 | 2 | } | ||
| 216 |