From b590d28e7a3d29b39fdb21379cadc7b9c18bc9c4 Mon Sep 17 00:00:00 2001 From: rusefi Date: Mon, 5 Mar 2018 08:25:20 -0500 Subject: [PATCH] #563 fix #571 unit test coverage --- .../controllers/trigger/main_trigger_callback.cpp | 2 +- unit_tests/test_startOfCrankingPrimingPulse.cpp | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/firmware/controllers/trigger/main_trigger_callback.cpp b/firmware/controllers/trigger/main_trigger_callback.cpp index 271330c9fd..df0c4ce8cd 100644 --- a/firmware/controllers/trigger/main_trigger_callback.cpp +++ b/firmware/controllers/trigger/main_trigger_callback.cpp @@ -521,7 +521,7 @@ void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t trgEventIndex D // Check if the engine is not stopped or cylinder cleanup is activated static bool isPrimeInjectionPulseSkipped(DECLARE_ENGINE_PARAMETER_SIGNATURE) { - if (engine->rpmCalculator.isStopped(PASS_ENGINE_PARAMETER_SIGNATURE)) + if (!engine->rpmCalculator.isStopped(PASS_ENGINE_PARAMETER_SIGNATURE)) return true; return CONFIG(isCylinderCleanupEnabled) && (getTPS(PASS_ENGINE_PARAMETER_SIGNATURE) > CLEANUP_MODE_TPS); } diff --git a/unit_tests/test_startOfCrankingPrimingPulse.cpp b/unit_tests/test_startOfCrankingPrimingPulse.cpp index afc1c71683..0759170c0f 100644 --- a/unit_tests/test_startOfCrankingPrimingPulse.cpp +++ b/unit_tests/test_startOfCrankingPrimingPulse.cpp @@ -50,10 +50,21 @@ void testStartOfCrankingPrimingPulse() { setupSimpleTestEngineWithMafAndTT_ONE_trigger(ð); assertEqualsM("RPM=0", 0, engine->rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE)); + // this -70 value comes from CLT error handling code + assertEqualsM("CLT#1", 70, engine->sensors.clt); + + // we need below freezing temperature to get prime fuel + // todo: less cruel CLT value assignment which would survive 'updateSlowSensors' + engine->sensors.clt = -10; + // this is needed to update injectorLag +// engine->updateSlowSensors(PASS_ENGINE_PARAMETER_SIGNATURE); +// assertEqualsM("CLT#2", -10, engine->sensors.clt); + + // prod code invokes this on ECU start, here we have to mimic this behavior startPrimeInjectionPulse(PASS_ENGINE_PARAMETER_SIGNATURE); - assertEqualsM("prime fuel", 0, schedulingQueue.size()); + assertEqualsM("prime fuel", 1, schedulingQueue.size()); }