mirror of https://github.com/FOME-Tech/fome-fw.git
reducing global state in unit tests
This commit is contained in:
parent
5fc02174d4
commit
72cc52add6
|
@ -137,7 +137,7 @@ engine_configuration_s activeConfiguration;
|
||||||
|
|
||||||
extern engine_configuration_s *engineConfiguration;
|
extern engine_configuration_s *engineConfiguration;
|
||||||
|
|
||||||
void rememberCurrentConfiguration(void) {
|
void rememberCurrentConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
memcpy(&activeConfiguration, engineConfiguration, sizeof(engine_configuration_s));
|
memcpy(&activeConfiguration, engineConfiguration, sizeof(engine_configuration_s));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,12 +149,17 @@ int getGlobalConfigurationVersion(void) {
|
||||||
return globalConfigurationVersion;
|
return globalConfigurationVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern LoggingWithStorage sharedLogger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* this is the top-level method which should be called in case of any changes to engine configuration
|
* this is the top-level method which should be called in case of any changes to engine configuration
|
||||||
* online tuning of most values in the maps does not count as configuration change, but 'Burn' command does
|
* online tuning of most values in the maps does not count as configuration change, but 'Burn' command does
|
||||||
*/
|
*/
|
||||||
void incrementGlobalConfigurationVersion(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
void incrementGlobalConfigurationVersion(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
globalConfigurationVersion++;
|
globalConfigurationVersion++;
|
||||||
|
#if EFI_DEFAILED_LOGGING
|
||||||
|
scheduleMsg(&sharedLogger, "set globalConfigurationVersion=%d", globalConfigurationVersion);
|
||||||
|
#endif /* EFI_DEFAILED_LOGGING */
|
||||||
/**
|
/**
|
||||||
* All these callbacks could be implemented as listeners, but these days I am saving RAM
|
* All these callbacks could be implemented as listeners, but these days I am saving RAM
|
||||||
*/
|
*/
|
||||||
|
@ -182,7 +187,7 @@ void incrementGlobalConfigurationVersion(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
|
|
||||||
onConfigurationChangeFsioCallback(&activeConfiguration PASS_ENGINE_PARAMETER_SUFFIX);
|
onConfigurationChangeFsioCallback(&activeConfiguration PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
|
|
||||||
rememberCurrentConfiguration();
|
rememberCurrentConfiguration(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -67,7 +67,7 @@ void setDefaultBasePins(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||||
void setDefaultSerialParameters(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
void setDefaultSerialParameters(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||||
void setDefaultSdCardParameters(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
void setDefaultSdCardParameters(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||||
|
|
||||||
void rememberCurrentConfiguration(void);
|
void rememberCurrentConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||||
void incrementGlobalConfigurationVersion(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
void incrementGlobalConfigurationVersion(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||||
int getGlobalConfigurationVersion(void);
|
int getGlobalConfigurationVersion(void);
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,10 @@
|
||||||
|
|
||||||
#define EFI_GPIO_HARDWARE FALSE
|
#define EFI_GPIO_HARDWARE FALSE
|
||||||
|
|
||||||
|
#define FUEL_MATH_EXTREME_LOGGING FALSE
|
||||||
|
|
||||||
|
#define EFI_DEFAILED_LOGGING FALSE
|
||||||
|
|
||||||
#define EFI_UNIT_TEST TRUE
|
#define EFI_UNIT_TEST TRUE
|
||||||
|
|
||||||
#define EFI_FSIO TRUE
|
#define EFI_FSIO TRUE
|
||||||
|
|
|
@ -35,15 +35,11 @@
|
||||||
#include "test_engine_math.h"
|
#include "test_engine_math.h"
|
||||||
#include "test_trigger_decoder.h"
|
#include "test_trigger_decoder.h"
|
||||||
|
|
||||||
|
|
||||||
typedef int32_t msg_t;
|
typedef int32_t msg_t;
|
||||||
|
|
||||||
#include "hal_streams.h"
|
#include "hal_streams.h"
|
||||||
#include "memstreams.h"
|
#include "memstreams.h"
|
||||||
|
|
||||||
static engine_configuration_s ec;
|
|
||||||
engine_configuration_s *engineConfiguration = &ec;
|
|
||||||
|
|
||||||
int timeNowUs = 0;
|
int timeNowUs = 0;
|
||||||
|
|
||||||
efitimeus_t getTimeNowUs(void) {
|
efitimeus_t getTimeNowUs(void) {
|
||||||
|
@ -54,6 +50,8 @@ efitick_t getTimeNowNt(void) {
|
||||||
return getTimeNowUs() * US_TO_NT_MULTIPLIER;
|
return getTimeNowUs() * US_TO_NT_MULTIPLIER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LoggingWithStorage sharedLogger("main");
|
||||||
|
|
||||||
extern int revolutionCounterSinceBootForUnitTest;
|
extern int revolutionCounterSinceBootForUnitTest;
|
||||||
|
|
||||||
int getRevolutionCounter(void) {
|
int getRevolutionCounter(void) {
|
||||||
|
|
Loading…
Reference in New Issue