technical debt: NT -> US -> NT in unit test scheduler [fix code & prepare flag for now broken test]

see #7245
This commit is contained in:
FDSoftware 2025-03-06 15:38:07 -03:00 committed by rusefillc
parent 715019ec7f
commit 44f33b0579
2 changed files with 13 additions and 3 deletions

View File

@ -21,6 +21,7 @@
#include <sys/stat.h>
bool unitTestBusyWaitHack;
bool unitTestTaskPrecisionHack;
#if EFI_ENGINE_SNIFFER
#include "engine_sniffer.h"
@ -360,7 +361,12 @@ void EngineTestHelper::setTimeAndInvokeEventsUs(int targetTimeUs) {
break;
}
setTimeNowUs(nextEventTime);
engine.scheduler.executeAll(getTimeNowUs());
extern bool unitTestTaskPrecisionHack;
if (unitTestTaskPrecisionHack) {
engine.scheduler.executeAll(getTimeNowUs());
} else {
engine.scheduler.executeAll(getTimeNowNt());
}
}
setTimeNowUs(targetTimeUs);

View File

@ -43,8 +43,12 @@ void TestExecutor::schedule(const char *msg, scheduling_s* scheduling, efitick_t
// technical debt: NT -> US -> NT in unit test scheduler #7245
// by the way we have loss of precision while converting NT to integer US
// technical debt: looks like our unit tests were all created with us precision?
efitimeus_t timeUs = NT2US(timeNt);
schedulingQueue.insertTask(scheduling, US2NT(timeUs), action);
efitimeus_t scheduleTime = timeNt;
extern bool unitTestTaskPrecisionHack;
if(unitTestTaskPrecisionHack) {
scheduleTime = US2NT(NT2US(timeNt));
}
schedulingQueue.insertTask(scheduling, scheduleTime, action);
}
void TestExecutor::cancel(scheduling_s* s) {