reducing global variables in tests
This commit is contained in:
parent
ea069b118a
commit
e357cec8bf
|
@ -129,14 +129,34 @@ void EngineTestHelper::fireTriggerEvents(int count) {
|
|||
|
||||
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);
|
||||
assertEvent(&engine.executor, msg, eventIndex, (void*)seTurnPinHigh, getTimeNowUs(), 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);
|
||||
assertEvent(&engine.executor, msg, eventIndex, (void*)seTurnPinLow, getTimeNowUs(), momentX, (long)pair);
|
||||
}
|
||||
|
||||
scheduling_s * EngineTestHelper::assertEvent5(TestExecutor *executor, const char *msg, int index, void *callback, efitime_t start, efitime_t momentX) {
|
||||
assertTrueM(msg, executor->size() > index);
|
||||
scheduling_s *event = executor->getForUnitTest(index);
|
||||
assertEqualsM4(msg, " up/down", (void*)event->callback == (void*) callback, 1);
|
||||
assertEqualsM(msg, momentX, event->momentX - start);
|
||||
return event;
|
||||
}
|
||||
|
||||
void EngineTestHelper::assertEvent(TestExecutor *executor, const char *msg, int index, void *callback, efitime_t start, efitime_t momentX, long param) {
|
||||
scheduling_s *event = assertEvent5(executor, msg, index, callback, start, momentX);
|
||||
|
||||
InjectionSignalPair *eventPair = (InjectionSignalPair *)event->param;
|
||||
|
||||
InjectionSignalPair *expectedPair = (InjectionSignalPair *)param;
|
||||
|
||||
assertEqualsLM(msg, expectedPair->outputs[0], (long)eventPair->outputs[0]);
|
||||
// but this would not work assertEqualsLM(msg, expectedPair, (long)eventPair);
|
||||
}
|
||||
|
||||
|
||||
void EngineTestHelper::applyTriggerShape() {
|
||||
Engine *engine = &this->engine;
|
||||
EXPAND_Engine
|
||||
|
|
|
@ -53,8 +53,8 @@ void testFasterEngineSpinningUp() {
|
|||
// test if ignition mode is temporary changed to wasted spark, if set to ind.coils
|
||||
assertEquals(IM_WASTED_SPARK, getIgnitionMode(PASS_ENGINE_PARAMETER_SIGNATURE));
|
||||
// check real events
|
||||
assertEvent5(&engine->executor, "inj start#1", 0, (void*)startSimultaniousInjection, timeStartUs, MS2US(200) + 97975);
|
||||
assertEvent5(&engine->executor, "inj end#1", 1, (void*)endSimultaniousInjection, timeStartUs, MS2US(200) + 100000);
|
||||
eth.assertEvent5(&engine->executor, "inj start#1", 0, (void*)startSimultaniousInjection, timeStartUs, MS2US(200) + 97975);
|
||||
eth.assertEvent5(&engine->executor, "inj end#1", 1, (void*)endSimultaniousInjection, timeStartUs, MS2US(200) + 100000);
|
||||
|
||||
// skip the rest of the cycle
|
||||
eth.fireFall(200);
|
||||
|
@ -75,8 +75,8 @@ void testFasterEngineSpinningUp() {
|
|||
// two simultaneous injections
|
||||
assertEqualsM("plain#2", 4, engine->executor.size());
|
||||
// check real events
|
||||
assertEvent5(&engine->executor, "inj start#2", 0, (void*)startSimultaniousInjection, eth.getTimeNowUs(), 97975);
|
||||
assertEvent5(&engine->executor, "inj end#2", 1, (void*)endSimultaniousInjection, eth.getTimeNowUs(), 100000);
|
||||
eth.assertEvent5(&engine->executor, "inj start#2", 0, (void*)startSimultaniousInjection, eth.getTimeNowUs(), 97975);
|
||||
eth.assertEvent5(&engine->executor, "inj end#2", 1, (void*)endSimultaniousInjection, eth.getTimeNowUs(), 100000);
|
||||
|
||||
// skip, clear & advance 1 more revolution at higher RPM
|
||||
eth.fireFall(60);
|
||||
|
@ -96,6 +96,6 @@ void testFasterEngineSpinningUp() {
|
|||
|
||||
// check real events for sequential injection
|
||||
// Note: See addFuelEvents() fix inside setRpmValue()!
|
||||
assertEvent5(&engine->executor, "inj start#3", 0, (void*)seTurnPinHigh, timeStartUs, MS2US(60) + 27974);
|
||||
assertEvent5(&engine->executor, "inj end#3", 1, (void*)seTurnPinLow, timeStartUs, MS2US(60) + 27974 + 3000);
|
||||
eth.assertEvent5(&engine->executor, "inj start#3", 0, (void*)seTurnPinHigh, timeStartUs, MS2US(60) + 27974);
|
||||
eth.assertEvent5(&engine->executor, "inj end#3", 1, (void*)seTurnPinLow, timeStartUs, MS2US(60) + 27974 + 3000);
|
||||
}
|
||||
|
|
|
@ -32,8 +32,8 @@ void testPlainCrankingWithoutAdvancedFeatures() {
|
|||
// two simultaneous injections
|
||||
assertEqualsM("plain#2", 4, engine->executor.size());
|
||||
|
||||
assertEvent5(&engine->executor, "sim start", 0, (void*)startSimultaniousInjection, timeNowUs, 97975);
|
||||
assertEvent5(&engine->executor, "sim end", 1, (void*)endSimultaniousInjection, timeNowUs, 100000);
|
||||
eth.assertEvent5(&engine->executor, "sim start", 0, (void*)startSimultaniousInjection, timeNowUs, 97975);
|
||||
eth.assertEvent5(&engine->executor, "sim end", 1, (void*)endSimultaniousInjection, timeNowUs, 100000);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -593,25 +593,6 @@ void testTriggerDecoder(void) {
|
|||
|
||||
extern fuel_Map3D_t fuelMap;
|
||||
|
||||
scheduling_s * assertEvent5(TestExecutor *executor, const char *msg, int index, void *callback, efitime_t start, efitime_t momentX) {
|
||||
assertTrueM(msg, executor->size() > index);
|
||||
scheduling_s *event = executor->getForUnitTest(index);
|
||||
assertEqualsM4(msg, " up/down", (void*)event->callback == (void*) callback, 1);
|
||||
assertEqualsM(msg, momentX, event->momentX - start);
|
||||
return event;
|
||||
}
|
||||
|
||||
void assertEvent(TestExecutor *executor, const char *msg, int index, void *callback, efitime_t start, efitime_t momentX, long param) {
|
||||
scheduling_s *event = assertEvent5(executor, msg, index, callback, start, momentX);
|
||||
|
||||
InjectionSignalPair *eventPair = (InjectionSignalPair *)event->param;
|
||||
|
||||
InjectionSignalPair *expectedPair = (InjectionSignalPair *)param;
|
||||
|
||||
assertEqualsLM(msg, expectedPair->outputs[0], (long)eventPair->outputs[0]);
|
||||
// but this would not work assertEqualsLM(msg, expectedPair, (long)eventPair);
|
||||
}
|
||||
|
||||
static void assertInjectionEvent(const char *msg, InjectionEvent *ev, int injectorIndex, int eventIndex, angle_t angleOffset, bool isOverlapping) {
|
||||
assertEqualsM4(msg, "inj index", injectorIndex, ev->outputs[0]->injectorIndex);
|
||||
assertEqualsM4(msg, " event index", eventIndex, ev->injectionStart.eventIndex);
|
||||
|
|
|
@ -23,7 +23,4 @@ void assertTrueM(const char *msg, float actual);
|
|||
void assertFalse(float actual);
|
||||
void assertFalseM(const char *msg, float actual);
|
||||
|
||||
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);
|
||||
|
||||
#endif /* UNIT_TEST_FRAMEWORK_H_ */
|
||||
|
|
Loading…
Reference in New Issue