Question: something strange trigger errors #662

reducing warnings in unit tests
This commit is contained in:
rusefi 2019-01-12 15:32:40 -05:00
parent 7f9b3d05b6
commit 3ca1c5360f
5 changed files with 18 additions and 3 deletions

View File

@ -8,11 +8,17 @@
#include "boards.h"
float testMafValue = 0;
float testCltValue = 0;
float testIatValue = 0;
float getVoltageDivided(const char *msg, int channel) {
switch(channel) {
case TEST_MAF_CHANNEL:
return testMafValue;
case TEST_CLT_CHANNEL:
return testCltValue;
case TEST_IAT_CHANNEL:
return testIatValue;
}
return 0;
}

View File

@ -11,6 +11,8 @@
#define ADC_CHANNEL_VREF 0
#define TEST_MAF_CHANNEL 10000013
#define TEST_CLT_CHANNEL 10000014
#define TEST_IAT_CHANNEL 10000015
float getVoltageDivided(const char *msg, int);
float getVoltage(const char *msg, int channel);

View File

@ -19,6 +19,8 @@ extern int timeNowUs;
extern EnginePins enginePins;
extern WarningCodeState unitTestWarningCodeState;
extern float testMafValue;
extern float testCltValue;
extern float testIatValue;
extern engine_configuration_s activeConfiguration;
EngineTestHelper::EngineTestHelper(engine_type_e engineType) : engine (&persistentConfig) {
@ -59,6 +61,10 @@ EngineTestHelper::EngineTestHelper(engine_type_e engineType) : engine (&persiste
resetConfigurationExt(NULL, engineType PASS_ENGINE_PARAMETER_SUFFIX);
prepareShapes(PASS_ENGINE_PARAMETER_SIGNATURE);
engine->engineConfigurationPtr->mafAdcChannel = (adc_channel_e)TEST_MAF_CHANNEL;
engine->engineConfigurationPtr->clt.adcChannel = (adc_channel_e)TEST_CLT_CHANNEL;
engine->engineConfigurationPtr->iat.adcChannel = (adc_channel_e)TEST_IAT_CHANNEL;
testCltValue = 1.492964;
// testIatValue = 1.492964;
// this is needed to have valid CLT and IAT.
engine->updateSlowSensors(PASS_ENGINE_PARAMETER_SIGNATURE);

View File

@ -71,7 +71,7 @@ void testFuelMap(void) {
printf("*************************************************** getRunningFuel 1\r\n");
eth.engine.periodicFastCallback(PASS_ENGINE_PARAMETER_SIGNATURE);
float baseFuel = getBaseTableFuel(5, getEngineLoadT(PASS_ENGINE_PARAMETER_SIGNATURE));
assertEqualsM("base fuel", 5.05, getRunningFuel(baseFuel PASS_ENGINE_PARAMETER_SUFFIX));
assertEqualsM("base fuel", 5.3679, getRunningFuel(baseFuel PASS_ENGINE_PARAMETER_SUFFIX));
printf("*************************************************** setting IAT table\r\n");
for (int i = 0; i < IAT_CURVE_SIZE; i++) {

View File

@ -313,6 +313,7 @@ void testRpmCalculator(void) {
setFlatInjectorLag(0 PASS_CONFIG_PARAMETER_SUFFIX);
engine->updateSlowSensors(PASS_ENGINE_PARAMETER_SIGNATURE);
engine->sensors.clt = 70; // 'testCltValue' does not give us exact number so we have to hack here. todo: migrate test
assertEquals(0, engine->rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE));
@ -1248,7 +1249,7 @@ TEST(big, testMissedSpark299) {
engineConfiguration->isIgnitionEnabled = true;
engineConfiguration->isInjectionEnabled = false;
assertEqualsM("warningCounter#0", 4, unitTestWarningCodeState.warningCounter);
assertEqualsM("warningCounter#0", 2, unitTestWarningCodeState.warningCounter);
eth.fireRise(20);
@ -1318,5 +1319,5 @@ TEST(big, testMissedSpark299) {
eth.fireFall(20);
eth.executeActions();
assertEqualsM("warningCounter#1", 5, unitTestWarningCodeState.warningCounter);
assertEqualsM("warningCounter#1", 3, unitTestWarningCodeState.warningCounter);
}