From c9552f29bbda31b89af08a8cd751bba8c3d78676 Mon Sep 17 00:00:00 2001 From: rusefi Date: Wed, 6 Nov 2019 00:01:08 -0500 Subject: [PATCH] Missing dwell altogether in some corner cases #796 getting closer! --- .../tests/test_dwell_corner_case_issue_796.cpp | 17 +++++++++++++++++ .../tests/test_fasterEngineSpinningUp.cpp | 3 +-- unit_tests/unit_test_framework.h | 1 + 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/unit_tests/tests/test_dwell_corner_case_issue_796.cpp b/unit_tests/tests/test_dwell_corner_case_issue_796.cpp index 8b68a5bd93..33ec1d2f40 100644 --- a/unit_tests/tests/test_dwell_corner_case_issue_796.cpp +++ b/unit_tests/tests/test_dwell_corner_case_issue_796.cpp @@ -9,4 +9,21 @@ TEST(scheduler, dwellIssue796) { + WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + setupSimpleTestEngineWithMafAndTT_ONE_trigger(ð, IM_SEQUENTIAL); + + eth.fireTriggerEvents2(4 /* count */ , 600 /* ms */); + + // check if the mode is changed + ASSERT_EQ(CRANKING, engine->rpmCalculator.getState()); + // due to isFasterEngineSpinUp=true, we should have already detected RPM! + ASSERT_EQ( 100, GET_RPM()) << "spinning-RPM#1"; + ASSERT_EQ(300000, ENGINE(rpmCalculator.oneDegreeUs) * 180); + + eth.fireRise(601); + eth.fireFall(600); + ASSERT_NEAR( 99, GET_RPM(), EPS3D) << "spinning-RPM#2"; + ASSERT_EQ(303030, (int)(ENGINE(rpmCalculator.oneDegreeUs) * 180)); + + } diff --git a/unit_tests/tests/test_fasterEngineSpinningUp.cpp b/unit_tests/tests/test_fasterEngineSpinningUp.cpp index e10af9cafb..e88dad2181 100644 --- a/unit_tests/tests/test_fasterEngineSpinningUp.cpp +++ b/unit_tests/tests/test_fasterEngineSpinningUp.cpp @@ -23,8 +23,7 @@ TEST(cranking, testFasterEngineSpinningUp) { ASSERT_EQ(IM_INDIVIDUAL_COILS, getCurrentIgnitionMode(PASS_ENGINE_PARAMETER_SIGNATURE)); - eth.moveTimeForwardMs(1000 /*ms*/); - eth.firePrimaryTriggerRise(); + eth.fireRise(1000 /*ms*/); // check if it's true ASSERT_EQ(IM_SEQUENTIAL, engine->getCurrentInjectionMode(PASS_ENGINE_PARAMETER_SIGNATURE)); diff --git a/unit_tests/unit_test_framework.h b/unit_tests/unit_test_framework.h index 66e16cbe15..fd380ef299 100644 --- a/unit_tests/unit_test_framework.h +++ b/unit_tests/unit_test_framework.h @@ -15,6 +15,7 @@ // This lets us inspect private state from unit tests #define private public +#define EPS0D 1 #define EPS1D 0.1 #define EPS2D 0.01 #define EPS3D 0.001