From a72d2834fbca02ce5b4a69c023d9494dff5d0099 Mon Sep 17 00:00:00 2001 From: rusefi Date: Fri, 20 Sep 2019 00:46:35 -0400 Subject: [PATCH] unit tests progress --- firmware/controllers/actuators/idle_thread.cpp | 1 + firmware/controllers/engine_controller.cpp | 8 ++++---- unit_tests/tests/test_idle_controller.cpp | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/firmware/controllers/actuators/idle_thread.cpp b/firmware/controllers/actuators/idle_thread.cpp index 1a8fe4d866..765d738018 100644 --- a/firmware/controllers/actuators/idle_thread.cpp +++ b/firmware/controllers/actuators/idle_thread.cpp @@ -311,6 +311,7 @@ static percent_t automaticIdleController(DECLARE_ENGINE_PARAMETER_SIGNATURE) { } void IdleController::PeriodicTask() { + efiAssertVoid(OBD_PCM_Processor_Fault, engineConfiguration != NULL, "engineConfiguration pointer"); /* * Here we have idle logic thread - actual stepper movement is implemented in a separate * working thread, diff --git a/firmware/controllers/engine_controller.cpp b/firmware/controllers/engine_controller.cpp index b03ab298d1..253cc60b25 100644 --- a/firmware/controllers/engine_controller.cpp +++ b/firmware/controllers/engine_controller.cpp @@ -90,6 +90,10 @@ // this method is used by real firmware and simulator and unit test void mostCommonInitEngineController(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) { +#if EFI_IDLE_CONTROL + startIdleThread(sharedLogger PASS_ENGINE_PARAMETER_SUFFIX); +#endif /* EFI_IDLE_CONTROL */ + initSensors(sharedLogger PASS_ENGINE_PARAMETER_SUFFIX); initAccelEnrichment(sharedLogger PASS_ENGINE_PARAMETER_SUFFIX); #if EFI_FSIO @@ -658,10 +662,6 @@ void commonInitEngineController(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_S initSensorChart(); #endif /* EFI_SENSOR_CHART */ -#if EFI_IDLE_CONTROL - startIdleThread(sharedLogger PASS_ENGINE_PARAMETER_SUFFIX); -#endif /* EFI_IDLE_CONTROL */ - #if EFI_PROD_CODE || EFI_SIMULATOR // todo: this is a mess, remove code duplication with simulator initSettings(); diff --git a/unit_tests/tests/test_idle_controller.cpp b/unit_tests/tests/test_idle_controller.cpp index 0ff071e6b3..3daa1b86ab 100644 --- a/unit_tests/tests/test_idle_controller.cpp +++ b/unit_tests/tests/test_idle_controller.cpp @@ -40,7 +40,7 @@ TEST(idle, fsioPidParameters) { // timeNowUs = MS2US(700); -// idleControllerInstance.PeriodicTask(); + idleControllerInstance.PeriodicTask(); // ASSERT_EQ(0, engine->acSwitchLastChangeTime); // ASSERT_EQ(1, engine->acSwitchState);