refactoring: better location for shared methods

This commit is contained in:
rusefi 2019-01-15 21:36:13 -05:00
parent 662831cde9
commit a8b3c8f8d2
10 changed files with 45 additions and 67 deletions

View File

@ -181,3 +181,37 @@ void EngineTestHelper::applyTriggerShape() {
incrementGlobalConfigurationVersion(PASS_ENGINE_PARAMETER_SIGNATURE);
}
void assertRpm(const char *msg, int expectedRpm DECLARE_ENGINE_PARAMETER_SUFFIX) {
EXPECT_EQ(expectedRpm, engine->rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE)) << msg;
}
void setupSimpleTestEngineWithMafAndTT_ONE_trigger(EngineTestHelper *eth, injection_mode_e injMode) {
Engine *engine = &eth->engine;
EXPAND_Engine
timeNowUs = 0;
eth->clearQueue();
ASSERT_EQ(LM_PLAIN_MAF, engineConfiguration->fuelAlgorithm);
engineConfiguration->isIgnitionEnabled = false; // let's focus on injection
engineConfiguration->specs.cylindersCount = 4;
// a bit of flexibility - the mode may be changed by some tests
engineConfiguration->injectionMode = injMode;
// set cranking mode (it's used by getCurrentInjectionMode())
engineConfiguration->crankingInjectionMode = IM_SIMULTANEOUS;
setArrayValues(config->cltFuelCorrBins, CLT_CURVE_SIZE, 1);
setArrayValues(engineConfiguration->injector.battLagCorr, VBAT_INJECTOR_CURVE_SIZE, 0);
// this is needed to update injectorLag
engine->updateSlowSensors(PASS_ENGINE_PARAMETER_SIGNATURE);
ASSERT_NEAR( 70, engine->sensors.clt, EPS4D) << "CLT";
ASSERT_EQ( 0, readIfTriggerConfigChangedForUnitTest()) << "trigger #1";
engineConfiguration->trigger.type = TT_ONE;
incrementGlobalConfigurationVersion(PASS_ENGINE_PARAMETER_SIGNATURE);
ASSERT_EQ( 1, readIfTriggerConfigChangedForUnitTest()) << "trigger #2";
eth->applyTriggerShape();
}

View File

@ -51,4 +51,8 @@ public:
persistent_config_s persistentConfig;
};
void assertRpm(const char *msg, int expectedRpm DECLARE_ENGINE_PARAMETER_SUFFIX);
void setupSimpleTestEngineWithMafAndTT_ONE_trigger(EngineTestHelper *eth, injection_mode_e injMode = IM_BATCH);
#endif /* ENGINE_TEST_HELPER_H_ */

View File

@ -14,13 +14,12 @@
#include "engine_configuration.h"
#include "test_idle_controller.h"
#include "afm2mapConverter.h"
#include "test_signal_executor.h"
#include "trigger_central.h"
#include "map_resize.h"
#include "engine_math.h"
#include "test_trigger_decoder.h"
#include "engine_test_helper.h"
#include "gtest/gtest.h"
typedef int32_t msg_t;

View File

@ -5,7 +5,7 @@
*/
#include "engine_math.h"
#include "test_trigger_decoder.h"
#include "engine_test_helper.h"
extern int timeNowUs;

View File

@ -5,7 +5,7 @@
*/
#include "engine_math.h"
#include "test_trigger_decoder.h"
#include "engine_test_helper.h"
#include "event_queue.h"
#include "tps.h"

View File

@ -1,6 +0,0 @@
#ifndef TEST_IDLE_CONTROLLER_H
#define TEST_IDLE_CONTROLLER_H
void idleDebug(char *msg, int value);
#endif

View File

@ -5,7 +5,7 @@
* @author Andrey Belomutskiy, (c) 2012-2018
*/
#include "test_trigger_decoder.h"
#include "engine_test_helper.h"
TEST(engine, testPlainCrankingWithoutAdvancedFeatures) {
printf("*************************************************** testPlainCrankingWithoutAdvancedFeatures\r\n");

View File

@ -6,7 +6,7 @@
*/
#include "global.h"
#include "test_trigger_decoder.h"
#include "engine_test_helper.h"
#include "trigger_decoder.h"
#include "engine_math.h"
#include "allsensors.h"
@ -218,7 +218,7 @@ TEST(misc, testFordAspire) {
assertEqualsM("higher rpm dwell", 3.25, getSparkDwell(6000 PASS_ENGINE_PARAMETER_SUFFIX));
}
void testTriggerDecoder2(const char *msg, engine_type_e type, int synchPointIndex, float channel1duty, float channel2duty) {
static void testTriggerDecoder2(const char *msg, engine_type_e type, int synchPointIndex, float channel1duty, float channel2duty) {
printf("====================================================================================== testTriggerDecoder2 msg=%s\r\n", msg);
EngineTestHelper eth(type);
@ -581,41 +581,6 @@ static void assertInjectionEvent(const char *msg, InjectionEvent *ev, int inject
assertEqualsM4(msg, " event offset", angleOffset, ev->injectionStart.angleOffset);
}
void assertRpm(const char *msg, int expectedRpm DECLARE_ENGINE_PARAMETER_SUFFIX) {
assertEqualsM(msg, expectedRpm, engine->rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_SIGNATURE));
}
void setupSimpleTestEngineWithMafAndTT_ONE_trigger(EngineTestHelper *eth, injection_mode_e injMode) {
Engine *engine = &eth->engine;
EXPAND_Engine
timeNowUs = 0;
eth->clearQueue();
ASSERT_EQ(LM_PLAIN_MAF, engineConfiguration->fuelAlgorithm);
engineConfiguration->isIgnitionEnabled = false; // let's focus on injection
engineConfiguration->specs.cylindersCount = 4;
// a bit of flexibility - the mode may be changed by some tests
engineConfiguration->injectionMode = injMode;
// set cranking mode (it's used by getCurrentInjectionMode())
engineConfiguration->crankingInjectionMode = IM_SIMULTANEOUS;
setArrayValues(config->cltFuelCorrBins, CLT_CURVE_SIZE, 1);
setArrayValues(engineConfiguration->injector.battLagCorr, VBAT_INJECTOR_CURVE_SIZE, 0);
// this is needed to update injectorLag
engine->updateSlowSensors(PASS_ENGINE_PARAMETER_SIGNATURE);
ASSERT_NEAR( 70, engine->sensors.clt, EPS4D) << "CLT";
ASSERT_EQ( 0, readIfTriggerConfigChangedForUnitTest()) << "trigger #1";
engineConfiguration->trigger.type = TT_ONE;
incrementGlobalConfigurationVersion(PASS_ENGINE_PARAMETER_SIGNATURE);
ASSERT_EQ( 1, readIfTriggerConfigChangedForUnitTest()) << "trigger #2";
eth->applyTriggerShape();
}
static void setTestBug299(EngineTestHelper *eth) {
setupSimpleTestEngineWithMafAndTT_ONE_trigger(eth);
Engine *engine = &eth->engine;

View File

@ -1,18 +0,0 @@
/**
* @file test_trigger_decoder.h
*
* @date Dec 24, 2013
* @author Andrey Belomutskiy, (c) 2012-2017
*/
#ifndef TEST_TRIGGER_DECODER_H_
#define TEST_TRIGGER_DECODER_H_
#include "engine_test_helper.h"
void testTriggerDecoder2(const char *msg, engine_type_e type, int synchPointIndex, float channel1duty, float channel2duty);
void setupSimpleTestEngineWithMafAndTT_ONE_trigger(EngineTestHelper *eth, injection_mode_e injMode = IM_BATCH);
void assertRpm(const char *msg, int expectedRpm DECLARE_ENGINE_PARAMETER_SUFFIX);
#endif /* TEST_TRIGGER_DECODER_H_ */

View File

@ -5,7 +5,7 @@
*/
#include "global.h"
#include "test_trigger_decoder.h"
#include "engine_test_helper.h"
#include "trigger_decoder.h"
#include "engine_math.h"
#include "allsensors.h"