Skip to content

Commit

Permalink
testability: bench test commands should have automated coverage using…
Browse files Browse the repository at this point in the history
… simulator #5562
  • Loading branch information
rusefillc committed Sep 11, 2023
1 parent daf4edb commit e5f7c98
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
10 changes: 7 additions & 3 deletions firmware/controllers/system/efi_gpio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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)) {
Expand Down
4 changes: 2 additions & 2 deletions firmware/controllers/system/efi_output.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ class OutputPin {
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;
Expand Down
2 changes: 1 addition & 1 deletion unit_tests/tests/test_hpfp_integrated.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}


0 comments on commit e5f7c98

Please sign in to comment.