diff --git a/unit_tests/tests/ignition_injection/test_hd_cranking.cpp b/unit_tests/tests/ignition_injection/test_hd_cranking.cpp new file mode 100644 index 0000000000..4ab24cccf8 --- /dev/null +++ b/unit_tests/tests/ignition_injection/test_hd_cranking.cpp @@ -0,0 +1,43 @@ +// file test_hd_cranking.cpp + +#include "pch.h" +#include "logicdata_csv_reader.h" + +TEST(harley, cranking) { + CsvReader reader(1, /* vvtCount */ 1); + reader.open("tests/ignition_injection/resources/hd-req-sync_3.csv"); + + EngineTestHelper eth(engine_type_e::HARLEY); + + bool gotRpm = false; + bool gotSync = false; + bool prevSync = false; + + while (reader.haveMore()) { + reader.processLine(ð); + + engine->rpmCalculator.onSlowCallback(); + + // whole pattern is a copy-paste from test_real_4b11.cpp, is better API possible? + auto rpm = Sensor::getOrZero(SensorType::Rpm); + if (!gotRpm && rpm) { + gotRpm = true; + + // We should get first RPM on exactly the first sync point - this means the instant RPM pre-sync event copy all worked OK + EXPECT_EQ(reader.lineIndex(), 56); + EXPECT_NEAR(rpm, 87, 1); + } + + if (!gotSync && engine->triggerCentral.triggerState.hasSynchronizedPhase()) { + EXPECT_EQ(reader.lineIndex(), 83); + gotSync = true; + } + + if (gotSync) { + // we have loss of sync, interesting! +// EXPECT_TRUE(engine->triggerCentral.triggerState.hasSynchronizedPhase()) << "Loss " << reader.lineIndex(); + } + } + + ASSERT_EQ(6, engine->triggerCentral.triggerState.camResyncCounter); // interesting! +} diff --git a/unit_tests/tests/tests.mk b/unit_tests/tests/tests.mk index 95a6ef4492..c6d5b85657 100644 --- a/unit_tests/tests/tests.mk +++ b/unit_tests/tests/tests.mk @@ -42,6 +42,7 @@ TESTS_SRC_CPP = \ tests/ignition_injection/injection_mode_transition.cpp \ tests/ignition_injection/test_startOfCrankingPrimingPulse.cpp \ tests/ignition_injection/test_multispark.cpp \ + tests/ignition_injection/test_hd_cranking.cpp \ tests/ignition_injection/test_ignition_scheduling.cpp \ tests/ignition_injection/test_fuelCut.cpp \ tests/ignition_injection/test_fuel_computer.cpp \