unit tests run in US with a loss of precision from NT #6450

only: hiding skeletons deeper in the closet
This commit is contained in:
rusefi 2024-05-03 00:49:08 -04:00
parent cc82085f26
commit 06db619635
6 changed files with 19 additions and 0 deletions

View File

@ -244,6 +244,12 @@ bool EventQueue::executeOne(efitick_t now) {
// yes, that's a busy wait but that's what we need here
// todo: problem: we have a defect - tests are using US not NT so we are comparing apples to oranges here!
while (current->getMomentNt() > getTimeNowNt()) {
#if EFI_UNIT_TEST
extern bool unitTestBusyWaitHack;
if (unitTestBusyWaitHack) {
break;
}
#endif
UNIT_TEST_BUSY_WAIT_CALLBACK();
}

View File

@ -16,6 +16,8 @@
#include "logicdata.h"
#include "hardware.h"
bool unitTestBusyWaitHack;
#if EFI_ENGINE_SNIFFER
#include "engine_sniffer.h"
extern WaveChart waveChart;
@ -32,6 +34,7 @@ EngineTestHelperBase::EngineTestHelperBase(Engine * eng, engine_configuration_s
// todo: make this not a global variable, we need currentTimeProvider interface on engine
setTimeNowUs(0);
minCrankingRpm = 0;
unitTestBusyWaitHack = false;
EnableToothLogger();
if (engine || engineConfiguration || config) {
firmwareError(ObdCode::OBD_PCM_Processor_Fault,

View File

@ -46,6 +46,8 @@ TEST(ignition, twoCoils) {
TEST(ignition, trailingSpark) {
EngineTestHelper eth(engine_type_e::TEST_ENGINE);
engineConfiguration->isFasterEngineSpinUpEnabled = false;
extern bool unitTestBusyWaitHack;
unitTestBusyWaitHack = true;
/**
// TODO #3220: this feature makes this test sad, eventually remove this line (and the ability to disable it altogether)

View File

@ -9,6 +9,8 @@ using ::testing::_;
TEST(OddFireRunningMode, hd) {
// basic engine setup
EngineTestHelper eth(engine_type_e::HARLEY);
extern bool unitTestBusyWaitHack;
unitTestBusyWaitHack = true;
engineConfiguration->cranking.rpm = 100;
engineConfiguration->vvtMode[0] = VVT_SINGLE_TOOTH; // need to avoid engine phase sync requirement
// let's pretend to have a 32 degree V odd fire engine.

View File

@ -9,6 +9,8 @@
TEST(cranking, testFasterEngineSpinningUp) {
EngineTestHelper eth(engine_type_e::TEST_ENGINE);
extern bool unitTestBusyWaitHack;
unitTestBusyWaitHack = true;
float phase = 181;
setTable(config->injectionPhase, -phase);
engine->tdcMarkEnabled = false;

View File

@ -528,6 +528,8 @@ void doTestFuelSchedulerBug299smallAndMedium(int startUpDelayMs) {
printf("*************************************************** testFuelSchedulerBug299 small to medium\r\n");
EngineTestHelper eth(engine_type_e::TEST_ENGINE);
extern bool unitTestBusyWaitHack;
unitTestBusyWaitHack = true;
setTable(config->injectionPhase, -180.0f);
engineConfiguration->isFasterEngineSpinUpEnabled = false;
engine->tdcMarkEnabled = false;
@ -885,6 +887,8 @@ TEST(big, testSinglePoint) {
TEST(big, testFuelSchedulerBug299smallAndLarge) {
EngineTestHelper eth(engine_type_e::TEST_ENGINE);
extern bool unitTestBusyWaitHack;
unitTestBusyWaitHack = true;
engineConfiguration->hpfpCamLobes = 0;
setTable(config->injectionPhase, -180.0f);
engineConfiguration->isFasterEngineSpinUpEnabled = false;