Andrey 2022-01-18 10:24:08 -05:00
parent c23c93a384
commit 7e007cc534
4 changed files with 51 additions and 0 deletions

View File

@ -424,6 +424,8 @@ void OutputPin::setValue(int logicValue) {
#endif // ENABLE_PERF_TRACE
#if EFI_UNIT_TEST
unitTestTurnedOnCounter++;
if (verboseMode) {
efiPrintf("pin goes %d", logicValue);
}
@ -495,6 +497,10 @@ void OutputPin::initPin(const char *msg, brain_pin_e brainPin) {
}
void OutputPin::initPin(const char *msg, brain_pin_e brainPin, const pin_output_mode_e *outputMode, bool forceInitWithFatalError) {
#if EFI_UNIT_TEST
unitTestTurnedOnCounter = 0;
#endif
if (!isBrainPinValid(brainPin)) {
return;
}

View File

@ -65,6 +65,10 @@ public:
uint8_t pin = 0;
#endif /* EFI_GPIO_HARDWARE */
#if EFI_UNIT_TEST
int unitTestTurnedOnCounter = 0;
#endif
brain_pin_e brainPin = GPIO_UNASSIGNED;
#if (EFI_GPIO_HARDWARE && (BOARD_EXT_GPIOCHIPS > 0))

View File

@ -0,0 +1,40 @@
/*
* @file test_hpfp_integrated.cpp
*
* Created on: Jan 18, 2022
* More integrated version of HPFP test
*/
#include "pch.h"
TEST(HPFP, IntegratedSchedule) {
EngineTestHelper eth(TEST_ENGINE, [](engine_configuration_s* engineConfiguration) {
engineConfiguration->hpfpValvePin = GPIOA_2; // arbitrary
});
engineConfiguration->specs.cylindersCount = 4;
engineConfiguration->hpfpCamLobes = 3;
engineConfiguration->hpfpPumpVolume = 0.2; // cc/lobe
engineConfiguration->trigger.customTotalToothCount = 16;
engineConfiguration->trigger.customSkippedToothCount = 0;
eth.setTriggerType(TT_TOOTHED_WHEEL);
engineConfiguration->ambiguousOperationMode = FOUR_STROKE_CAM_SENSOR;
engineConfiguration->isFasterEngineSpinUpEnabled = true;
eth.smartFireTriggerEvents2(/*count*/40, /*delay*/ 4);
ASSERT_EQ(937, GET_RPM());
for (int i = 0;i<100;i++) {
eth.smartFireTriggerEvents2(/*count*/1, /*delay*/ 4);
engine->periodicFastCallback();
}
/**
* overall this is a pretty lame test but helps to know that the whole on/off/on dance does in fact happen for HPFP
*/
ASSERT_EQ(31, enginePins.hpfpValve.unitTestTurnedOnCounter);
}

View File

@ -88,6 +88,7 @@ TESTS_SRC_CPP = \
tests/test_boost.cpp \
tests/test_gppwm.cpp \
tests/test_hpfp.cpp \
tests/test_hpfp_integrated.cpp \
tests/test_fuel_math.cpp \
tests/test_binary_log.cpp \
tests/test_dynoview.cpp \