parent
a86976b6f1
commit
3a5ea90417
|
@ -243,6 +243,22 @@ static void SetNextCompositeEntry(efitick_t timestamp) {
|
|||
#endif // EFI_UNIT_TEST
|
||||
|
||||
void LogTriggerTooth(trigger_event_e tooth, efitick_t timestamp) {
|
||||
|
||||
|
||||
#if EFI_UNIT_TEST
|
||||
extern FILE *jsonTrace;
|
||||
//static efitick_t risingTimestamp = 0;
|
||||
if (jsonTrace != nullptr) {
|
||||
if (tooth == SHAFT_PRIMARY_RISING) {
|
||||
fprintf(jsonTrace, ",\n");
|
||||
fprintf(jsonTrace, "{\"name\":\"trg0\",\"ph\":\"B\",\"tid\":0,\"pid\":54,\"ts\":%f}", timestamp / 1000.0);
|
||||
} else if (tooth == SHAFT_PRIMARY_FALLING) {
|
||||
fprintf(jsonTrace, ",\n");
|
||||
fprintf(jsonTrace, "{\"name\":\"trg0\",\"ph\":\"E\",\"tid\":0,\"pid\":54,\"ts\":%f}", timestamp / 1000.0);
|
||||
}
|
||||
}
|
||||
#endif // EFI_UNIT_TEST
|
||||
|
||||
efiAssertVoid(ObdCode::CUSTOM_ERR_6650, hasLotsOfRemainingStack(), "l-t-t");
|
||||
// bail if we aren't enabled
|
||||
if (!ToothLoggerEnabled) {
|
||||
|
|
|
@ -4,4 +4,5 @@ gcov_working_area
|
|||
triggers
|
||||
unittest*.logicdata
|
||||
unittest*.events.txt
|
||||
unittest*.json
|
||||
/.idea/
|
||||
|
|
|
@ -73,6 +73,8 @@ int EngineTestHelper::getWarningCounter() {
|
|||
return unitTestWarningCodeState.warningCounter;
|
||||
}
|
||||
|
||||
FILE *jsonTrace;
|
||||
|
||||
EngineTestHelper::EngineTestHelper(engine_type_e engineType, configuration_callback_t configurationCallback, const std::unordered_map<SensorType, float>& sensorValues) :
|
||||
EngineTestHelperBase(&engine, &persistentConfig.engineConfiguration, &persistentConfig)
|
||||
{
|
||||
|
@ -80,6 +82,24 @@ EngineTestHelper::EngineTestHelper(engine_type_e engineType, configuration_callb
|
|||
memset(&pinRepository, 0, sizeof(pinRepository));
|
||||
|
||||
|
||||
auto testInfo = ::testing::UnitTest::GetInstance()->current_test_info();
|
||||
extern bool hasInitGtest;
|
||||
if (hasInitGtest) {
|
||||
std::stringstream filePath;
|
||||
filePath << "unittest_" << testInfo->test_case_name() << "_" << testInfo->name() << "_trace.json";
|
||||
const char *fileName = filePath.str().c_str();
|
||||
// jsonTrace = fopen(fileName, "wb");
|
||||
if (jsonTrace == nullptr) {
|
||||
// criticalError("Error creating file [%s]", fileName);
|
||||
} else {
|
||||
// fprintf(jsonTrace, "{\"traceEvents\": [\n");
|
||||
// fprintf(jsonTrace, "{\"name\":\"process_name\",\"ph\":\"M\",\"pid\":-16,\"tid\":0,\"args\":{\"name\":\"Main\"}}\n");
|
||||
}
|
||||
} else {
|
||||
// todo: document why this branch even exists
|
||||
jsonTrace = nullptr;
|
||||
}
|
||||
|
||||
Sensor::setMockValue(SensorType::Clt, 70);
|
||||
Sensor::setMockValue(SensorType::Iat, 30);
|
||||
|
||||
|
@ -181,6 +201,12 @@ EngineTestHelper::~EngineTestHelper() {
|
|||
writeEvents2(filePath.str().c_str());
|
||||
}
|
||||
|
||||
if (jsonTrace != nullptr) {
|
||||
fprintf(jsonTrace, "]}\n");
|
||||
fclose(jsonTrace);
|
||||
jsonTrace = nullptr;
|
||||
}
|
||||
|
||||
// Cleanup
|
||||
enginePins.reset();
|
||||
enginePins.unregisterPins();
|
||||
|
|
Loading…
Reference in New Issue