WFT is wrong with MRE_miata_na6 config? operationMode complexity #898

fancy smansy unit test with some C++11
This commit is contained in:
rusefi 2019-08-08 21:27:57 -04:00
parent 3ff8c92d38
commit 7d73c6a8a9
10 changed files with 54 additions and 7 deletions

View File

@ -313,7 +313,6 @@ private:
};
void prepareShapes(DECLARE_ENGINE_PARAMETER_SIGNATURE);
void resetConfigurationExt(Logging * logger, engine_type_e engineType DECLARE_ENGINE_PARAMETER_SUFFIX);
void applyNonPersistentConfiguration(Logging * logger DECLARE_ENGINE_PARAMETER_SUFFIX);
void prepareOutputSignals(DECLARE_ENGINE_PARAMETER_SIGNATURE);

View File

@ -1022,7 +1022,7 @@ static void setDefaultFrankensoConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE)
boardConfiguration->is_enabled_spi_3 = true;
}
void resetConfigurationExt(Logging * logger, engine_type_e engineType DECLARE_ENGINE_PARAMETER_SUFFIX) {
void resetConfigurationExt(Logging * logger, std::function<void(Engine *)> boardCallback, engine_type_e engineType DECLARE_ENGINE_PARAMETER_SUFFIX) {
enginePins.reset(); // that's mostly important for functional tests
/**
* Let's apply global defaults first
@ -1032,6 +1032,8 @@ void resetConfigurationExt(Logging * logger, engine_type_e engineType DECLARE_EN
// set initial pin groups
setDefaultBasePins(PASS_CONFIG_PARAMETER_SIGNATURE);
boardCallback(engine);
#if EFI_PROD_CODE
// call overrided board-specific configuration setup, if needed (for custom boards only)
setBoardConfigurationOverrides();
@ -1289,6 +1291,14 @@ void resetConfigurationExt(Logging * logger, engine_type_e engineType DECLARE_EN
#endif /* EFI_TUNER_STUDIO */
}
void emptyCallbackWithEngine(Engine * engine) {
}
void resetConfigurationExt(Logging * logger, engine_type_e engineType DECLARE_ENGINE_PARAMETER_SUFFIX) {
resetConfigurationExt(logger, &emptyCallbackWithEngine, engineType PASS_ENGINE_PARAMETER_SUFFIX);
}
void validateConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
if (engineConfiguration->adcVcc > 5.0f || engineConfiguration->adcVcc < 1.0f) {
engineConfiguration->adcVcc = 3.0f;

View File

@ -13,6 +13,7 @@
#include "crc.h"
#include "engine_configuration_generated_structures.h"
#include "globalaccess.h"
#include <functional>
#ifndef DEFAULT_ENGINE_TYPE
#define DEFAULT_ENGINE_TYPE DEFAULT_FRANKENSO
@ -80,4 +81,8 @@ void copyTargetAfrTable(fuel_table_t const source, afr_table_t destination);
void copyFuelTable(fuel_table_t const source, fuel_table_t destination);
void copyTimingTable(ignition_table_t const source, ignition_table_t destination);
void resetConfigurationExt(Logging * logger, std::function<void(Engine *)>, engine_type_e engineType DECLARE_ENGINE_PARAMETER_SUFFIX);
void resetConfigurationExt(Logging * logger, engine_type_e engineType DECLARE_ENGINE_PARAMETER_SUFFIX);
void emptyCallbackWithEngine(Engine * engine);
#endif /* ENGINE_CONFIGURATION_H_ */

View File

@ -29,7 +29,7 @@ EngineTestHelperBase::EngineTestHelperBase() {
timeNowUs = 0;
}
EngineTestHelper::EngineTestHelper(engine_type_e engineType) : engine (&persistentConfig) {
EngineTestHelper::EngineTestHelper(engine_type_e engineType, std::function<void(Engine *)> boardCallback) {
unitTestWarningCodeState.clear();
testMafValue = 0;
@ -60,7 +60,7 @@ EngineTestHelper::EngineTestHelper(engine_type_e engineType) : engine (&persiste
mostCommonInitEngineController(NULL PASS_ENGINE_PARAMETER_SUFFIX);
resetConfigurationExt(NULL, engineType PASS_ENGINE_PARAMETER_SUFFIX);
resetConfigurationExt(NULL, boardCallback, engineType PASS_ENGINE_PARAMETER_SUFFIX);
prepareShapes(PASS_ENGINE_PARAMETER_SIGNATURE);
engine->engineConfigurationPtr->mafAdcChannel = TEST_MAF_CHANNEL;
engine->engineConfigurationPtr->clt.adcChannel = TEST_CLT_CHANNEL;
@ -79,6 +79,9 @@ EngineTestHelper::EngineTestHelper(engine_type_e engineType) : engine (&persiste
initMainEventListener(NULL PASS_ENGINE_PARAMETER_SUFFIX);
}
EngineTestHelper::EngineTestHelper(engine_type_e engineType) : EngineTestHelper(engineType, &emptyCallbackWithEngine) {
}
/**
* mock a change of time and fire single RISE front event
*/

View File

@ -12,6 +12,7 @@
#include "rpm_calculator.h"
#include "main_trigger_callback.h"
#include "unit_test_framework.h"
#include <functional>
class EngineTestHelperBase
{
@ -27,6 +28,7 @@ public:
class EngineTestHelper : public EngineTestHelperBase {
public:
EngineTestHelper(engine_type_e engineType);
EngineTestHelper(engine_type_e engineType, std::function<void(Engine *)>);
void applyTriggerShape();
void setTriggerType(trigger_type_e trigger DECLARE_ENGINE_PARAMETER_SUFFIX);
void fireRise(int delayMs);

View File

@ -46,7 +46,7 @@ GTEST_API_ int main(int argc, char **argv) {
// printTriggerDebug = true;
// resizeMap();
printf("Success 20190713\r\n");
printf("Success 20190808\r\n");
printAllTriggers();
// printConvertedTable();
testing::InitGoogleTest(&argc, argv);

View File

@ -2,7 +2,7 @@
* @file test_idle_controller.cpp
*
* @date Oct 17, 2013
* @author Andrey Belomutskiy, (c) 2012-2018
* @author Andrey Belomutskiy, (c) 2012-2019
*/
#include "engine_test_helper.h"

View File

@ -2,7 +2,7 @@
* test_ion.cpp
*
* Created on: Jan 4, 2019
* Author: user
* @author Andrey Belomutskiy, (c) 2012-2019
*/
#ifndef TEST_ION_CPP_

View File

@ -0,0 +1,27 @@
/*
* test_issue_898.cpp
*
* Created on: Aug 8, 2019
* @author Andrey Belomutskiy, (c) 2012-2019
*/
#include "engine_test_helper.h"
static void boardConfigurationForIssue898(Engine * engine) {
engine_configuration_s *engineConfiguration = engine->engineConfigurationPtr;
setOperationMode(engineConfiguration, FOUR_STROKE_CRANK_SENSOR);
engineConfiguration->trigger.type = TT_TOOTHED_WHEEL_60_2;
engineConfiguration->useOnlyRisingEdgeForTrigger = true;
}
TEST(issues, issue898) {
// works without extra board settings
EngineTestHelper eth(MRE_MIATA_NA6);
// fails like this with self-contradictory trigger definition
// EngineTestHelper eth(MRE_MIATA_NA6, &boardConfigurationForIssue898);
EXPAND_EngineTestHelper;
ASSERT_EQ(0, engine->triggerCentral.triggerShape.shapeDefinitionError) << "MRE_MIATA_NA6 shapeDefinitionError";
}

View File

@ -13,6 +13,7 @@ TESTS_SRC_CPP = \
tests/test_idle_controller.cpp \
tests/test_trigger_decoder.cpp \
tests/test_trigger_noiseless.cpp \
tests/test_issue_898.cpp \
tests/test_fuel_map.cpp \
tests/test_maf2map.cpp \
tests/test_fuelCut.cpp \