logicdata into unit tests
This commit is contained in:
parent
517761320e
commit
b2edd3a4f4
|
@ -55,6 +55,25 @@ int getCompositeRecordCount() {
|
||||||
return NextIdx;
|
return NextIdx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if EFI_UNIT_TEST
|
||||||
|
#include "logicdata.h"
|
||||||
|
int copyCompositeEvents(CompositeEvent *events) {
|
||||||
|
for (int i = 0;i < NextIdx;i++) {
|
||||||
|
CompositeEvent *event = &events[i];
|
||||||
|
event->timestamp = buffer[i].timestamp;
|
||||||
|
event->primaryTrigger = buffer[i].priLevel;
|
||||||
|
event->secondaryTrigger = buffer[i].secLevel;
|
||||||
|
event->trg = buffer[i].trigger;
|
||||||
|
event->sync = buffer[i].sync;
|
||||||
|
event->coil = buffer[i].coil;
|
||||||
|
event->injector = buffer[i].injector;
|
||||||
|
}
|
||||||
|
return NextIdx;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // EFI_UNIT_TEST
|
||||||
|
|
||||||
static void SetNextCompositeEntry(efitick_t timestamp, bool trigger1, bool trigger2,
|
static void SetNextCompositeEntry(efitick_t timestamp, bool trigger1, bool trigger2,
|
||||||
bool isTDC DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
bool isTDC DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
uint32_t nowUs = NT2US(timestamp);
|
uint32_t nowUs = NT2US(timestamp);
|
||||||
|
|
|
@ -13,6 +13,11 @@
|
||||||
#include "rusefi_enums.h"
|
#include "rusefi_enums.h"
|
||||||
#include "engine.h"
|
#include "engine.h"
|
||||||
|
|
||||||
|
#if EFI_UNIT_TEST
|
||||||
|
#include "logicdata.h"
|
||||||
|
int copyCompositeEvents(CompositeEvent *events);
|
||||||
|
#endif // EFI_UNIT_TEST
|
||||||
|
|
||||||
int getCompositeRecordCount();
|
int getCompositeRecordCount();
|
||||||
|
|
||||||
void EnableToothLoggerIfNotEnabled();
|
void EnableToothLoggerIfNotEnabled();
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
#include "engine_controller.h"
|
#include "engine_controller.h"
|
||||||
#include "advance_map.h"
|
#include "advance_map.h"
|
||||||
#include "sensor.h"
|
#include "sensor.h"
|
||||||
|
#include "tooth_logger.h"
|
||||||
|
#include "logicdata.h"
|
||||||
|
|
||||||
extern int timeNowUs;
|
extern int timeNowUs;
|
||||||
extern WarningCodeState unitTestWarningCodeState;
|
extern WarningCodeState unitTestWarningCodeState;
|
||||||
|
@ -25,6 +27,7 @@ extern bool printFuelDebug;
|
||||||
EngineTestHelperBase::EngineTestHelperBase() {
|
EngineTestHelperBase::EngineTestHelperBase() {
|
||||||
// todo: make this not a global variable, we need currentTimeProvider interface on engine
|
// todo: make this not a global variable, we need currentTimeProvider interface on engine
|
||||||
timeNowUs = 0;
|
timeNowUs = 0;
|
||||||
|
EnableToothLogger();
|
||||||
}
|
}
|
||||||
|
|
||||||
EngineTestHelper::EngineTestHelper(engine_type_e engineType, configuration_callback_t boardCallback)
|
EngineTestHelper::EngineTestHelper(engine_type_e engineType, configuration_callback_t boardCallback)
|
||||||
|
@ -86,6 +89,18 @@ EngineTestHelper::~EngineTestHelper() {
|
||||||
Sensor::resetRegistry();
|
Sensor::resetRegistry();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static CompositeEvent compositeEvents[COMPOSITE_PACKET_COUNT];
|
||||||
|
|
||||||
|
void EngineTestHelper::writeEvents(const char *fileName) {
|
||||||
|
int count = copyCompositeEvents(compositeEvents);
|
||||||
|
if (count < 2) {
|
||||||
|
printf("Not enough data for %s\n", fileName);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
printf("Writing %d records to %s\n", count, fileName);
|
||||||
|
writeFile(fileName, compositeEvents, count);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* mock a change of time and fire single RISE front event
|
* mock a change of time and fire single RISE front event
|
||||||
*/
|
*/
|
||||||
|
@ -98,7 +113,11 @@ void EngineTestHelper::fireRise(float delayMs) {
|
||||||
* fire single RISE front event
|
* fire single RISE front event
|
||||||
*/
|
*/
|
||||||
void EngineTestHelper::firePrimaryTriggerRise() {
|
void EngineTestHelper::firePrimaryTriggerRise() {
|
||||||
engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_RISING, getTimeNowNt(), &engine, engine.engineConfigurationPtr, &persistentConfig);
|
efitick_t nowNt = getTimeNowNt();
|
||||||
|
Engine *engine = &this->engine;
|
||||||
|
EXPAND_Engine;
|
||||||
|
LogTriggerTooth(SHAFT_PRIMARY_RISING, nowNt PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
|
engine->triggerCentral.handleShaftSignal(SHAFT_PRIMARY_RISING, nowNt, engine, engine->engineConfigurationPtr, &persistentConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EngineTestHelper::fireFall(float delayMs) {
|
void EngineTestHelper::fireFall(float delayMs) {
|
||||||
|
@ -107,7 +126,11 @@ void EngineTestHelper::fireFall(float delayMs) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void EngineTestHelper::firePrimaryTriggerFall() {
|
void EngineTestHelper::firePrimaryTriggerFall() {
|
||||||
engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_FALLING, getTimeNowNt(), &engine, engine.engineConfigurationPtr, &persistentConfig);
|
efitick_t nowNt = getTimeNowNt();
|
||||||
|
Engine *engine = &this->engine;
|
||||||
|
EXPAND_Engine;
|
||||||
|
LogTriggerTooth(SHAFT_PRIMARY_FALLING, nowNt PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
|
engine->triggerCentral.handleShaftSignal(SHAFT_PRIMARY_FALLING, nowNt, engine, engine->engineConfigurationPtr, &persistentConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EngineTestHelper::fireTriggerEventsWithDuration(float durationMs) {
|
void EngineTestHelper::fireTriggerEventsWithDuration(float durationMs) {
|
||||||
|
|
|
@ -68,6 +68,8 @@ public:
|
||||||
void moveTimeForwardUs(int deltaTimeUs);
|
void moveTimeForwardUs(int deltaTimeUs);
|
||||||
efitimeus_t getTimeNowUs(void);
|
efitimeus_t getTimeNowUs(void);
|
||||||
|
|
||||||
|
void writeEvents(const char *fileName);
|
||||||
|
|
||||||
Engine engine;
|
Engine engine;
|
||||||
persistent_config_s persistentConfig;
|
persistent_config_s persistentConfig;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
/**
|
||||||
|
* @file logicdata_sandbox.cpp
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include "logicdata.h"
|
#include "logicdata.h"
|
||||||
|
|
|
@ -35,6 +35,9 @@ TEST(fuelControl, transitionIssue1592) {
|
||||||
|
|
||||||
ASSERT_EQ(IM_SIMULTANEOUS, ENGINE(getCurrentInjectionMode(PASS_ENGINE_PARAMETER_SIGNATURE)));
|
ASSERT_EQ(IM_SIMULTANEOUS, ENGINE(getCurrentInjectionMode(PASS_ENGINE_PARAMETER_SIGNATURE)));
|
||||||
|
|
||||||
|
|
||||||
|
eth.writeEvents("transitionIssue1592.logicdata");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue