From b72e7952cdad25e67ed506c1740072e61b7b2fa6 Mon Sep 17 00:00:00 2001 From: rusefi Date: Sun, 4 Mar 2018 16:13:23 -0500 Subject: [PATCH] #571 skeleton --- .../trigger/main_trigger_callback.cpp | 5 +++- unit_tests/main.cpp | 4 +++ unit_tests/test.mk | 1 + .../test_startOfCrankingPrimingPulse.cpp | 27 +++++++++++++++++++ unit_tests/test_startOfCrankingPrimingPulse.h | 16 +++++++++++ unit_tests/test_trigger_decoder.cpp | 7 +++-- unit_tests/test_trigger_decoder.h | 4 ++- 7 files changed, 58 insertions(+), 6 deletions(-) create mode 100644 unit_tests/test_startOfCrankingPrimingPulse.cpp create mode 100644 unit_tests/test_startOfCrankingPrimingPulse.h diff --git a/firmware/controllers/trigger/main_trigger_callback.cpp b/firmware/controllers/trigger/main_trigger_callback.cpp index 2fc1b3bbfe..b4af71af6d 100644 --- a/firmware/controllers/trigger/main_trigger_callback.cpp +++ b/firmware/controllers/trigger/main_trigger_callback.cpp @@ -526,7 +526,10 @@ static bool isPrimeInjectionPulseSkipped(DECLARE_ENGINE_PARAMETER_SIGNATURE) { return CONFIG(isCylinderCleanupEnabled) && (getTPS(PASS_ENGINE_PARAMETER_SIGNATURE) > CLEANUP_MODE_TPS); } -// Prime injection pulse, mainly needed for mono-injectors or long intake manifolds. +/** + * Prime injection pulse, mainly needed for mono-injectors or long intake manifolds. + * See testStartOfCrankingPrimingPulse() + */ static void startPrimeInjectionPulse(DECLARE_ENGINE_PARAMETER_SIGNATURE) { #if EFI_PROD_CODE || defined(__DOXYGEN__) // First, we need a protection against 'fake' ignition switch on and off (i.e. no engine started), to avoid repeated prime pulses. diff --git a/unit_tests/main.cpp b/unit_tests/main.cpp index 6633a7f0e0..547d83dd80 100644 --- a/unit_tests/main.cpp +++ b/unit_tests/main.cpp @@ -28,12 +28,14 @@ #include "afm2mapConverter.h" #include "test_signal_executor.h" #include "trigger_central.h" +#include "test_startOfCrankingPrimingPulse.h" #include "test_util.h" #include "map_resize.h" #include "engine_math.h" #include "test_engine_math.h" #include "test_trigger_decoder.h" + typedef int32_t msg_t; #include "hal_streams.h" @@ -72,6 +74,8 @@ int main(void) { testOverflow64Counter(); testInterpolate3d(); testFindIndex(); + testPlainCrankingWithoutAdvancedFeatures(); + testStartOfCrankingPrimingPulse(); testInterpolate2d(); testGpsParser(); testMisc(); diff --git a/unit_tests/test.mk b/unit_tests/test.mk index d58f119854..fd0586fccd 100644 --- a/unit_tests/test.mk +++ b/unit_tests/test.mk @@ -4,6 +4,7 @@ TEST_SRC_CPP = test_util.cpp \ test_basic_math/test_find_index.cpp \ test_basic_math/test_interpolation_3d.cpp \ test_data_structures/test_engine_math.cpp \ + test_startOfCrankingPrimingPulse.cpp \ test_idle_controller.cpp \ test_trigger_decoder.cpp \ test_fuel_map.cpp \ diff --git a/unit_tests/test_startOfCrankingPrimingPulse.cpp b/unit_tests/test_startOfCrankingPrimingPulse.cpp new file mode 100644 index 0000000000..a7d73f928e --- /dev/null +++ b/unit_tests/test_startOfCrankingPrimingPulse.cpp @@ -0,0 +1,27 @@ +/* + * test_startOfCrankingPrimingPulse.cpp + * + * Created on: Mar 4, 2018 + * @author Andrey Belomutskiy, (c) 2012-2018 + */ + +#include "test_startOfCrankingPrimingPulse.h" +#include "test_trigger_decoder.h" + +void testPlainCrankingWithoutAdvancedFeatures() { + // this is just a reference unit test implementation + printf("*************************************************** testPlainCrankingWithoutAdvancedFeatures\r\n"); + + EngineTestHelper eth(TEST_ENGINE); + EXPAND_EngineTestHelper + + assertEqualsM("RPM=0", 0, engine->rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE)); + + +} + + +void testStartOfCrankingPrimingPulse() { + +} + diff --git a/unit_tests/test_startOfCrankingPrimingPulse.h b/unit_tests/test_startOfCrankingPrimingPulse.h new file mode 100644 index 0000000000..6a8ae43ac7 --- /dev/null +++ b/unit_tests/test_startOfCrankingPrimingPulse.h @@ -0,0 +1,16 @@ +/* + * test_startOfCrankingPrimingPulse.h + * + * Created on: Mar 4, 2018 + * @author Andrey Belomutskiy, (c) 2012-2018 + */ + +#ifndef TEST_STARTOFCRANKINGPRIMINGPULSE_H_ +#define TEST_STARTOFCRANKINGPRIMINGPULSE_H_ + +#include "main.h" + +void testPlainCrankingWithoutAdvancedFeatures(); +void testStartOfCrankingPrimingPulse(); + +#endif /* TEST_STARTOFCRANKINGPRIMINGPULSE_H_ */ diff --git a/unit_tests/test_trigger_decoder.cpp b/unit_tests/test_trigger_decoder.cpp index 15bddf6a16..13344d3c03 100644 --- a/unit_tests/test_trigger_decoder.cpp +++ b/unit_tests/test_trigger_decoder.cpp @@ -26,7 +26,6 @@ #include "main_trigger_callback.h" #include "engine.h" #include "advance_map.h" -#include "engine_test_helper.h" #include "speed_density.h" #include "fuel_math.h" #include "spark_logic.h" @@ -615,7 +614,7 @@ static void assertInjectionEvent(const char *msg, InjectionEvent *ev, int inject assertEqualsM4(msg, " event offset", angleOffset, ev->injectionStart.angleOffset); } -static void setTestBug299small(EngineTestHelper *eth) { +void setupSimpleTestEngineWithMafAndTT_ONE_trigger(EngineTestHelper *eth) { Engine *engine = ð->engine; EXPAND_Engine @@ -644,7 +643,7 @@ static void setTestBug299small(EngineTestHelper *eth) { } static void setTestBug299(EngineTestHelper *eth) { - setTestBug299small(eth); + setupSimpleTestEngineWithMafAndTT_ONE_trigger(eth); Engine *engine = ð->engine; EXPAND_Engine @@ -1277,7 +1276,7 @@ void testMissedSpark299(void) { EXPAND_EngineTestHelper engineConfiguration->ignitionMode = IM_WASTED_SPARK; engineConfiguration->useOnlyRisingEdgeForTrigger = false; - setTestBug299small(ð); + setupSimpleTestEngineWithMafAndTT_ONE_trigger(ð); engineConfiguration->isIgnitionEnabled = true; engineConfiguration->isInjectionEnabled = false; diff --git a/unit_tests/test_trigger_decoder.h b/unit_tests/test_trigger_decoder.h index 048acb19f8..d5f78daf62 100644 --- a/unit_tests/test_trigger_decoder.h +++ b/unit_tests/test_trigger_decoder.h @@ -8,6 +8,8 @@ #ifndef TEST_TRIGGER_DECODER_H_ #define TEST_TRIGGER_DECODER_H_ +#include "engine_test_helper.h" + void testTriggerDecoder(void); void testFuelSchedulerBug299smallAndMedium(void); void testFuelSchedulerBug299smallAndLarge(void); @@ -18,6 +20,6 @@ void testRpmCalculator(void); void testStartupFuelPumping(void); void test1995FordInline6TriggerDecoder(void); void testTriggerDecoder2(const char *msg, engine_type_e type, int synchPointIndex, float channel1duty, float channel2duty); - +void setupSimpleTestEngineWithMafAndTT_ONE_trigger(EngineTestHelper *eth); #endif /* TEST_TRIGGER_DECODER_H_ */