reducing global variables in tests
This commit is contained in:
parent
a32e8a3530
commit
34cfdfd718
|
@ -119,10 +119,24 @@ void EngineTestHelper::moveTimeForwardUs(int deltaTimeUs) {
|
||||||
timeNowUs += deltaTimeUs;
|
timeNowUs += deltaTimeUs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
efitimeus_t EngineTestHelper::getTimeNowUs(void) {
|
||||||
|
return timeNowUs;
|
||||||
|
}
|
||||||
|
|
||||||
void EngineTestHelper::fireTriggerEvents(int count) {
|
void EngineTestHelper::fireTriggerEvents(int count) {
|
||||||
fireTriggerEvents2(count, 5); // 5ms
|
fireTriggerEvents2(count, 5); // 5ms
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EngineTestHelper::assertInjectorUpEvent(const char *msg, int eventIndex, efitime_t momentX, long injectorIndex) {
|
||||||
|
InjectionSignalPair *pair = &engine.fuelActuators[injectorIndex];
|
||||||
|
::assertEvent(&engine.executor, msg, eventIndex, (void*)seTurnPinHigh, timeNowUs, momentX, (long)pair);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EngineTestHelper::assertInjectorDownEvent(const char *msg, int eventIndex, efitime_t momentX, long injectorIndex) {
|
||||||
|
InjectionSignalPair *pair = &engine.fuelActuators[injectorIndex];
|
||||||
|
::assertEvent(&engine.executor, msg, eventIndex, (void*)seTurnPinLow, timeNowUs, momentX, (long)pair);
|
||||||
|
}
|
||||||
|
|
||||||
void EngineTestHelper::applyTriggerShape() {
|
void EngineTestHelper::applyTriggerShape() {
|
||||||
Engine *engine = &this->engine;
|
Engine *engine = &this->engine;
|
||||||
EXPAND_Engine
|
EXPAND_Engine
|
||||||
|
|
|
@ -31,8 +31,14 @@ public:
|
||||||
void fireTriggerEvents2(int count, int delayMs);
|
void fireTriggerEvents2(int count, int delayMs);
|
||||||
void clearQueue();
|
void clearQueue();
|
||||||
|
|
||||||
|
scheduling_s * assertEvent5(TestExecutor *executor, const char *msg, int index, void *callback, efitime_t start, efitime_t momentX);
|
||||||
|
void assertEvent(TestExecutor *executor, const char *msg, int index, void *callback, efitime_t start, efitime_t momentX, long param);
|
||||||
|
void assertInjectorUpEvent(const char *msg, int eventIndex, efitime_t momentX, long injectorIndex);
|
||||||
|
void assertInjectorDownEvent(const char *msg, int eventIndex, efitime_t momentX, long injectorIndex);
|
||||||
|
|
||||||
int executeActions();
|
int executeActions();
|
||||||
void moveTimeForwardUs(int deltaTimeUs);
|
void moveTimeForwardUs(int deltaTimeUs);
|
||||||
|
efitimeus_t getTimeNowUs(void);
|
||||||
|
|
||||||
Engine engine;
|
Engine engine;
|
||||||
persistent_config_s persistentConfig;
|
persistent_config_s persistentConfig;
|
||||||
|
|
|
@ -38,7 +38,7 @@ void testFasterEngineSpinningUp() {
|
||||||
assertEqualsM("plain#1", 0, engine->executor.size());
|
assertEqualsM("plain#1", 0, engine->executor.size());
|
||||||
|
|
||||||
// check all events starting from now
|
// check all events starting from now
|
||||||
int timeStartUs = timeNowUs;
|
int timeStartUs = eth.getTimeNowUs();
|
||||||
// advance 1 revolution
|
// advance 1 revolution
|
||||||
eth.fireRise(200);
|
eth.fireRise(200);
|
||||||
|
|
||||||
|
@ -75,8 +75,8 @@ void testFasterEngineSpinningUp() {
|
||||||
// two simultaneous injections
|
// two simultaneous injections
|
||||||
assertEqualsM("plain#2", 4, engine->executor.size());
|
assertEqualsM("plain#2", 4, engine->executor.size());
|
||||||
// check real events
|
// check real events
|
||||||
assertEvent5(&engine->executor, "inj start#2", 0, (void*)startSimultaniousInjection, timeNowUs, 97975);
|
assertEvent5(&engine->executor, "inj start#2", 0, (void*)startSimultaniousInjection, eth.getTimeNowUs(), 97975);
|
||||||
assertEvent5(&engine->executor, "inj end#2", 1, (void*)endSimultaniousInjection, timeNowUs, 100000);
|
assertEvent5(&engine->executor, "inj end#2", 1, (void*)endSimultaniousInjection, eth.getTimeNowUs(), 100000);
|
||||||
|
|
||||||
// skip, clear & advance 1 more revolution at higher RPM
|
// skip, clear & advance 1 more revolution at higher RPM
|
||||||
eth.fireFall(60);
|
eth.fireFall(60);
|
||||||
|
|
|
@ -341,7 +341,7 @@ void testRpmCalculator(void) {
|
||||||
|
|
||||||
timeNowUs += MS2US(5); // 5ms
|
timeNowUs += MS2US(5); // 5ms
|
||||||
|
|
||||||
int start = timeNowUs;
|
int start = eth.getTimeNowUs();
|
||||||
assertEqualsM("start value", 485000, start);
|
assertEqualsM("start value", 485000, start);
|
||||||
|
|
||||||
// todo: why is this required here? we already have one 'prepareOutputSignals' in constructor, what's wrong with it?
|
// todo: why is this required here? we already have one 'prepareOutputSignals' in constructor, what's wrong with it?
|
||||||
|
@ -410,7 +410,7 @@ void testRpmCalculator(void) {
|
||||||
assertEqualsM("fuel #3", 4.5450, eth.engine.injectionDuration);
|
assertEqualsM("fuel #3", 4.5450, eth.engine.injectionDuration);
|
||||||
assertEquals(1500, eth.engine.rpmCalculator.rpmValue);
|
assertEquals(1500, eth.engine.rpmCalculator.rpmValue);
|
||||||
|
|
||||||
assertInjectorUpEvent("ev 0/2", 0, -4849, 2 PASS_ENGINE_PARAMETER_SUFFIX);
|
eth.assertInjectorUpEvent("ev 0/2", 0, -4849, 2);
|
||||||
|
|
||||||
|
|
||||||
assertEqualsM("index #4", 6, eth.engine.triggerCentral.triggerState.getCurrentIndex());
|
assertEqualsM("index #4", 6, eth.engine.triggerCentral.triggerState.getCurrentIndex());
|
||||||
|
@ -692,7 +692,7 @@ static void setTestBug299(EngineTestHelper *eth) {
|
||||||
assertEqualsM("rev cnt#3", 3, engine->rpmCalculator.getRevolutionCounter());
|
assertEqualsM("rev cnt#3", 3, engine->rpmCalculator.getRevolutionCounter());
|
||||||
assertInjectorUpEvent("setTestBug299: 1@0", 0, MS2US(8.5), 0 PASS_ENGINE_PARAMETER_SUFFIX);
|
assertInjectorUpEvent("setTestBug299: 1@0", 0, MS2US(8.5), 0 PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
assertInjectorDownEvent("@1", 1, MS2US(10), 0 PASS_ENGINE_PARAMETER_SUFFIX);
|
assertInjectorDownEvent("@1", 1, MS2US(10), 0 PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
assertInjectorUpEvent("1@2", 2, MS2US(18.5), 1 PASS_ENGINE_PARAMETER_SUFFIX);
|
eth->assertInjectorUpEvent("1@2", 2, MS2US(18.5), 1);
|
||||||
assertInjectorDownEvent("1@3", 3, MS2US(20), 1 PASS_ENGINE_PARAMETER_SUFFIX);
|
assertInjectorDownEvent("1@3", 3, MS2US(20), 1 PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
assertEqualsM("exec#0", 0, eth->executeActions());
|
assertEqualsM("exec#0", 0, eth->executeActions());
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue