reducing code duplication with unit tests
This commit is contained in:
parent
f3349f3163
commit
faba7ef136
|
@ -22,7 +22,6 @@
|
|||
*/
|
||||
|
||||
#include "global.h"
|
||||
#if !EFI_UNIT_TEST
|
||||
#if EFI_SENSOR_CHART
|
||||
#include "sensor_chart.h"
|
||||
#endif
|
||||
|
@ -80,6 +79,14 @@
|
|||
#include "cj125.h"
|
||||
#endif
|
||||
|
||||
// this method is used by real firmware and simulator and unit test
|
||||
void mostCommonInitEngineController(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||
initSensors(sharedLogger PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
initAccelEnrichment(sharedLogger PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
}
|
||||
|
||||
#if !EFI_UNIT_TEST
|
||||
|
||||
#if defined(EFI_BOOTLOADER_INCLUDE_CODE)
|
||||
#include "bootloader/bootloader.h"
|
||||
#endif /* EFI_BOOTLOADER_INCLUDE_CODE */
|
||||
|
@ -160,7 +167,7 @@ efitick_t getTimeNowNt(void) {
|
|||
unlockAnyContext();
|
||||
}
|
||||
return result;
|
||||
#else
|
||||
#else /* EFI_PROD_CODE */
|
||||
// todo: why is this implementation not used?
|
||||
/**
|
||||
* this method is lock-free and thread-safe, that's because the 'update' method
|
||||
|
@ -192,7 +199,7 @@ efitick_t getTimeNowNt(void) {
|
|||
}
|
||||
|
||||
return localH + value;
|
||||
#endif
|
||||
#endif /* EFI_PROD_CODE */
|
||||
|
||||
}
|
||||
|
||||
|
@ -625,7 +632,7 @@ static void getKnockInfo(void) {
|
|||
engine->printKnockState();
|
||||
}
|
||||
|
||||
// this method is used by real firmware and simulator
|
||||
// this method is used by real firmware and simulator but not unit tests
|
||||
void commonInitEngineController(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||
#if EFI_SIMULATOR
|
||||
printf("commonInitEngineController\n");
|
||||
|
@ -648,19 +655,16 @@ void commonInitEngineController(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_S
|
|||
if (engineConfiguration->isTunerStudioEnabled) {
|
||||
startTunerStudioConnectivity();
|
||||
}
|
||||
#endif
|
||||
#endif /* EFI_TUNER_STUDIO */
|
||||
|
||||
if (hasFirmwareError()) {
|
||||
return;
|
||||
}
|
||||
initSensors(sharedLogger PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
mostCommonInitEngineController(sharedLogger PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
|
||||
#if EFI_FSIO
|
||||
initFsioImpl(sharedLogger PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
#endif
|
||||
|
||||
initAccelEnrichment(sharedLogger);
|
||||
|
||||
#endif /* EFI_FSIO */
|
||||
}
|
||||
|
||||
void initEngineContoller(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||
|
|
|
@ -18,6 +18,7 @@ char * getPinNameByAdcChannel(const char *msg, adc_channel_e hwChannel, char *bu
|
|||
void initPeriodicEvents(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||
void initEngineContoller(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||
void commonInitEngineController(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||
void mostCommonInitEngineController(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||
|
||||
void setMockVBattVoltage(float voltage);
|
||||
void setMockMapVoltage(float voltage);
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "fuel_math.h"
|
||||
#include "accel_enrichment.h"
|
||||
#include "allsensors.h"
|
||||
#include "engine_controller.h"
|
||||
#include "advance_map.h"
|
||||
#include "algo.h"
|
||||
|
||||
|
@ -57,8 +58,7 @@ EngineTestHelper::EngineTestHelper(engine_type_e engineType) : engine (&persiste
|
|||
|
||||
initDataStructures(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
|
||||
initAccelEnrichment(NULL PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
initSensors(NULL PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
mostCommonInitEngineController(NULL PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
|
||||
resetConfigurationExt(NULL, engineType PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
prepareShapes(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
|
|
Loading…
Reference in New Issue