making warning codes more unit testable
This commit is contained in:
parent
e0a284a7fc
commit
b7917800c8
|
@ -37,9 +37,14 @@ extern TunerStudioOutputChannels tsOutputChannels;
|
||||||
#endif /* EFI_TUNER_STUDIO */
|
#endif /* EFI_TUNER_STUDIO */
|
||||||
|
|
||||||
WarningCodeState::WarningCodeState() {
|
WarningCodeState::WarningCodeState() {
|
||||||
|
clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void WarningCodeState::clear() {
|
||||||
warningCounter = 0;
|
warningCounter = 0;
|
||||||
lastErrorCode = 0;
|
lastErrorCode = 0;
|
||||||
timeOfPreviousWarning = -10;
|
timeOfPreviousWarning = -10;
|
||||||
|
recentWarninig.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WarningCodeState::addWarningCode(obd_code_e code) {
|
void WarningCodeState::addWarningCode(obd_code_e code) {
|
||||||
|
|
|
@ -96,7 +96,7 @@ static void printWarning(const char *fmt, va_list ap) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
int unitTestWarningCounter = 0;
|
WarningCodeState unitTestWarningCodeState;
|
||||||
|
|
||||||
#endif /* EFI_SIMULATOR || EFI_PROD_CODE */
|
#endif /* EFI_SIMULATOR || EFI_PROD_CODE */
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ bool warning(obd_code_e code, const char *fmt, ...) {
|
||||||
printWarning(fmt, ap);
|
printWarning(fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
#else
|
#else
|
||||||
unitTestWarningCounter++;
|
unitTestWarningCodeState.addWarningCode(code);
|
||||||
printf("unit_test_warning: ");
|
printf("unit_test_warning: ");
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
|
|
|
@ -17,12 +17,12 @@
|
||||||
|
|
||||||
extern int timeNowUs;
|
extern int timeNowUs;
|
||||||
extern EnginePins enginePins;
|
extern EnginePins enginePins;
|
||||||
extern int unitTestWarningCounter;
|
extern WarningCodeState unitTestWarningCodeState;
|
||||||
extern float testMafValue;
|
extern float testMafValue;
|
||||||
extern engine_configuration_s activeConfiguration;
|
extern engine_configuration_s activeConfiguration;
|
||||||
|
|
||||||
EngineTestHelper::EngineTestHelper(engine_type_e engineType) : engine (&persistentConfig) {
|
EngineTestHelper::EngineTestHelper(engine_type_e engineType) : engine (&persistentConfig) {
|
||||||
unitTestWarningCounter = 0;
|
unitTestWarningCodeState.clear();
|
||||||
|
|
||||||
// todo: make this not a global variable, we need currentTimeProvider interface on engine
|
// todo: make this not a global variable, we need currentTimeProvider interface on engine
|
||||||
timeNowUs = 0;
|
timeNowUs = 0;
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
extern int timeNowUs;
|
extern int timeNowUs;
|
||||||
extern float mockMapValue;
|
extern float mockMapValue;
|
||||||
extern float testMafValue;
|
extern float testMafValue;
|
||||||
extern int unitTestWarningCounter;
|
extern WarningCodeState unitTestWarningCodeState;
|
||||||
extern bool printTriggerDebug;
|
extern bool printTriggerDebug;
|
||||||
extern float actualSynchGap;
|
extern float actualSynchGap;
|
||||||
|
|
||||||
|
@ -1248,7 +1248,7 @@ TEST(big, testMissedSpark299) {
|
||||||
engineConfiguration->isIgnitionEnabled = true;
|
engineConfiguration->isIgnitionEnabled = true;
|
||||||
engineConfiguration->isInjectionEnabled = false;
|
engineConfiguration->isInjectionEnabled = false;
|
||||||
|
|
||||||
assertEqualsM("warningCounter#0", 4, unitTestWarningCounter);
|
assertEqualsM("warningCounter#0", 4, unitTestWarningCodeState.warningCounter);
|
||||||
|
|
||||||
|
|
||||||
eth.fireRise(20);
|
eth.fireRise(20);
|
||||||
|
@ -1318,5 +1318,5 @@ TEST(big, testMissedSpark299) {
|
||||||
eth.fireFall(20);
|
eth.fireFall(20);
|
||||||
eth.executeActions();
|
eth.executeActions();
|
||||||
|
|
||||||
assertEqualsM("warningCounter#1", 5, unitTestWarningCounter);
|
assertEqualsM("warningCounter#1", 5, unitTestWarningCodeState.warningCounter);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue