unit test framework improvements for smoother event execution
This commit is contained in:
parent
c4885dcc0e
commit
117e98b753
|
@ -28,7 +28,7 @@ typedef struct __attribute__ ((packed)) {
|
|||
// unfortunately all these fields are required by TS...
|
||||
bool priLevel : 1;
|
||||
bool secLevel : 1;
|
||||
bool trigger : 1;
|
||||
bool isTDC : 1;
|
||||
bool sync : 1;
|
||||
bool coil : 1;
|
||||
bool injector : 1;
|
||||
|
@ -64,7 +64,7 @@ int copyCompositeEvents(CompositeEvent *events) {
|
|||
event->timestamp = SWAP_UINT32(buffer[i].timestamp);
|
||||
event->primaryTrigger = buffer[i].priLevel;
|
||||
event->secondaryTrigger = buffer[i].secLevel;
|
||||
event->trg = buffer[i].trigger;
|
||||
event->isTDC = buffer[i].isTDC;
|
||||
event->sync = buffer[i].sync;
|
||||
event->coil = buffer[i].coil;
|
||||
event->injector = buffer[i].injector;
|
||||
|
@ -81,7 +81,7 @@ static void SetNextCompositeEntry(efitick_t timestamp, bool trigger1, bool trigg
|
|||
buffer[NextIdx].timestamp = SWAP_UINT32(nowUs);
|
||||
buffer[NextIdx].priLevel = trigger1;
|
||||
buffer[NextIdx].secLevel = trigger2;
|
||||
buffer[NextIdx].trigger = isTDC;
|
||||
buffer[NextIdx].isTDC = isTDC;
|
||||
buffer[NextIdx].sync = engine->triggerCentral.triggerState.shaft_is_synchronized;
|
||||
buffer[NextIdx].coil = coil;
|
||||
buffer[NextIdx].injector = injector;
|
||||
|
@ -144,6 +144,7 @@ void LogTriggerTopDeadCenter(efitick_t timestamp DECLARE_ENGINE_PARAMETER_SUFFIX
|
|||
return;
|
||||
}
|
||||
SetNextCompositeEntry(timestamp, trigger1, trigger2, true PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
SetNextCompositeEntry(timestamp + 10, trigger1, trigger2, false PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
}
|
||||
|
||||
void LogTriggerCoilState(efitick_t timestamp, bool state DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||
|
|
|
@ -111,7 +111,7 @@ void EngineTestHelper::fireRise(float delayMs) {
|
|||
}
|
||||
|
||||
void EngineTestHelper::smartFireRise(float delayMs) {
|
||||
moveTimeForwardUs(MS2US(delayMs));
|
||||
smartMoveTimeForwardUs(MS2US(delayMs));
|
||||
firePrimaryTriggerRise();
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,7 @@ void EngineTestHelper::fireFall(float delayMs) {
|
|||
}
|
||||
|
||||
void EngineTestHelper::smartFireFall(float delayMs) {
|
||||
moveTimeForwardUs(MS2US(delayMs));
|
||||
smartMoveTimeForwardUs(MS2US(delayMs));
|
||||
firePrimaryTriggerFall();
|
||||
}
|
||||
|
||||
|
@ -187,11 +187,31 @@ void EngineTestHelper::moveTimeForwardUs(int deltaTimeUs) {
|
|||
timeNowUs += deltaTimeUs;
|
||||
}
|
||||
|
||||
/**
|
||||
* this method executed all pending events wile
|
||||
*/
|
||||
void EngineTestHelper::smartMoveTimeForwardUs(int deltaTimeUs) {
|
||||
if (printTriggerDebug || printFuelDebug) {
|
||||
printf("moveTimeForwardUs %.1fms\r\n", deltaTimeUs / 1000.0);
|
||||
printf("smartMoveTimeForwardUs %.1fms\r\n", deltaTimeUs / 1000.0);
|
||||
}
|
||||
timeNowUs += deltaTimeUs;
|
||||
int targetTime = timeNowUs + deltaTimeUs;
|
||||
|
||||
while (true) {
|
||||
scheduling_s* nextScheduledEvent = engine.executor.getHead();
|
||||
if (nextScheduledEvent == nullptr) {
|
||||
// nothing pending - we are done here
|
||||
break;
|
||||
}
|
||||
int nextEventTime = nextScheduledEvent->momentX;
|
||||
if (nextEventTime > targetTime) {
|
||||
// next event is too far in the future
|
||||
break;
|
||||
}
|
||||
timeNowUs = nextEventTime;
|
||||
engine.executor.executeAll(timeNowUs);
|
||||
}
|
||||
|
||||
timeNowUs = targetTime;
|
||||
}
|
||||
|
||||
efitimeus_t EngineTestHelper::getTimeNowUs(void) {
|
||||
|
@ -233,9 +253,9 @@ static AngleBasedEvent * getElementAtIndexForUnitText(int index, Engine *engine)
|
|||
index--;
|
||||
}
|
||||
#if EFI_UNIT_TEST
|
||||
firmwareError(OBD_PCM_Processor_Fault, "getForUnitText: null");
|
||||
firmwareError(OBD_PCM_Processor_Fault, "getElementAtIndexForUnitText: null");
|
||||
#endif /* EFI_UNIT_TEST */
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
AngleBasedEvent * EngineTestHelper::assertTriggerEvent(const char *msg,
|
||||
|
|
|
@ -35,6 +35,10 @@ int TestExecutor::size() {
|
|||
return schedulingQueue.size();
|
||||
}
|
||||
|
||||
scheduling_s* TestExecutor::getHead() {
|
||||
return schedulingQueue.getHead();
|
||||
}
|
||||
|
||||
scheduling_s* TestExecutor::getForUnitTest(int index) {
|
||||
return schedulingQueue.getElementAtIndexForUnitText(index);
|
||||
}
|
||||
|
|
|
@ -18,7 +18,8 @@ public:
|
|||
void clear();
|
||||
int executeAll(efitime_t now);
|
||||
int size();
|
||||
scheduling_s* getForUnitTest(int index);
|
||||
scheduling_s * getHead();
|
||||
scheduling_s * getForUnitTest(int index);
|
||||
|
||||
void setMockExecutor(ExecutorInterface* exec);
|
||||
private:
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
#define MAX_STRING_SIZE 40
|
||||
|
||||
static char channelNames[][MAX_STRING_SIZE] = { "Primary", "Secondary", "Trg",
|
||||
static char channelNames[][MAX_STRING_SIZE] = { "Primary", "Secondary", "TDC",
|
||||
"Sync", "Coil", "Injector", "Channel 6", "Channel 7" };
|
||||
|
||||
static int CHANNEL_FLAGS[] = { 0x13458b, 0x0000ff, 0x00a0f9, 0x00ffff, 0x00ff00,
|
||||
|
@ -378,7 +378,7 @@ static int getChannelState(int ch, CompositeEvent *event) {
|
|||
case 1:
|
||||
return event->secondaryTrigger;
|
||||
case 2:
|
||||
return event->trg;
|
||||
return event->isTDC;
|
||||
case 3:
|
||||
return event->sync;
|
||||
case 4:
|
||||
|
|
|
@ -11,7 +11,7 @@ struct CompositeEvent {
|
|||
int timestamp;
|
||||
bool primaryTrigger;
|
||||
bool secondaryTrigger;
|
||||
bool trg;
|
||||
bool isTDC;
|
||||
bool sync;
|
||||
bool coil;
|
||||
bool injector;
|
||||
|
|
|
@ -8,13 +8,12 @@
|
|||
|
||||
static CompositeEvent events[100];
|
||||
|
||||
|
||||
void setEvent(CompositeEvent *events, int index,
|
||||
int timestamp, bool primaryTrigger, bool secondaryTrigger, bool trg, bool sync, bool coil, bool injector) {
|
||||
static void setEvent(CompositeEvent *events, int index,
|
||||
int timestamp, bool primaryTrigger, bool secondaryTrigger, bool isTDC, bool sync, bool coil, bool injector) {
|
||||
events[index].timestamp = timestamp;
|
||||
events[index].primaryTrigger = primaryTrigger;
|
||||
events[index].secondaryTrigger = secondaryTrigger;
|
||||
events[index].trg = trg;
|
||||
events[index].isTDC = isTDC;
|
||||
events[index].sync = sync;
|
||||
events[index].coil = coil;
|
||||
events[index].injector = injector;
|
||||
|
@ -23,7 +22,6 @@ void setEvent(CompositeEvent *events, int index,
|
|||
void runLogicdataSandbox() {
|
||||
printf(".logicdata Sandbox 20200719\n");
|
||||
|
||||
|
||||
int index = 0;
|
||||
setEvent(events, index++, 10, false, false, false, false, false, false);
|
||||
setEvent(events, index++, 20, true, false, true, false, false, false);
|
||||
|
|
|
@ -36,8 +36,5 @@ TEST(fuelControl, transitionIssue1592) {
|
|||
ASSERT_EQ(IM_SIMULTANEOUS, ENGINE(getCurrentInjectionMode(PASS_ENGINE_PARAMETER_SIGNATURE)));
|
||||
|
||||
|
||||
eth.writeEvents("transitionIssue1592.logicdata");
|
||||
|
||||
eth.writeEvents("fuel_schedule_transition_issue_1592.logicdata");
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue