refactoring: better location for shared methods
This commit is contained in:
parent
eba0278fdd
commit
09201e9b7e
|
@ -181,3 +181,37 @@ void EngineTestHelper::applyTriggerShape() {
|
||||||
|
|
||||||
incrementGlobalConfigurationVersion(PASS_ENGINE_PARAMETER_SIGNATURE);
|
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 = ð->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();
|
||||||
|
}
|
||||||
|
|
|
@ -51,4 +51,8 @@ public:
|
||||||
persistent_config_s persistentConfig;
|
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_ */
|
#endif /* ENGINE_TEST_HELPER_H_ */
|
||||||
|
|
|
@ -14,13 +14,12 @@
|
||||||
|
|
||||||
#include "engine_configuration.h"
|
#include "engine_configuration.h"
|
||||||
|
|
||||||
#include "test_idle_controller.h"
|
|
||||||
#include "afm2mapConverter.h"
|
#include "afm2mapConverter.h"
|
||||||
#include "test_signal_executor.h"
|
#include "test_signal_executor.h"
|
||||||
#include "trigger_central.h"
|
#include "trigger_central.h"
|
||||||
#include "map_resize.h"
|
#include "map_resize.h"
|
||||||
#include "engine_math.h"
|
#include "engine_math.h"
|
||||||
#include "test_trigger_decoder.h"
|
#include "engine_test_helper.h"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
typedef int32_t msg_t;
|
typedef int32_t msg_t;
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "engine_math.h"
|
#include "engine_math.h"
|
||||||
#include "test_trigger_decoder.h"
|
#include "engine_test_helper.h"
|
||||||
|
|
||||||
extern int timeNowUs;
|
extern int timeNowUs;
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "engine_math.h"
|
#include "engine_math.h"
|
||||||
#include "test_trigger_decoder.h"
|
#include "engine_test_helper.h"
|
||||||
#include "event_queue.h"
|
#include "event_queue.h"
|
||||||
#include "tps.h"
|
#include "tps.h"
|
||||||
|
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
#ifndef TEST_IDLE_CONTROLLER_H
|
|
||||||
#define TEST_IDLE_CONTROLLER_H
|
|
||||||
|
|
||||||
void idleDebug(char *msg, int value);
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -5,7 +5,7 @@
|
||||||
* @author Andrey Belomutskiy, (c) 2012-2018
|
* @author Andrey Belomutskiy, (c) 2012-2018
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "test_trigger_decoder.h"
|
#include "engine_test_helper.h"
|
||||||
|
|
||||||
TEST(engine, testPlainCrankingWithoutAdvancedFeatures) {
|
TEST(engine, testPlainCrankingWithoutAdvancedFeatures) {
|
||||||
printf("*************************************************** testPlainCrankingWithoutAdvancedFeatures\r\n");
|
printf("*************************************************** testPlainCrankingWithoutAdvancedFeatures\r\n");
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "test_trigger_decoder.h"
|
#include "engine_test_helper.h"
|
||||||
#include "trigger_decoder.h"
|
#include "trigger_decoder.h"
|
||||||
#include "engine_math.h"
|
#include "engine_math.h"
|
||||||
#include "allsensors.h"
|
#include "allsensors.h"
|
||||||
|
@ -218,7 +218,7 @@ TEST(misc, testFordAspire) {
|
||||||
assertEqualsM("higher rpm dwell", 3.25, getSparkDwell(6000 PASS_ENGINE_PARAMETER_SUFFIX));
|
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);
|
printf("====================================================================================== testTriggerDecoder2 msg=%s\r\n", msg);
|
||||||
|
|
||||||
EngineTestHelper eth(type);
|
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);
|
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 = ð->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) {
|
static void setTestBug299(EngineTestHelper *eth) {
|
||||||
setupSimpleTestEngineWithMafAndTT_ONE_trigger(eth);
|
setupSimpleTestEngineWithMafAndTT_ONE_trigger(eth);
|
||||||
Engine *engine = ð->engine;
|
Engine *engine = ð->engine;
|
||||||
|
|
|
@ -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_ */
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "test_trigger_decoder.h"
|
#include "engine_test_helper.h"
|
||||||
#include "trigger_decoder.h"
|
#include "trigger_decoder.h"
|
||||||
#include "engine_math.h"
|
#include "engine_math.h"
|
||||||
#include "allsensors.h"
|
#include "allsensors.h"
|
||||||
|
|
Loading…
Reference in New Issue