From 133b1689bb538621e57765c731fea0ecb506b663 Mon Sep 17 00:00:00 2001 From: rusefi Date: Sun, 4 Mar 2018 21:02:35 -0500 Subject: [PATCH] better state validation --- firmware/controllers/trigger/trigger_central.cpp | 4 ++++ firmware/controllers/trigger/trigger_central.h | 1 + unit_tests/test_trigger_decoder.cpp | 2 ++ 3 files changed, 7 insertions(+) diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp index 12aeb3e740..7c8efd196f 100644 --- a/firmware/controllers/trigger/trigger_central.cpp +++ b/firmware/controllers/trigger/trigger_central.cpp @@ -598,6 +598,10 @@ bool checkIfTriggerConfigChanged(void) { return result; } +bool readIfTriggerConfigChangedForUnitTest(void) { + return isTriggerConfigChanged; +} + void initTriggerCentral(Logging *sharedLogger) { logger = sharedLogger; strcpy((char*) shaft_signal_msg_index, "x_"); diff --git a/firmware/controllers/trigger/trigger_central.h b/firmware/controllers/trigger/trigger_central.h index ac5d4845b8..2fe2f3a503 100644 --- a/firmware/controllers/trigger/trigger_central.h +++ b/firmware/controllers/trigger/trigger_central.h @@ -65,5 +65,6 @@ void resetMaxValues(); void onConfigurationChangeTriggerCallback(engine_configuration_s *previousConfiguration DECLARE_ENGINE_PARAMETER_SUFFIX); bool checkIfTriggerConfigChanged(void); +bool readIfTriggerConfigChangedForUnitTest(void); #endif /* TRIGGER_CENTRAL_H_ */ diff --git a/unit_tests/test_trigger_decoder.cpp b/unit_tests/test_trigger_decoder.cpp index b553554f11..1fabdf641a 100644 --- a/unit_tests/test_trigger_decoder.cpp +++ b/unit_tests/test_trigger_decoder.cpp @@ -632,9 +632,11 @@ void setupSimpleTestEngineWithMafAndTT_ONE_trigger(EngineTestHelper *eth) { engine->updateSlowSensors(PASS_ENGINE_PARAMETER_SIGNATURE); assertEqualsM("CLT", 70, engine->sensors.clt); + assertEqualsM("trigger #1", 0, readIfTriggerConfigChangedForUnitTest()); engineConfiguration->trigger.type = TT_ONE; incrementGlobalConfigurationVersion(PASS_ENGINE_PARAMETER_SIGNATURE); + assertEqualsM("trigger #2", 1, readIfTriggerConfigChangedForUnitTest()); eth->applyTriggerShape();