refactoring: all events are now validated in relation to current timestamp
This commit is contained in:
parent
0380d4d709
commit
e6f5a6e3f4
|
@ -153,25 +153,26 @@ void EngineTestHelper::fireTriggerEvents(int count) {
|
|||
|
||||
void EngineTestHelper::assertInjectorUpEvent(const char *msg, int eventIndex, efitime_t momentX, long injectorIndex) {
|
||||
InjectionSignalPair *pair = &engine.fuelActuators[injectorIndex];
|
||||
assertEvent(msg, eventIndex, (void*)seTurnPinHigh, getTimeNowUs(), momentX, (long)pair);
|
||||
assertEvent(msg, eventIndex, (void*)seTurnPinHigh, momentX, (long)pair);
|
||||
}
|
||||
|
||||
void EngineTestHelper::assertInjectorDownEvent(const char *msg, int eventIndex, efitime_t momentX, long injectorIndex) {
|
||||
InjectionSignalPair *pair = &engine.fuelActuators[injectorIndex];
|
||||
assertEvent(msg, eventIndex, (void*)seTurnPinLow, getTimeNowUs(), momentX, (long)pair);
|
||||
assertEvent(msg, eventIndex, (void*)seTurnPinLow, momentX, (long)pair);
|
||||
}
|
||||
|
||||
scheduling_s * EngineTestHelper::assertEvent5(const char *msg, int index, void *callback, efitime_t start, efitime_t momentX) {
|
||||
scheduling_s * EngineTestHelper::assertEvent5(const char *msg, int index, void *callback, efitime_t expectedTimestamp) {
|
||||
TestExecutor *executor = &engine.executor;
|
||||
EXPECT_TRUE(executor->size() > index) << msg;
|
||||
scheduling_s *event = executor->getForUnitTest(index);
|
||||
assertEqualsM4(msg, " up/down", (void*)event->callback == (void*) callback, 1);
|
||||
assertEqualsM(msg, momentX, event->momentX - start);
|
||||
efitime_t start = getTimeNowUs();
|
||||
assertEqualsM(msg, expectedTimestamp, event->momentX - start);
|
||||
return event;
|
||||
}
|
||||
|
||||
void EngineTestHelper::assertEvent(const char *msg, int index, void *callback, efitime_t start, efitime_t momentX, long param) {
|
||||
scheduling_s *event = assertEvent5(msg, index, callback, start, momentX);
|
||||
void EngineTestHelper::assertEvent(const char *msg, int index, void *callback, efitime_t momentX, long param) {
|
||||
scheduling_s *event = assertEvent5(msg, index, callback, momentX);
|
||||
|
||||
InjectionSignalPair *eventPair = (InjectionSignalPair *)event->param;
|
||||
|
||||
|
|
|
@ -46,8 +46,8 @@ public:
|
|||
void fireTriggerEvents2(int count, float delayMs);
|
||||
void clearQueue();
|
||||
|
||||
scheduling_s * assertEvent5(const char *msg, int index, void *callback, efitime_t start, efitime_t momentX);
|
||||
void assertEvent(const char *msg, int index, void *callback, efitime_t start, efitime_t momentX, long param);
|
||||
scheduling_s * assertEvent5(const char *msg, int index, void *callback, efitime_t expectedTimestamp);
|
||||
void assertEvent(const char *msg, int index, void *callback, 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);
|
||||
// todo: open question if this is worth a helper method or should be inlined?
|
||||
|
|
|
@ -53,8 +53,8 @@ TEST(cranking, testFasterEngineSpinningUp) {
|
|||
// test if ignition mode is temporary changed to wasted spark, if set to individual coils
|
||||
ASSERT_EQ(IM_WASTED_SPARK, getCurrentIgnitionMode(PASS_ENGINE_PARAMETER_SIGNATURE));
|
||||
// check real events
|
||||
eth.assertEvent5("inj start#1", 0, (void*)startSimultaniousInjection, timeStartUs, MS2US(200) + 98125);
|
||||
eth.assertEvent5("inj end#1", 1, (void*)endSimultaniousInjection, timeStartUs, MS2US(200) + 100000);
|
||||
eth.assertEvent5("inj start#1", 0, (void*)startSimultaniousInjection, 98125);
|
||||
eth.assertEvent5("inj end#1", 1, (void*)endSimultaniousInjection, 100000);
|
||||
|
||||
// skip the rest of the cycle
|
||||
eth.fireFall(200);
|
||||
|
@ -75,8 +75,8 @@ TEST(cranking, testFasterEngineSpinningUp) {
|
|||
// two simultaneous injections
|
||||
ASSERT_EQ( 4, engine->executor.size()) << "plain#2";
|
||||
// check real events
|
||||
eth.assertEvent5("inj start#2", 0, (void*)startSimultaniousInjection, eth.getTimeNowUs(), 148125);
|
||||
eth.assertEvent5("inj end#2", 1, (void*)endSimultaniousInjection, eth.getTimeNowUs(), 150000);
|
||||
eth.assertEvent5("inj start#2", 0, (void*)startSimultaniousInjection, 148125);
|
||||
eth.assertEvent5("inj end#2", 1, (void*)endSimultaniousInjection, 150000);
|
||||
|
||||
// skip, clear & advance 1 more revolution at higher RPM
|
||||
eth.fireFall(60);
|
||||
|
@ -96,8 +96,8 @@ TEST(cranking, testFasterEngineSpinningUp) {
|
|||
|
||||
// check real events for sequential injection
|
||||
// Note: See addFuelEvents() fix inside setRpmValue()!
|
||||
eth.assertEvent5("inj start#3", 0, (void*)seTurnPinHigh, timeStartUs, MS2US(60) + 28125);
|
||||
eth.assertEvent5("inj end#3", 1, (void*)seTurnPinLow, timeStartUs, MS2US(60) + 28125 + 3000);
|
||||
eth.assertEvent5("inj start#3", 0, (void*)seTurnPinHigh, -31875);
|
||||
eth.assertEvent5("inj end#3", 1, (void*)seTurnPinLow, -28875);
|
||||
}
|
||||
|
||||
static void doTestFasterEngineSpinningUp60_2(int startUpDelayMs, int rpm1, int expectedRpm) {
|
||||
|
|
|
@ -25,8 +25,8 @@ TEST(engine, testPlainCrankingWithoutAdvancedFeatures) {
|
|||
// two simultaneous injections
|
||||
ASSERT_EQ( 4, engine->executor.size()) << "plain#2";
|
||||
|
||||
eth.assertEvent5("sim start", 0, (void*)startSimultaniousInjection, eth.getTimeNowUs(), 100000 - 1875);
|
||||
eth.assertEvent5("sim end", 1, (void*)endSimultaniousInjection, eth.getTimeNowUs(), 100000);
|
||||
eth.assertEvent5("sim start", 0, (void*)startSimultaniousInjection, 100000 - 1875);
|
||||
eth.assertEvent5("sim end", 1, (void*)endSimultaniousInjection, 100000);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue