testability: bench test commands should have automated coverage using simulator #5562

This commit is contained in:
Andrey 2023-09-11 00:03:10 -04:00
parent daf4edb04e
commit e5f7c9885c
3 changed files with 10 additions and 6 deletions

View File

@ -508,9 +508,13 @@ void OutputPin::setValue(const char *msg, int logicValue, bool isForce) {
// ScopePerf perf(PE::OutputPinSetValue);
#endif // ENABLE_PERF_TRACE
#if EFI_UNIT_TEST
unitTestTurnedOnCounter++;
#if EFI_UNIT_TEST || EFI_SIMULATOR
if (currentLogicValue != logicValue) {
pinToggleCounter++;
}
#endif // EFI_UNIT_TEST || EFI_SIMULATOR
#if EFI_UNIT_TEST
if (verboseMode) {
efiPrintf("pin goes %d", logicValue);
}
@ -587,7 +591,7 @@ void OutputPin::initPin(const char *msg, brain_pin_e brainPin) {
void OutputPin::initPin(const char *msg, brain_pin_e brainPin, pin_output_mode_e outputMode, bool forceInitWithFatalError) {
#if EFI_UNIT_TEST
unitTestTurnedOnCounter = 0;
pinToggleCounter = 0;
#endif
if (!isBrainPinValid(brainPin)) {

View File

@ -65,8 +65,8 @@ public:
uint8_t pin = 0;
#endif /* EFI_GPIO_HARDWARE */
#if EFI_UNIT_TEST
int unitTestTurnedOnCounter = 0;
#if EFI_UNIT_TEST || EFI_SIMULATOR
int pinToggleCounter = 0;
#endif
brain_pin_e brainPin = Gpio::Unassigned;

View File

@ -34,7 +34,7 @@ TEST(HPFP, IntegratedSchedule) {
/**
* 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);
ASSERT_EQ(8, enginePins.hpfpValve.pinToggleCounter);
}