reducing global state in unit tests
This commit is contained in:
parent
defb52a6e0
commit
e6d368d6f7
|
@ -137,7 +137,7 @@ engine_configuration_s activeConfiguration;
|
|||
|
||||
extern engine_configuration_s *engineConfiguration;
|
||||
|
||||
void rememberCurrentConfiguration(void) {
|
||||
void rememberCurrentConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||
memcpy(&activeConfiguration, engineConfiguration, sizeof(engine_configuration_s));
|
||||
}
|
||||
|
||||
|
@ -149,12 +149,17 @@ int getGlobalConfigurationVersion(void) {
|
|||
return globalConfigurationVersion;
|
||||
}
|
||||
|
||||
extern LoggingWithStorage sharedLogger;
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
void incrementGlobalConfigurationVersion(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||
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
|
||||
*/
|
||||
|
@ -182,7 +187,7 @@ void incrementGlobalConfigurationVersion(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
|||
|
||||
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 setDefaultSdCardParameters(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||
|
||||
void rememberCurrentConfiguration(void);
|
||||
void rememberCurrentConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||
void incrementGlobalConfigurationVersion(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||
int getGlobalConfigurationVersion(void);
|
||||
|
||||
|
|
|
@ -14,6 +14,10 @@
|
|||
|
||||
#define EFI_GPIO_HARDWARE FALSE
|
||||
|
||||
#define FUEL_MATH_EXTREME_LOGGING FALSE
|
||||
|
||||
#define EFI_DEFAILED_LOGGING FALSE
|
||||
|
||||
#define EFI_UNIT_TEST TRUE
|
||||
|
||||
#define EFI_FSIO TRUE
|
||||
|
|
|
@ -35,15 +35,11 @@
|
|||
#include "test_engine_math.h"
|
||||
#include "test_trigger_decoder.h"
|
||||
|
||||
|
||||
typedef int32_t msg_t;
|
||||
|
||||
#include "hal_streams.h"
|
||||
#include "memstreams.h"
|
||||
|
||||
static engine_configuration_s ec;
|
||||
engine_configuration_s *engineConfiguration = &ec;
|
||||
|
||||
int timeNowUs = 0;
|
||||
|
||||
efitimeus_t getTimeNowUs(void) {
|
||||
|
@ -54,6 +50,8 @@ efitick_t getTimeNowNt(void) {
|
|||
return getTimeNowUs() * US_TO_NT_MULTIPLIER;
|
||||
}
|
||||
|
||||
LoggingWithStorage sharedLogger("main");
|
||||
|
||||
extern int revolutionCounterSinceBootForUnitTest;
|
||||
|
||||
int getRevolutionCounter(void) {
|
||||
|
|
Loading…
Reference in New Issue