From d576f3ba1fbe97afc7632df29620b31aa7978931 Mon Sep 17 00:00:00 2001 From: rusefi Date: Thu, 12 Sep 2019 07:31:13 -0400 Subject: [PATCH] Delayed A/C compressor switch #922 unit tests skeleton --- firmware/controllers/core/fsio_impl.cpp | 7 +------ firmware/controllers/core/fsio_impl.h | 6 ++++++ unit_tests/tests/test_idle_controller.cpp | 12 ++++++++++++ unit_tests/tests/test_logic_expression.cpp | 10 +++++++--- 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/firmware/controllers/core/fsio_impl.cpp b/firmware/controllers/core/fsio_impl.cpp index ea888a49d5..8d789a319b 100644 --- a/firmware/controllers/core/fsio_impl.cpp +++ b/firmware/controllers/core/fsio_impl.cpp @@ -29,11 +29,6 @@ */ #define NO_PWM 0 -// see useFSIO12ForIdleOffset -#define MAGIC_OFFSET_FOR_IDLE_OFFSET 12 -// see useFSIO13ForIdleMinValue -#define MAGIC_OFFSET_FOR_IDLE_MIN_VALUE 13 - // see useFSIO15ForIdleRpmAdjustment #define MAGIC_OFFSET_FOR_IDLE_TARGET_RPM 14 // see useFSIO16ForTimingAdjustment @@ -612,7 +607,7 @@ static void setFsioSetting(float humanIndexF, float value) { #endif } -static void setFsioExpression(const char *indexStr, const char *quotedLine) { +void setFsioExpression(const char *indexStr, const char *quotedLine) { #if EFI_PROD_CODE || EFI_SIMULATOR int index = atoi(indexStr) - 1; if (index < 0 || index >= FSIO_COMMAND_COUNT) { diff --git a/firmware/controllers/core/fsio_impl.h b/firmware/controllers/core/fsio_impl.h index f9e38f046f..45a4ae2026 100644 --- a/firmware/controllers/core/fsio_impl.h +++ b/firmware/controllers/core/fsio_impl.h @@ -14,6 +14,11 @@ #include "table_helper.h" #include "system_fsio.h" +// see useFSIO12ForIdleOffset +#define MAGIC_OFFSET_FOR_IDLE_OFFSET 12 +// see useFSIO13ForIdleMinValue +#define MAGIC_OFFSET_FOR_IDLE_MIN_VALUE 13 + typedef Map3D fsio8_Map3D_f32t; typedef Map3D fsio8_Map3D_u8t; @@ -30,6 +35,7 @@ void setFsioExt(int index, brain_pin_e pin, const char * exp, int pwmFrequency D void initFsioImpl(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX); void runFsio(DECLARE_ENGINE_PARAMETER_SIGNATURE); +void setFsioExpression(const char *indexStr, const char *quotedLine); float getFsioOutputValue(int index DECLARE_ENGINE_PARAMETER_SUFFIX); void applyFsioConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE); void onConfigurationChangeFsioCallback(engine_configuration_s *previousConfiguration DECLARE_ENGINE_PARAMETER_SUFFIX); diff --git a/unit_tests/tests/test_idle_controller.cpp b/unit_tests/tests/test_idle_controller.cpp index c66a57abb8..c87838c402 100644 --- a/unit_tests/tests/test_idle_controller.cpp +++ b/unit_tests/tests/test_idle_controller.cpp @@ -9,6 +9,18 @@ #include "advance_map.h" #include "tps.h" #include "pid.h" +#include "fsio_impl.h" + +TEST(idle, fsioPidParameters) { + WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + + // todo finish this unit test! + engineConfiguration->useFSIO12ForIdleOffset = true; + setFsioExpression(MAGIC_OFFSET_FOR_IDLE_OFFSET, "\"ac_on_switch cfg_idleRpmPid_offset cfg_idleRpmPid2_offset if"); + + engineConfiguration->useFSIO13ForIdleMinValue = true; + setFsioExpression(MAGIC_OFFSET_FOR_IDLE_MIN_VALUE, "\"ac_on_switch cfg_idleRpmPid_minValue cfg_idleRpmPid2_minValue if"); +} TEST(idle, pid) { print("******************************************* testPidController\r\n"); diff --git a/unit_tests/tests/test_logic_expression.cpp b/unit_tests/tests/test_logic_expression.cpp index 54d573a4c6..c24cb75dc2 100644 --- a/unit_tests/tests/test_logic_expression.cpp +++ b/unit_tests/tests/test_logic_expression.cpp @@ -107,11 +107,15 @@ static void testExpression2(float selfValue, const char *line, float expected) { testExpression2(selfValue, line, expected, engine); } -static void testExpression(const char *line, float expected) { - testExpression2(0, line, expected); +static void testExpression(const char *line, float expectedValue) { + testExpression2(0, line, expectedValue); } -TEST(misc, testLogicExpressions) { +TEST(fsio, testIfFunction) { + testExpression("1 22 33 if", 22); +} + +TEST(fsio, testLogicExpressions) { printf("*************************************************** testLogicExpressions\r\n"); testParsing();