From cc95bd6c8e105a036177a9ffbef7073d5401a01c Mon Sep 17 00:00:00 2001 From: Scott Smith Date: Tue, 16 Nov 2021 13:52:11 -0800 Subject: [PATCH] Programmatically remove EnginePtr/inject, EXPAND_Engine, and WITH_ENGINE_TEST_HELPER* (#3560) * Programmatically remove EnginePtr/inject, EXPAND_Engine, and WITH_ENGINE_TEST_HELPER* for i in ": public EnginePtr " ", public EnginePtr" "EXPAND_Engine;" "EXPAND_Engine"; do git grep -l "$i" | xargs sed -i "s/$i//g" done git grep -l "inject" | xargs sed -i "/inject[(][)]/d" for i in WITH_ENGINE_TEST_HELPER_SENS WITH_ENGINE_TEST_HELPER_BOARD_CALLBACK WITH_ENGINE_TEST_HELPER; do git grep -l "$i" | xargs sed -i "s/$i/EngineTestHelper eth/g" done git checkout firmware/controllers/core/engine_ptr.h git checkout unit_tests/global.h * Review fixups. --- .../controllers/actuators/boost_control.h | 2 +- .../actuators/electronic_throttle.cpp | 1 - .../actuators/electronic_throttle.h | 2 +- .../controllers/actuators/gppwm/gppwm.cpp | 1 - .../actuators/gppwm/gppwm_channel.h | 2 +- .../controllers/actuators/idle_thread.cpp | 2 - firmware/controllers/actuators/idle_thread.h | 2 +- firmware/controllers/actuators/vvt.cpp | 1 - firmware/controllers/actuators/vvt.h | 2 +- firmware/controllers/algo/airmass/airmass.h | 2 +- firmware/controllers/algo/dynoview.cpp | 1 - firmware/controllers/algo/dynoview.h | 2 +- firmware/controllers/algo/engine.cpp | 11 ---- firmware/controllers/algo/engine.h | 2 +- firmware/controllers/algo/event_registry.h | 6 +-- .../controllers/algo/fuel/fuel_computer.h | 2 +- .../controllers/algo/fuel/injector_model.h | 2 +- firmware/controllers/algo/fuel_math.cpp | 5 -- firmware/controllers/algo/launch_control.cpp | 1 - firmware/controllers/algo/launch_control.h | 2 +- firmware/controllers/buttonshift.cpp | 1 - .../controllers/engine_cycle/aux_valves.cpp | 1 - .../engine_cycle/fuel_schedule.cpp | 1 - .../controllers/engine_cycle/knock_logic.h | 2 +- .../engine_cycle/main_trigger_callback.cpp | 2 - .../engine_cycle/map_averaging.cpp | 3 -- .../engine_cycle/rpm_calculator.cpp | 1 - .../controllers/engine_cycle/rpm_calculator.h | 2 +- .../controllers/engine_cycle/spark_logic.cpp | 2 - firmware/controllers/gear_controller.cpp | 1 - firmware/controllers/gear_controller.h | 2 +- firmware/controllers/limp_manager.h | 2 +- .../converters/turbocharger_speed_converter.h | 2 +- .../converters/vehicle_speed_converter.h | 2 +- firmware/controllers/simple_tcu.h | 2 +- firmware/controllers/system/efi_gpio.h | 4 +- firmware/controllers/system/timer/scheduler.h | 2 +- .../controllers/trigger/trigger_central.cpp | 9 ---- .../controllers/trigger/trigger_central.h | 3 +- .../controllers/trigger/trigger_decoder.h | 4 +- firmware/development/engine_sniffer.h | 2 +- firmware/hw_layer/sensors/hip9011_logic.h | 2 +- firmware/init/sensor/init_lambda.cpp | 3 +- firmware/init/sensor/init_map.cpp | 3 +- .../sensor/init_turbocharger_speed_sensor.cpp | 1 - .../init/sensor/init_vehicle_speed_sensor.cpp | 1 - firmware/util/math/pid.h | 2 +- unit_tests/engine_test_helper.cpp | 2 - .../injection_mode_transition.cpp | 2 +- .../test_dwell_corner_case_issue_796.cpp | 2 +- .../tests/ignition_injection/test_fuelCut.cpp | 2 +- .../ignition_injection/test_fuel_computer.cpp | 6 +-- .../ignition_injection/test_fuel_map.cpp | 4 +- .../ignition_injection/test_fuel_math.cpp | 18 +++---- .../test_fuel_wall_wetting.cpp | 4 +- .../test_ignition_scheduling.cpp | 4 +- .../test_injector_model.cpp | 30 ++++------- .../ignition_injection/test_multispark.cpp | 6 +-- .../test_one_cylinder_logic.cpp | 2 +- .../test_startOfCrankingPrimingPulse.cpp | 4 +- unit_tests/tests/lua/test_lua_hooks.cpp | 2 +- unit_tests/tests/lua/test_lua_with_engine.cpp | 2 +- unit_tests/tests/sensor/test_cj125.cpp | 4 +- .../tests/sensor/test_frequency_sensor.cpp | 2 +- unit_tests/tests/sensor/test_sensor_init.cpp | 18 +++---- .../test_turbocharger_speed_converter.cpp | 1 - .../sensor/test_vehicle_speed_converter.cpp | 1 - unit_tests/tests/test_accel_enrichment.cpp | 6 +-- unit_tests/tests/test_aux_valves.cpp | 2 +- unit_tests/tests/test_boost.cpp | 15 ++---- unit_tests/tests/test_change_engine_type.cpp | 2 +- unit_tests/tests/test_dynoview.cpp | 12 ++--- unit_tests/tests/test_engine_math.cpp | 4 +- unit_tests/tests/test_etb.cpp | 52 +++++++------------ unit_tests/tests/test_fan_control.cpp | 2 +- unit_tests/tests/test_gpio.cpp | 4 +- unit_tests/tests/test_gppwm.cpp | 3 +- unit_tests/tests/test_hardware_reinit.cpp | 2 +- unit_tests/tests/test_idle_controller.cpp | 48 ++++++----------- unit_tests/tests/test_knock.cpp | 6 +-- unit_tests/tests/test_launch.cpp | 17 +++--- unit_tests/tests/test_limp.cpp | 12 ++--- unit_tests/tests/test_logic_expression.cpp | 12 ++--- unit_tests/tests/test_sensors.cpp | 4 +- unit_tests/tests/test_start_stop.cpp | 2 +- unit_tests/tests/test_stft.cpp | 2 +- unit_tests/tests/test_tacho.cpp | 2 +- unit_tests/tests/test_tunerstudio.cpp | 4 +- unit_tests/tests/test_vvt.cpp | 6 +-- unit_tests/tests/trigger/test_2jz_vvt.cpp | 2 +- .../tests/trigger/test_cam_vvt_input.cpp | 10 ++-- .../trigger/test_fasterEngineSpinningUp.cpp | 4 +- .../trigger/test_injection_scheduling.cpp | 3 +- .../tests/trigger/test_miata_na_tdc.cpp | 2 +- .../tests/trigger/test_nissan_vq_vvt.cpp | 4 +- .../tests/trigger/test_override_gaps.cpp | 2 +- unit_tests/tests/trigger/test_quad_cam.cpp | 2 +- .../trigger/test_real_cranking_miata_NA.cpp | 2 +- .../trigger/test_real_cranking_miata_na6.cpp | 6 +-- .../test_real_cranking_nissan_vq40.cpp | 2 +- .../tests/trigger/test_real_nb2_cranking.cpp | 4 +- .../tests/trigger/test_real_volkswagen.cpp | 4 +- .../tests/trigger/test_rpm_multiplier.cpp | 2 +- .../tests/trigger/test_symmetrical_crank.cpp | 4 +- .../tests/trigger/test_trigger_decoder.cpp | 38 +++++++------- .../tests/trigger/test_trigger_multi_sync.cpp | 2 +- .../tests/trigger/test_trigger_noiseless.cpp | 2 +- unit_tests/tests/util/test_timer.cpp | 2 +- 108 files changed, 212 insertions(+), 333 deletions(-) diff --git a/firmware/controllers/actuators/boost_control.h b/firmware/controllers/actuators/boost_control.h index 9e7734b4db..69245bf966 100644 --- a/firmware/controllers/actuators/boost_control.h +++ b/firmware/controllers/actuators/boost_control.h @@ -12,7 +12,7 @@ struct IPwm; -class BoostController : public ClosedLoopController, public EnginePtr { +class BoostController : public ClosedLoopController { public: void init(IPwm* pmw, const ValueProvider3D* openLoopMap, const ValueProvider3D* closedLoopTargetMap, pid_s* pidParams); void update(); diff --git a/firmware/controllers/actuators/electronic_throttle.cpp b/firmware/controllers/actuators/electronic_throttle.cpp index be58232ffd..b8551a340b 100644 --- a/firmware/controllers/actuators/electronic_throttle.cpp +++ b/firmware/controllers/actuators/electronic_throttle.cpp @@ -956,7 +956,6 @@ void doInitElectronicThrottle() { auto pid = getEtbPidForFunction(func); anyEtbConfigured |= controller->init(func, motor, pid, &pedal2tpsMap, shouldInitThrottles); - engine->etbControllers[i]->inject(); } } diff --git a/firmware/controllers/actuators/electronic_throttle.h b/firmware/controllers/actuators/electronic_throttle.h index 5c424164d5..8e66bd19fd 100644 --- a/firmware/controllers/actuators/electronic_throttle.h +++ b/firmware/controllers/actuators/electronic_throttle.h @@ -43,7 +43,7 @@ struct pid_s; class ValueProvider3D; struct pid_state_s; -class IEtbController : public ClosedLoopController, public EnginePtr { +class IEtbController : public ClosedLoopController { public: // Initialize the throttle. // returns true if the throttle was initialized, false otherwise. diff --git a/firmware/controllers/actuators/gppwm/gppwm.cpp b/firmware/controllers/actuators/gppwm/gppwm.cpp index 5e1fced4d0..b70d73998a 100644 --- a/firmware/controllers/actuators/gppwm/gppwm.cpp +++ b/firmware/controllers/actuators/gppwm/gppwm.cpp @@ -42,7 +42,6 @@ void initGpPwm() { tables[i]->init(cfg.table, cfg.loadBins, cfg.rpmBins); // Finally configure the channel - channels[i].inject(); channels[i].init(usePwm, &outputs[i], &pins[i], tables[i], &cfg); } } diff --git a/firmware/controllers/actuators/gppwm/gppwm_channel.h b/firmware/controllers/actuators/gppwm/gppwm_channel.h index 44a46c5989..2dbf1ee25f 100644 --- a/firmware/controllers/actuators/gppwm/gppwm_channel.h +++ b/firmware/controllers/actuators/gppwm/gppwm_channel.h @@ -9,7 +9,7 @@ class OutputPin; struct IPwm; class ValueProvider3D; -class GppwmChannel : public EnginePtr { +class GppwmChannel { public: void init(bool usePwm, IPwm* pwm, OutputPin* outputPin, const ValueProvider3D* table, const gppwm_channel* config); float update(); diff --git a/firmware/controllers/actuators/idle_thread.cpp b/firmware/controllers/actuators/idle_thread.cpp index 94e410ff73..2237370b5e 100644 --- a/firmware/controllers/actuators/idle_thread.cpp +++ b/firmware/controllers/actuators/idle_thread.cpp @@ -566,9 +566,7 @@ void startIdleBench(void) { #endif /* EFI_UNIT_TEST */ void startIdleThread() { - idleControllerInstance.inject(); idleControllerInstance.init(&CONFIG(idleTimingPid)); - industrialWithOverrideIdlePid.inject(); ENGINE(idleController) = &idleControllerInstance; diff --git a/firmware/controllers/actuators/idle_thread.h b/firmware/controllers/actuators/idle_thread.h index 8d1542a42d..2f467862cb 100644 --- a/firmware/controllers/actuators/idle_thread.h +++ b/firmware/controllers/actuators/idle_thread.h @@ -31,7 +31,7 @@ struct IIdleController { virtual float getCrankingTaperFraction() const = 0; }; -class IdleController : public IIdleController, public EnginePtr { +class IdleController : public IIdleController { public: void init(pid_s* idlePidConfig); diff --git a/firmware/controllers/actuators/vvt.cpp b/firmware/controllers/actuators/vvt.cpp index 902c64bb3e..1efece6a29 100644 --- a/firmware/controllers/actuators/vvt.cpp +++ b/firmware/controllers/actuators/vvt.cpp @@ -140,7 +140,6 @@ void initAuxPid() { config->vvtTable2RpmBins); for (int i = 0;i < CAM_INPUTS_COUNT;i++) { - instances[i].inject(); int camIndex = i % CAMS_PER_BANK; int bankIndex = i / CAMS_PER_BANK; diff --git a/firmware/controllers/actuators/vvt.h b/firmware/controllers/actuators/vvt.h index c517cc099c..0e7b6a23b0 100644 --- a/firmware/controllers/actuators/vvt.h +++ b/firmware/controllers/actuators/vvt.h @@ -19,7 +19,7 @@ void initAuxPid(); void startVvtControlPins(); void stopVvtControlPins(); -class VvtController : public PeriodicTimerController, public ClosedLoopController, public EnginePtr { +class VvtController : public PeriodicTimerController, public ClosedLoopController { public: void init(int index, int bankIndex, int camIndex, const ValueProvider3D* targetMap); diff --git a/firmware/controllers/algo/airmass/airmass.h b/firmware/controllers/algo/airmass/airmass.h index 503f479e50..32ff89e8aa 100644 --- a/firmware/controllers/algo/airmass/airmass.h +++ b/firmware/controllers/algo/airmass/airmass.h @@ -11,7 +11,7 @@ struct AirmassModelBase { virtual AirmassResult getAirmass(int rpm) = 0; }; -class AirmassVeModelBase : public AirmassModelBase, public EnginePtr { +class AirmassVeModelBase : public AirmassModelBase { public: explicit AirmassVeModelBase(const ValueProvider3D& veTable); diff --git a/firmware/controllers/algo/dynoview.cpp b/firmware/controllers/algo/dynoview.cpp index ea498c515d..f0bfe626be 100644 --- a/firmware/controllers/algo/dynoview.cpp +++ b/firmware/controllers/algo/dynoview.cpp @@ -146,7 +146,6 @@ int getDynoviewPower() { void updateDynoView() { if (isBrainPinValid(CONFIG(vehicleSpeedSensorInputPin)) && (!CONFIG(enableCanVss))) { - dynoInstance.inject(); dynoInstance.update(ICU); } } diff --git a/firmware/controllers/algo/dynoview.h b/firmware/controllers/algo/dynoview.h index 00b43dc707..39e649f638 100644 --- a/firmware/controllers/algo/dynoview.h +++ b/firmware/controllers/algo/dynoview.h @@ -19,7 +19,7 @@ typedef enum{ CAN, }vssSrc; -class DynoView : public EnginePtr { +class DynoView { public: // Update the state of the launch control system void update(vssSrc src); diff --git a/firmware/controllers/algo/engine.cpp b/firmware/controllers/algo/engine.cpp index 9f54d69e4f..09db4914aa 100644 --- a/firmware/controllers/algo/engine.cpp +++ b/firmware/controllers/algo/engine.cpp @@ -130,7 +130,6 @@ static void initVvtShape(int camIndex, TriggerState &initState) { void Engine::initializeTriggerWaveform() { static TriggerState initState; - initState.inject(); // Re-read config in case it's changed primaryTriggerConfiguration.update(); @@ -463,23 +462,13 @@ void Engine::OnTriggerSyncronization(bool wasSynchronized) { #endif void Engine::injectEngineReferences() { - triggerCentral.inject(); - primaryTriggerConfiguration.inject(); - for (int camIndex = 0;camIndex < CAMS_PER_BANK;camIndex++) { - vvtTriggerConfiguration[camIndex].inject(); - } - limpManager.inject(); - knockController.inject(); - primaryTriggerConfiguration.update(); for (int camIndex = 0;camIndex < CAMS_PER_BANK;camIndex++) { vvtTriggerConfiguration[camIndex].update(); } - triggerCentral.init(); } void Engine::setConfig() { - inject(); efi::clear(config); injectEngineReferences(); diff --git a/firmware/controllers/algo/engine.h b/firmware/controllers/algo/engine.h index 463e4a1d6a..f34e61b4e6 100644 --- a/firmware/controllers/algo/engine.h +++ b/firmware/controllers/algo/engine.h @@ -87,7 +87,7 @@ protected: #define DEFAULT_MOCK_SPEED -1 -class Engine final : public TriggerStateListener, public EnginePtr { +class Engine final : public TriggerStateListener { public: Engine(); AcState acState; diff --git a/firmware/controllers/algo/event_registry.h b/firmware/controllers/algo/event_registry.h index 14a3470fc3..63acbf200c 100644 --- a/firmware/controllers/algo/event_registry.h +++ b/firmware/controllers/algo/event_registry.h @@ -19,7 +19,7 @@ class Engine; -class InjectionEvent : public EnginePtr { +class InjectionEvent { public: InjectionEvent(); @@ -92,7 +92,7 @@ public: #define MAX_OUTPUTS_FOR_IGNITION 2 -class IgnitionEvent : public EnginePtr { +class IgnitionEvent { public: IgnitionEvent(); IgnitionOutputPin *outputs[MAX_OUTPUTS_FOR_IGNITION]; @@ -139,7 +139,7 @@ public: bool isReady = false; }; -class AuxActor : public EnginePtr { +class AuxActor { public: int phaseIndex; int valveIndex; diff --git a/firmware/controllers/algo/fuel/fuel_computer.h b/firmware/controllers/algo/fuel/fuel_computer.h index 83f258da5c..8ca70fe18f 100644 --- a/firmware/controllers/algo/fuel/fuel_computer.h +++ b/firmware/controllers/algo/fuel/fuel_computer.h @@ -9,7 +9,7 @@ struct IFuelComputer { }; // This contains the math of the fuel model, but doesn't actually read any configuration -class FuelComputerBase : public IFuelComputer, public EnginePtr { +class FuelComputerBase : public IFuelComputer { public: mass_t getCycleFuel(mass_t airmass, int rpm, float load) const override; diff --git a/firmware/controllers/algo/fuel/injector_model.h b/firmware/controllers/algo/fuel/injector_model.h index fe5e50ce1d..b0979bf2d5 100644 --- a/firmware/controllers/algo/fuel/injector_model.h +++ b/firmware/controllers/algo/fuel/injector_model.h @@ -27,7 +27,7 @@ private: float m_massFlowRate = 0; }; -class InjectorModel : public InjectorModelBase, public EnginePtr { +class InjectorModel : public InjectorModelBase { public: void postState(float deadtime) const override; floatms_t getDeadtime() const override; diff --git a/firmware/controllers/algo/fuel_math.cpp b/firmware/controllers/algo/fuel_math.cpp index b37f959761..ebf71715ca 100644 --- a/firmware/controllers/algo/fuel_math.cpp +++ b/firmware/controllers/algo/fuel_math.cpp @@ -305,12 +305,7 @@ static InjectorModel injectorModel; * is to prepare the fuel map data structure for 3d interpolation */ void initFuelMap() { - sdAirmass.inject(); - mafAirmass.inject(); - alphaNAirmass.inject(); - fuelComputer.inject(); - injectorModel.inject(); ENGINE(fuelComputer) = &fuelComputer; ENGINE(injectorModel) = &injectorModel; diff --git a/firmware/controllers/algo/launch_control.cpp b/firmware/controllers/algo/launch_control.cpp index 12bcdbc1e0..c3c5cf7391 100644 --- a/firmware/controllers/algo/launch_control.cpp +++ b/firmware/controllers/algo/launch_control.cpp @@ -155,7 +155,6 @@ bool SoftSparkLimiter::shouldSkip() { } void initLaunchControl() { - engine->launchController.inject(); } #endif /* EFI_LAUNCH_CONTROL */ diff --git a/firmware/controllers/algo/launch_control.h b/firmware/controllers/algo/launch_control.h index b42b569cdc..b3c5818de0 100644 --- a/firmware/controllers/algo/launch_control.h +++ b/firmware/controllers/algo/launch_control.h @@ -12,7 +12,7 @@ void initLaunchControl(); -class LaunchControlBase : public EnginePtr { +class LaunchControlBase { public: // Update the state of the launch control system void update(); diff --git a/firmware/controllers/buttonshift.cpp b/firmware/controllers/buttonshift.cpp index c374471dd6..2a3b7f63a4 100644 --- a/firmware/controllers/buttonshift.cpp +++ b/firmware/controllers/buttonshift.cpp @@ -85,5 +85,4 @@ void ButtonShiftController::update() { void initButtonShift() { buttonShiftController.init(); engine->gearController = &buttonShiftController; - buttonShiftController.inject(); } diff --git a/firmware/controllers/engine_cycle/aux_valves.cpp b/firmware/controllers/engine_cycle/aux_valves.cpp index e2e4afc2a9..ab1fee66fb 100644 --- a/firmware/controllers/engine_cycle/aux_valves.cpp +++ b/firmware/controllers/engine_cycle/aux_valves.cpp @@ -71,7 +71,6 @@ void initAuxValves() { actor->valveIndex = valveIndex; actor->extra = phaseIndex * 360 + valveIndex * 180; - actor->inject(); scheduleOpen(actor); } } diff --git a/firmware/controllers/engine_cycle/fuel_schedule.cpp b/firmware/controllers/engine_cycle/fuel_schedule.cpp index 7ea2678f87..e5d0245386 100644 --- a/firmware/controllers/engine_cycle/fuel_schedule.cpp +++ b/firmware/controllers/engine_cycle/fuel_schedule.cpp @@ -96,7 +96,6 @@ bool FuelSchedule::addFuelEventsForCylinder(int i ) { bool isSimultanious = mode == IM_SIMULTANEOUS; InjectionEvent *ev = &elements[i]; - ev->inject(); ev->ownIndex = i; ev->outputs[0] = output; diff --git a/firmware/controllers/engine_cycle/knock_logic.h b/firmware/controllers/engine_cycle/knock_logic.h index a5a49b44fc..20562e8e64 100644 --- a/firmware/controllers/engine_cycle/knock_logic.h +++ b/firmware/controllers/engine_cycle/knock_logic.h @@ -11,7 +11,7 @@ int getCylinderKnockBank(uint8_t cylinderIndex); -class KnockController : public EnginePtr { +class KnockController { public: // onKnockSenseCompleted is the callback from the knock sense driver to report a sensed knock level bool onKnockSenseCompleted(uint8_t cylinderIndex, float dbv, efitick_t lastKnockTime); diff --git a/firmware/controllers/engine_cycle/main_trigger_callback.cpp b/firmware/controllers/engine_cycle/main_trigger_callback.cpp index 378f70335f..0c477be06d 100644 --- a/firmware/controllers/engine_cycle/main_trigger_callback.cpp +++ b/firmware/controllers/engine_cycle/main_trigger_callback.cpp @@ -99,7 +99,6 @@ void InjectorOutputPin::open(efitick_t nowNt) { #if EFI_TOOTH_LOGGER LogTriggerInjectorState(nowNt, true); #endif // EFI_TOOTH_LOGGER - this->inject(); setHigh(); } } @@ -441,7 +440,6 @@ static bool isPrimeInjectionPulseSkipped() { * See testStartOfCrankingPrimingPulse() */ void startPrimeInjectionPulse() { - engine->primeInjEvent.inject(); // First, we need a protection against 'fake' ignition switch on and off (i.e. no engine started), to avoid repeated prime pulses. // So we check and update the ignition switch counter in non-volatile backup-RAM diff --git a/firmware/controllers/engine_cycle/map_averaging.cpp b/firmware/controllers/engine_cycle/map_averaging.cpp index e2ccf84b6e..3ef2f3cdd5 100644 --- a/firmware/controllers/engine_cycle/map_averaging.cpp +++ b/firmware/controllers/engine_cycle/map_averaging.cpp @@ -275,9 +275,6 @@ void mapAveragingTriggerCallback( scheduling_s *starTimer = &startTimers[i][structIndex]; scheduling_s *endTimer = &endTimers[i][structIndex]; - mapAveragingPin.inject(); - starTimer->inject(); - endTimer->inject(); // at the moment we schedule based on time prediction based on current RPM and angle // we are loosing precision in case of changing RPM - the further away is the event the worse is precision diff --git a/firmware/controllers/engine_cycle/rpm_calculator.cpp b/firmware/controllers/engine_cycle/rpm_calculator.cpp index e5b1a416cd..97dd884c61 100644 --- a/firmware/controllers/engine_cycle/rpm_calculator.cpp +++ b/firmware/controllers/engine_cycle/rpm_calculator.cpp @@ -364,7 +364,6 @@ float getCrankshaftAngleNt(efitick_t timeNt) { } void initRpmCalculator() { - ENGINE(rpmCalculator).inject(); #if ! HW_CHECK_MODE if (hasFirmwareError()) { diff --git a/firmware/controllers/engine_cycle/rpm_calculator.h b/firmware/controllers/engine_cycle/rpm_calculator.h index f4c7414b6c..2d36ef8ec6 100644 --- a/firmware/controllers/engine_cycle/rpm_calculator.h +++ b/firmware/controllers/engine_cycle/rpm_calculator.h @@ -42,7 +42,7 @@ typedef enum { RUNNING, } spinning_state_e; -class RpmCalculator : public StoredValueSensor, public EnginePtr { +class RpmCalculator : public StoredValueSensor { public: #if !EFI_PROD_CODE int mockRpm; diff --git a/firmware/controllers/engine_cycle/spark_logic.cpp b/firmware/controllers/engine_cycle/spark_logic.cpp index 77be6cf1f2..8cace5c792 100644 --- a/firmware/controllers/engine_cycle/spark_logic.cpp +++ b/firmware/controllers/engine_cycle/spark_logic.cpp @@ -251,7 +251,6 @@ static void startDwellByTurningSparkPinHigh(IgnitionEvent *event, IgnitionOutput } } - output->inject(); output->setHigh(); } @@ -273,7 +272,6 @@ void turnSparkPinHigh(IgnitionEvent *event) { if (CONFIG(enableTrailingSparks)) { IgnitionOutputPin *output = &enginePins.trailingCoils[event->cylinderNumber]; - output->inject(); // Trailing sparks are enabled - schedule an event for the corresponding trailing coil scheduleByAngle( &event->trailingSparkCharge, nowNt, ENGINE(engineState.trailingSparkAngle), diff --git a/firmware/controllers/gear_controller.cpp b/firmware/controllers/gear_controller.cpp index 2085685897..52a45eda89 100644 --- a/firmware/controllers/gear_controller.cpp +++ b/firmware/controllers/gear_controller.cpp @@ -3,7 +3,6 @@ #include "gear_controller.h" void GearControllerBase::init() { - transmissionController.inject(); transmissionController.init(); } diff --git a/firmware/controllers/gear_controller.h b/firmware/controllers/gear_controller.h index ad0230085e..85830cfa1e 100644 --- a/firmware/controllers/gear_controller.h +++ b/firmware/controllers/gear_controller.h @@ -7,7 +7,7 @@ #include "globalaccess.h" #include "simple_tcu.h" -class GearControllerBase : public EnginePtr { +class GearControllerBase { public: virtual void update(); gear_e getDesiredGear() const; diff --git a/firmware/controllers/limp_manager.h b/firmware/controllers/limp_manager.h index 4fecbe67ab..626d9c6f4c 100644 --- a/firmware/controllers/limp_manager.h +++ b/firmware/controllers/limp_manager.h @@ -23,7 +23,7 @@ private: bool m_value = true; }; -class LimpManager : public EnginePtr { +class LimpManager { public: // This is called from periodicFastCallback to update internal state void updateState(int rpm, efitick_t nowNt); diff --git a/firmware/controllers/sensors/converters/turbocharger_speed_converter.h b/firmware/controllers/sensors/converters/turbocharger_speed_converter.h index 371d88fb4d..14460c9094 100644 --- a/firmware/controllers/sensors/converters/turbocharger_speed_converter.h +++ b/firmware/controllers/sensors/converters/turbocharger_speed_converter.h @@ -5,7 +5,7 @@ #include "pch.h" #include "sensor_converter_func.h" -class TurbochargerSpeedConverter : public SensorConverter, public EnginePtr { +class TurbochargerSpeedConverter : public SensorConverter { public: SensorResult convert(float frequency) const override { auto hz = frequency * engineConfiguration->turboSpeedSensorMultiplier; diff --git a/firmware/controllers/sensors/converters/vehicle_speed_converter.h b/firmware/controllers/sensors/converters/vehicle_speed_converter.h index 5c451835c4..1dc9e2c3c2 100644 --- a/firmware/controllers/sensors/converters/vehicle_speed_converter.h +++ b/firmware/controllers/sensors/converters/vehicle_speed_converter.h @@ -1,7 +1,7 @@ #include "pch.h" #include "sensor_converter_func.h" -class VehicleSpeedConverter : public SensorConverter, public EnginePtr { +class VehicleSpeedConverter : public SensorConverter { public: SensorResult convert(float frequency) const override { auto speed = frequency * engineConfiguration->vehicleSpeedCoef; diff --git a/firmware/controllers/simple_tcu.h b/firmware/controllers/simple_tcu.h index bfdb0bb3d4..ceba866afd 100644 --- a/firmware/controllers/simple_tcu.h +++ b/firmware/controllers/simple_tcu.h @@ -2,7 +2,7 @@ #include "tcu.h" -class SimpleTransmissionController: public TransmissionControllerBase, public EnginePtr { +class SimpleTransmissionController: public TransmissionControllerBase { public: void update(gear_e); void init(); diff --git a/firmware/controllers/system/efi_gpio.h b/firmware/controllers/system/efi_gpio.h index 56c0715c1b..ea3775bbad 100644 --- a/firmware/controllers/system/efi_gpio.h +++ b/firmware/controllers/system/efi_gpio.h @@ -89,7 +89,7 @@ private: /** * OutputPin which is reported on Engine Sniffer */ -class NamedOutputPin : public virtual OutputPin, public EnginePtr { +class NamedOutputPin : public virtual OutputPin { public: NamedOutputPin(); explicit NamedOutputPin(const char *name); @@ -155,7 +155,7 @@ public: RegisteredNamedOutputPin(const char *name, short pinOffset, short pinModeOffset); }; -class EnginePins : public EnginePtr { +class EnginePins { public: EnginePins(); void startPins(); diff --git a/firmware/controllers/system/timer/scheduler.h b/firmware/controllers/system/timer/scheduler.h index 01972ca711..352504056a 100644 --- a/firmware/controllers/system/timer/scheduler.h +++ b/firmware/controllers/system/timer/scheduler.h @@ -39,7 +39,7 @@ private: * This structure holds information about an event scheduled in the future: when to execute what callback with what parameters */ #pragma pack(push, 4) -struct scheduling_s : public EnginePtr { +struct scheduling_s { #if EFI_SIGNAL_EXECUTOR_SLEEP virtual_timer_t timer; #endif /* EFI_SIGNAL_EXECUTOR_SLEEP */ diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp index 95ae38b496..dffffd619f 100644 --- a/firmware/controllers/trigger/trigger_central.cpp +++ b/firmware/controllers/trigger/trigger_central.cpp @@ -51,15 +51,6 @@ TriggerCentral::TriggerCentral() : trigger_central_s(), noiseFilter.resetAccumSignalData(); } -void TriggerCentral::init() { - triggerState.inject(); - for (int bankIndex = 0; bankIndex < BANKS_COUNT; bankIndex++) { - for (int camIndex = 0; camIndex < CAMS_PER_BANK; camIndex++) { - vvtState[bankIndex][camIndex].inject(); - } - } -} - void TriggerNoiseFilter::resetAccumSignalData() { memset(lastSignalTimes, 0xff, sizeof(lastSignalTimes)); // = -1 memset(accumSignalPeriods, 0, sizeof(accumSignalPeriods)); diff --git a/firmware/controllers/trigger/trigger_central.h b/firmware/controllers/trigger/trigger_central.h index 6d0a51a895..9cfeca2e63 100644 --- a/firmware/controllers/trigger/trigger_central.h +++ b/firmware/controllers/trigger/trigger_central.h @@ -37,10 +37,9 @@ public: * Probably not: we have an instance of TriggerState which is used for trigger initialization, * also composition probably better than inheritance here */ -class TriggerCentral final : public trigger_central_s, public EnginePtr { +class TriggerCentral final : public trigger_central_s { public: TriggerCentral(); - void init(); void handleShaftSignal(trigger_event_e signal, efitick_t timestamp); int getHwEventCounter(int index) const; void resetCounters(); diff --git a/firmware/controllers/trigger/trigger_decoder.h b/firmware/controllers/trigger/trigger_decoder.h index f6a2f55f0b..f73457af54 100644 --- a/firmware/controllers/trigger/trigger_decoder.h +++ b/firmware/controllers/trigger/trigger_decoder.h @@ -24,7 +24,7 @@ struct TriggerStateListener { #endif // EFI_SHAFT_POSITION_INPUT }; -class TriggerConfiguration : public EnginePtr { +class TriggerConfiguration { public: explicit TriggerConfiguration(const char* printPrefix) : PrintPrefix(printPrefix) {} void update(); @@ -74,7 +74,7 @@ typedef struct { /** * @see TriggerWaveform for trigger wheel shape definition */ -class TriggerState : public trigger_state_s, public EnginePtr { +class TriggerState : public trigger_state_s { public: TriggerState(); /** diff --git a/firmware/development/engine_sniffer.h b/firmware/development/engine_sniffer.h index a18c70bc95..e5938980e4 100644 --- a/firmware/development/engine_sniffer.h +++ b/firmware/development/engine_sniffer.h @@ -16,7 +16,7 @@ /** * @brief rusEfi console sniffer data buffer */ -class WaveChart : public EnginePtr { +class WaveChart { public: WaveChart(); void init(); diff --git a/firmware/hw_layer/sensors/hip9011_logic.h b/firmware/hw_layer/sensors/hip9011_logic.h index c8f78e167d..1b5a8d426d 100644 --- a/firmware/hw_layer/sensors/hip9011_logic.h +++ b/firmware/hw_layer/sensors/hip9011_logic.h @@ -80,7 +80,7 @@ public: #define DEFINE_PARAM_SUFFIX(x) , x #endif -class HIP9011 : public EnginePtr { +class HIP9011 { public: explicit HIP9011(Hip9011HardwareInterface *hardware); int sendCommand(uint8_t cmd); diff --git a/firmware/init/sensor/init_lambda.cpp b/firmware/init/sensor/init_lambda.cpp index a69a34b859..57a1834176 100644 --- a/firmware/init/sensor/init_lambda.cpp +++ b/firmware/init/sensor/init_lambda.cpp @@ -4,7 +4,7 @@ #include "adc_subscription.h" #include "function_pointer_sensor.h" -struct GetAfrWrapper : public EnginePtr { +struct GetAfrWrapper { float getLambda() { return getAfr() / 14.7f; } @@ -24,7 +24,6 @@ static AemXSeriesWideband aem2(1, SensorType::Lambda2); #endif void initLambda() { - afrWrapper.inject(); #if EFI_CAN_SUPPORT if (CONFIG(enableAemXSeries)) { diff --git a/firmware/init/sensor/init_map.cpp b/firmware/init/sensor/init_map.cpp index 1ed2960ca3..473abfee10 100644 --- a/firmware/init/sensor/init_map.cpp +++ b/firmware/init/sensor/init_map.cpp @@ -7,7 +7,7 @@ #include "function_pointer_sensor.h" #include "identity_func.h" -struct GetBaroWrapper : public EnginePtr { +struct GetBaroWrapper { float getBaro() { return ::getBaroPressure(); } @@ -111,7 +111,6 @@ void configureMapFunction() { } void initMap() { - baroWrapper.inject(); auto mapChannel = engineConfiguration->map.sensor.hwChannel; diff --git a/firmware/init/sensor/init_turbocharger_speed_sensor.cpp b/firmware/init/sensor/init_turbocharger_speed_sensor.cpp index 81f7b1e593..0270cc5741 100644 --- a/firmware/init/sensor/init_turbocharger_speed_sensor.cpp +++ b/firmware/init/sensor/init_turbocharger_speed_sensor.cpp @@ -9,7 +9,6 @@ static TurbochargerSpeedConverter turbochargerSpeedConverter; void initTurbochargerSpeedSensor() { - turbochargerSpeedConverter.inject(); auto pin = CONFIG(turboSpeedSensorInputPin); diff --git a/firmware/init/sensor/init_vehicle_speed_sensor.cpp b/firmware/init/sensor/init_vehicle_speed_sensor.cpp index bd9472e493..2c2f29223d 100644 --- a/firmware/init/sensor/init_vehicle_speed_sensor.cpp +++ b/firmware/init/sensor/init_vehicle_speed_sensor.cpp @@ -8,7 +8,6 @@ static FrequencySensor vehicleSpeedSensor(SensorType::VehicleSpeed, MS2NT(500)); static VehicleSpeedConverter vehicleSpeedConverter; void initVehicleSpeedSensor() { - vehicleSpeedConverter.inject(); auto pin = CONFIG(vehicleSpeedSensorInputPin); diff --git a/firmware/util/math/pid.h b/firmware/util/math/pid.h index cd665362d0..7f210519f7 100644 --- a/firmware/util/math/pid.h +++ b/firmware/util/math/pid.h @@ -27,7 +27,7 @@ struct pid_s; /** * default basic implementation also known as PidParallelController */ -class Pid : public pid_state_s, public EnginePtr { +class Pid : public pid_state_s { public: Pid(); explicit Pid(pid_s *parameters); diff --git a/unit_tests/engine_test_helper.cpp b/unit_tests/engine_test_helper.cpp index acbfaa8d1a..d6d086683f 100644 --- a/unit_tests/engine_test_helper.cpp +++ b/unit_tests/engine_test_helper.cpp @@ -86,11 +86,9 @@ EngineTestHelper::EngineTestHelper(engine_type_e engineType, configuration_callb memset(&activeConfiguration, 0, sizeof(activeConfiguration)); - enginePins.inject(); enginePins.reset(); enginePins.unregisterPins(); - waveChart.inject(); waveChart.init(); setCurveValue(config->cltFuelCorrBins, config->cltFuelCorr, CLT_CURVE_SIZE, -40, 1.5); diff --git a/unit_tests/tests/ignition_injection/injection_mode_transition.cpp b/unit_tests/tests/ignition_injection/injection_mode_transition.cpp index 32b970b147..591dc14bcf 100644 --- a/unit_tests/tests/ignition_injection/injection_mode_transition.cpp +++ b/unit_tests/tests/ignition_injection/injection_mode_transition.cpp @@ -28,7 +28,7 @@ static void doRevolution(EngineTestHelper& eth, int periodMs) { // https://github.com/rusefi/rusefi/issues/1592 TEST(fuelControl, transitionIssue1592) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); ENGINE(tdcMarkEnabled) = false; setupSimpleTestEngineWithMafAndTT_ONE_trigger(ð, IM_SEQUENTIAL); diff --git a/unit_tests/tests/ignition_injection/test_dwell_corner_case_issue_796.cpp b/unit_tests/tests/ignition_injection/test_dwell_corner_case_issue_796.cpp index d91ba844ec..2940a177a7 100644 --- a/unit_tests/tests/ignition_injection/test_dwell_corner_case_issue_796.cpp +++ b/unit_tests/tests/ignition_injection/test_dwell_corner_case_issue_796.cpp @@ -9,7 +9,7 @@ TEST(scheduler, dwellIssue796) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); setupSimpleTestEngineWithMafAndTT_ONE_trigger(ð, IM_SEQUENTIAL); eth.fireTriggerEvents2(4 /* count */ , 600 /* ms */); diff --git a/unit_tests/tests/ignition_injection/test_fuelCut.cpp b/unit_tests/tests/ignition_injection/test_fuelCut.cpp index 92e2016553..6349cedd8e 100644 --- a/unit_tests/tests/ignition_injection/test_fuelCut.cpp +++ b/unit_tests/tests/ignition_injection/test_fuelCut.cpp @@ -13,7 +13,7 @@ using ::testing::_; TEST(fuelCut, coasting) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); EXPECT_CALL(eth.mockAirmass, getAirmass(_)) .WillRepeatedly(Return(AirmassResult{0.1008f, 50.0f})); diff --git a/unit_tests/tests/ignition_injection/test_fuel_computer.cpp b/unit_tests/tests/ignition_injection/test_fuel_computer.cpp index 0784422406..fd3d751ea7 100644 --- a/unit_tests/tests/ignition_injection/test_fuel_computer.cpp +++ b/unit_tests/tests/ignition_injection/test_fuel_computer.cpp @@ -14,10 +14,9 @@ public: }; TEST(FuelComputer, getCycleFuel) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); MockFuelComputer dut; - dut.inject(); EXPECT_CALL(dut, getTargetLambdaLoadAxis(FloatEq(0.8f))) .WillOnce(Return(0.8f)); @@ -41,11 +40,10 @@ TEST(FuelComputer, LambdaLookup) { } TEST(FuelComputer, FlexFuel) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); MockVp3d lambdaTable; FuelComputer dut(lambdaTable); - dut.inject(); // easier values for testing engineConfiguration->stoichRatioPrimary = 15; diff --git a/unit_tests/tests/ignition_injection/test_fuel_map.cpp b/unit_tests/tests/ignition_injection/test_fuel_map.cpp index 9b601bb867..6425092267 100644 --- a/unit_tests/tests/ignition_injection/test_fuel_map.cpp +++ b/unit_tests/tests/ignition_injection/test_fuel_map.cpp @@ -16,7 +16,7 @@ using ::testing::FloatNear; TEST(misc, testFuelMap) { printf("Setting up FORD_ASPIRE_1996\r\n"); - WITH_ENGINE_TEST_HELPER(FORD_ASPIRE_1996); + EngineTestHelper eth(FORD_ASPIRE_1996); for (int i = 0; i < VBAT_INJECTOR_CURVE_SIZE; i++) { CONFIG(injector.battLagCorrBins[i]) = i; @@ -133,7 +133,7 @@ static void configureFordAspireTriggerWaveform(TriggerWaveform * s) { TEST(misc, testAngleResolver) { printf("*************************************************** testAngleResolver\r\n"); - WITH_ENGINE_TEST_HELPER(FORD_ASPIRE_1996); + EngineTestHelper eth(FORD_ASPIRE_1996); engineConfiguration->globalTriggerAngleOffset = 175; diff --git a/unit_tests/tests/ignition_injection/test_fuel_math.cpp b/unit_tests/tests/ignition_injection/test_fuel_math.cpp index 602b5bce90..ec2480cce3 100644 --- a/unit_tests/tests/ignition_injection/test_fuel_math.cpp +++ b/unit_tests/tests/ignition_injection/test_fuel_math.cpp @@ -9,7 +9,7 @@ using ::testing::InSequence; using ::testing::_; TEST(FuelMath, getStandardAirCharge) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); // Miata 1839cc 4cyl CONFIG(specs.displacement) = 1.839f; @@ -36,7 +36,7 @@ TEST(FuelMath, getStandardAirCharge) { } TEST(AirmassModes, AlphaNNormal) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); // 4 cylinder 4 liter = easy math engineConfiguration->specs.displacement = 4.0f; engineConfiguration->specs.cylindersCount = 4; @@ -47,7 +47,6 @@ TEST(AirmassModes, AlphaNNormal) { .WillOnce(Return(35.0f)); AlphaNAirmass dut(veTable); - dut.inject(); Sensor::setMockValue(SensorType::Tps1, 0.71f); @@ -60,13 +59,12 @@ TEST(AirmassModes, AlphaNNormal) { } TEST(AirmassModes, AlphaNFailedTps) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); // Shouldn't get called StrictMock veTable; AlphaNAirmass dut(veTable); - dut.inject(); // explicitly reset the sensor Sensor::resetMockValue(SensorType::Tps1); @@ -78,7 +76,7 @@ TEST(AirmassModes, AlphaNFailedTps) { } TEST(AirmassModes, MafNormal) { - WITH_ENGINE_TEST_HELPER(FORD_ASPIRE_1996); + EngineTestHelper eth(FORD_ASPIRE_1996); engineConfiguration->fuelAlgorithm = LM_REAL_MAF; engineConfiguration->injector.flow = 200; @@ -88,7 +86,6 @@ TEST(AirmassModes, MafNormal) { .WillOnce(Return(75.0f)); MafAirmass dut(veTable); - dut.inject(); auto airmass = dut.getAirmassImpl(200, 6000); @@ -120,9 +117,8 @@ TEST(AirmassModes, VeOverride) { } }; - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); DummyAirmassModel dut(veTable); - dut.inject(); // Use default mode - will call with 10 dut.getAirmass(0); @@ -138,7 +134,7 @@ TEST(AirmassModes, VeOverride) { void setInjectionMode(int value); TEST(FuelMath, testDifferentInjectionModes) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); setupSimpleTestEngineWithMafAndTT_ONE_trigger(ð); EXPECT_CALL(eth.mockAirmass, getAirmass(_)) @@ -163,7 +159,7 @@ TEST(FuelMath, testDifferentInjectionModes) { } TEST(FuelMath, deadtime) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); setupSimpleTestEngineWithMafAndTT_ONE_trigger(ð); diff --git a/unit_tests/tests/ignition_injection/test_fuel_wall_wetting.cpp b/unit_tests/tests/ignition_injection/test_fuel_wall_wetting.cpp index 42623ea563..69e0a01779 100644 --- a/unit_tests/tests/ignition_injection/test_fuel_wall_wetting.cpp +++ b/unit_tests/tests/ignition_injection/test_fuel_wall_wetting.cpp @@ -10,7 +10,7 @@ #include "pch.h" TEST(fuel, testWallWettingEnrichmentMath) { - WITH_ENGINE_TEST_HELPER(FORD_ASPIRE_1996); + EngineTestHelper eth(FORD_ASPIRE_1996); engineConfiguration->wwaeTau = 1.0f; engineConfiguration->wwaeBeta = 0.40f; @@ -26,7 +26,7 @@ TEST(fuel, testWallWettingEnrichmentMath) { TEST(fuel, testWallWettingEnrichmentScheduling) { - WITH_ENGINE_TEST_HELPER(FORD_ASPIRE_1996); + EngineTestHelper eth(FORD_ASPIRE_1996); setOperationMode(engineConfiguration, FOUR_STROKE_CRANK_SENSOR); engineConfiguration->useOnlyRisingEdgeForTrigger = true; diff --git a/unit_tests/tests/ignition_injection/test_ignition_scheduling.cpp b/unit_tests/tests/ignition_injection/test_ignition_scheduling.cpp index fb80f42129..450acba117 100644 --- a/unit_tests/tests/ignition_injection/test_ignition_scheduling.cpp +++ b/unit_tests/tests/ignition_injection/test_ignition_scheduling.cpp @@ -11,7 +11,7 @@ using ::testing::_; TEST(ignition, twoCoils) { - WITH_ENGINE_TEST_HELPER(FRANKENSO_BMW_M73_F); + EngineTestHelper eth(FRANKENSO_BMW_M73_F); // first one to fire uses first coil ASSERT_EQ(ENGINE(ignitionPin[ID2INDEX(1)]), 0); @@ -38,7 +38,7 @@ TEST(ignition, twoCoils) { } TEST(ignition, trailingSpark) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); /** // TODO #3220: this feature makes this test sad, eventually remove this line (and the ability to disable it altogether) diff --git a/unit_tests/tests/ignition_injection/test_injector_model.cpp b/unit_tests/tests/ignition_injection/test_injector_model.cpp index 2607d931a3..4a05078824 100644 --- a/unit_tests/tests/ignition_injection/test_injector_model.cpp +++ b/unit_tests/tests/ignition_injection/test_injector_model.cpp @@ -59,9 +59,8 @@ TEST(InjectorModel, getInjectionDurationNonlinear) { } TEST(InjectorModel, nonlinearPolynomial) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); InjectorModel dut; - dut.inject(); CONFIG(applyNonlinearBelowPulse) = MS2US(10); @@ -80,7 +79,7 @@ TEST(InjectorModel, nonlinearPolynomial) { } TEST(InjectorModel, Deadtime) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); // Some test data in the injector correction table for (size_t i = 0; i < efi::size(engineConfiguration->injector.battLagCorr); i++) { @@ -89,7 +88,6 @@ TEST(InjectorModel, Deadtime) { } InjectorModel dut; - dut.inject(); Sensor::setMockValue(SensorType::BatteryVoltage, 3); EXPECT_EQ(dut.getDeadtime(), 6); @@ -121,8 +119,7 @@ TEST_P(FlowRateFixture, FlowRateRatio) { StrictMock dut; EXPECT_CALL(dut, getInjectorFlowRatio()).WillOnce(Return(flowRatio)); - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); - dut.inject(); + EngineTestHelper eth(TEST_ENGINE); engineConfiguration->injector.flow = 500; // 500 cc/min = 6g/s @@ -141,8 +138,7 @@ TEST_P(FlowRateFixture, PressureRatio) { StrictMock dut; EXPECT_CALL(dut, getAbsoluteRailPressure()).WillOnce(Return(400 * pressureRatio + fakeMap)); - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); - dut.inject(); + EngineTestHelper eth(TEST_ENGINE); // Use injector compensation engineConfiguration->injectorCompensationMode = ICM_SensedRailPressure; @@ -160,8 +156,7 @@ TEST_P(FlowRateFixture, PressureRatio) { TEST(InjectorModel, NegativePressureDelta) { StrictMock dut; - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); - dut.inject(); + EngineTestHelper eth(TEST_ENGINE); // Use injector compensation engineConfiguration->injectorCompensationMode = ICM_SensedRailPressure; @@ -180,8 +175,7 @@ TEST(InjectorModel, NegativePressureDelta) { TEST(InjectorModel, VariableInjectorFlowModeNone) { StrictMock dut; - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); - dut.inject(); + EngineTestHelper eth(TEST_ENGINE); engineConfiguration->injectorCompensationMode = ICM_None; @@ -192,8 +186,7 @@ TEST(InjectorModel, VariableInjectorFlowModeNone) { TEST(InjectorModel, RailPressureFixed) { InjectorModel dut; - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); - dut.inject(); + EngineTestHelper eth(TEST_ENGINE); // Reference pressure is 350kpa engineConfiguration->fuelReferencePressure = 350; @@ -206,8 +199,7 @@ TEST(InjectorModel, RailPressureFixed) { TEST(InjectorModel, RailPressureSensed) { InjectorModel dut; - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); - dut.inject(); + EngineTestHelper eth(TEST_ENGINE); // Reference pressure is 350kpa engineConfiguration->injectorCompensationMode = ICM_SensedRailPressure; @@ -224,8 +216,7 @@ TEST(InjectorModel, RailPressureSensed) { TEST(InjectorModel, FailedPressureSensor) { InjectorModel dut; - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); - dut.inject(); + EngineTestHelper eth(TEST_ENGINE); // Reference pressure is 350kpa engineConfiguration->injectorCompensationMode = ICM_SensedRailPressure; @@ -243,8 +234,7 @@ TEST(InjectorModel, FailedPressureSensor) { TEST(InjectorModel, MissingPressureSensor) { InjectorModel dut; - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); - dut.inject(); + EngineTestHelper eth(TEST_ENGINE); // Reference pressure is 350kpa engineConfiguration->injectorCompensationMode = ICM_SensedRailPressure; diff --git a/unit_tests/tests/ignition_injection/test_multispark.cpp b/unit_tests/tests/ignition_injection/test_multispark.cpp index e33f7eefdd..8e997952b4 100644 --- a/unit_tests/tests/ignition_injection/test_multispark.cpp +++ b/unit_tests/tests/ignition_injection/test_multispark.cpp @@ -9,7 +9,7 @@ #include "advance_map.h" TEST(Multispark, DefaultConfiguration) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); EXPECT_EQ(0, getMultiSparkCount(0 )); EXPECT_EQ(0, getMultiSparkCount(100 )); @@ -37,7 +37,7 @@ static void multisparkCfg() { } TEST(Multispark, EnabledNoMaxRpm) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); multisparkCfg(); @@ -62,7 +62,7 @@ TEST(Multispark, EnabledNoMaxRpm) { } TEST(Multispark, RpmLimit) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); multisparkCfg(); diff --git a/unit_tests/tests/ignition_injection/test_one_cylinder_logic.cpp b/unit_tests/tests/ignition_injection/test_one_cylinder_logic.cpp index 3d1d63a269..8abfa8035f 100644 --- a/unit_tests/tests/ignition_injection/test_one_cylinder_logic.cpp +++ b/unit_tests/tests/ignition_injection/test_one_cylinder_logic.cpp @@ -7,7 +7,7 @@ #include "spark_logic.h" TEST(issues, issueOneCylinderSpecialCase968) { - WITH_ENGINE_TEST_HELPER(GY6_139QMB); + EngineTestHelper eth(GY6_139QMB); ENGINE(tdcMarkEnabled) = false; // set injection_mode 1 engineConfiguration->injectionMode = IM_SEQUENTIAL; diff --git a/unit_tests/tests/ignition_injection/test_startOfCrankingPrimingPulse.cpp b/unit_tests/tests/ignition_injection/test_startOfCrankingPrimingPulse.cpp index 8bcf1d0bdf..8b6b371b73 100644 --- a/unit_tests/tests/ignition_injection/test_startOfCrankingPrimingPulse.cpp +++ b/unit_tests/tests/ignition_injection/test_startOfCrankingPrimingPulse.cpp @@ -8,7 +8,7 @@ #include "pch.h" TEST(engine, testPlainCrankingWithoutAdvancedFeatures) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); ENGINE(tdcMarkEnabled) = false; engineConfiguration->cranking.baseFuel = 12; @@ -33,7 +33,7 @@ TEST(engine, testPlainCrankingWithoutAdvancedFeatures) { TEST(engine, testStartOfCrankingPrimingPulse) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); engineConfiguration->startOfCrankingPrimingPulse = 4; diff --git a/unit_tests/tests/lua/test_lua_hooks.cpp b/unit_tests/tests/lua/test_lua_hooks.cpp index f8b202e303..ffc822bed6 100644 --- a/unit_tests/tests/lua/test_lua_hooks.cpp +++ b/unit_tests/tests/lua/test_lua_hooks.cpp @@ -45,7 +45,7 @@ end )"; TEST(LuaHooks, Table3d) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); setTable(config->scriptTable2, (uint8_t)33); EXPECT_EQ(testLuaReturnsNumber(tableTest), 33); diff --git a/unit_tests/tests/lua/test_lua_with_engine.cpp b/unit_tests/tests/lua/test_lua_with_engine.cpp index b5927886ec..a0f42f00af 100644 --- a/unit_tests/tests/lua/test_lua_with_engine.cpp +++ b/unit_tests/tests/lua/test_lua_with_engine.cpp @@ -19,7 +19,7 @@ end )"; TEST(LuaHooks, TestCurve) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); strcpy(engineConfiguration->scriptCurveName[3], "hello"); setLinearCurve(engineConfiguration->scriptCurve4, 500, 600, 1); diff --git a/unit_tests/tests/sensor/test_cj125.cpp b/unit_tests/tests/sensor/test_cj125.cpp index 9522e111a2..f56e4e04a9 100644 --- a/unit_tests/tests/sensor/test_cj125.cpp +++ b/unit_tests/tests/sensor/test_cj125.cpp @@ -22,7 +22,7 @@ TEST(testCJ125, testInitialState) { ASSERT_FALSE(cj.isWorkingState()); ASSERT_EQ(cj.heaterDuty, 0); - WITH_ENGINE_TEST_HELPER(FORD_ASPIRE_1996); + EngineTestHelper eth(FORD_ASPIRE_1996); cj.StartHeaterControl(); ASSERT_EQ(cj.heaterDuty, CJ125_HEATER_IDLE_RATE); @@ -49,7 +49,7 @@ TEST(testCJ125, testFailedIdentify) { TestSpi mock; cj.spi = &mock; - WITH_ENGINE_TEST_HELPER(FORD_ASPIRE_1996); + EngineTestHelper eth(FORD_ASPIRE_1996); cj.cjIdentify(); ASSERT_EQ(cj.errorCode, CJ125_ERROR_WRONG_IDENT); diff --git a/unit_tests/tests/sensor/test_frequency_sensor.cpp b/unit_tests/tests/sensor/test_frequency_sensor.cpp index aa9942fc88..aea2442f1a 100644 --- a/unit_tests/tests/sensor/test_frequency_sensor.cpp +++ b/unit_tests/tests/sensor/test_frequency_sensor.cpp @@ -51,7 +51,7 @@ public: */ TEST_F(FrequencySensorTest, testValidWithPwm) { ASSERT_TRUE(dut.Register()); - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); // Should be invalid - not set yet { diff --git a/unit_tests/tests/sensor/test_sensor_init.cpp b/unit_tests/tests/sensor/test_sensor_init.cpp index 79b2e245b9..281255ad64 100644 --- a/unit_tests/tests/sensor/test_sensor_init.cpp +++ b/unit_tests/tests/sensor/test_sensor_init.cpp @@ -24,7 +24,7 @@ static void postToFuncSensor(Sensor* s, float value) { } TEST(SensorInit, Tps) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); CONFIG(tpsMin) = 200; // 1 volt CONFIG(tpsMax) = 800; // 4 volts @@ -50,7 +50,7 @@ TEST(SensorInit, Tps) { } TEST(SensorInit, TpsValuesTooClose) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); // Should fail, 0.49 volts apart CONFIG(tpsMin) = 200; // 1.00 volt @@ -97,7 +97,7 @@ TEST(SensorInit, TpsValuesTooClose) { } TEST(SensorInit, Pedal) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); CONFIG(throttlePedalPositionAdcChannel) = EFI_ADC_0; CONFIG(throttlePedalUpVoltage) = 1; @@ -124,7 +124,7 @@ TEST(SensorInit, Pedal) { } TEST(SensorInit, DriverIntentNoPedal) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); // We have no pedal - so we should get the TPS CONFIG(throttlePedalPositionAdcChannel) = EFI_ADC_NONE; @@ -144,7 +144,7 @@ TEST(SensorInit, DriverIntentNoPedal) { TEST(SensorInit, DriverIntentWithPedal) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); // We have a pedal, so we should get it CONFIG(throttlePedalPositionAdcChannel) = EFI_ADC_0; @@ -163,7 +163,7 @@ TEST(SensorInit, DriverIntentWithPedal) { } TEST(SensorInit, OilPressure) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); CONFIG(oilPressure.hwChannel) = EFI_ADC_0; CONFIG(oilPressure.v1) = 1; @@ -188,7 +188,7 @@ TEST(SensorInit, OilPressure) { } TEST(SensorInit, Clt) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); // 2003 neon sensor CONFIG(clt.config) = {0, 30, 100, 32500, 7550, 700, 2700}; @@ -210,7 +210,7 @@ TEST(SensorInit, Clt) { } TEST(SensorInit, Lambda) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); initLambda(); @@ -219,7 +219,7 @@ TEST(SensorInit, Lambda) { } TEST(SensorInit, Map) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); initMap(); diff --git a/unit_tests/tests/sensor/test_turbocharger_speed_converter.cpp b/unit_tests/tests/sensor/test_turbocharger_speed_converter.cpp index 8693494684..4c2fdbe2ff 100644 --- a/unit_tests/tests/sensor/test_turbocharger_speed_converter.cpp +++ b/unit_tests/tests/sensor/test_turbocharger_speed_converter.cpp @@ -13,7 +13,6 @@ public: } void SetUp() override { - dut.inject(); } void SetCoef(float new_coef) { diff --git a/unit_tests/tests/sensor/test_vehicle_speed_converter.cpp b/unit_tests/tests/sensor/test_vehicle_speed_converter.cpp index cb0e350d12..39a874d17e 100644 --- a/unit_tests/tests/sensor/test_vehicle_speed_converter.cpp +++ b/unit_tests/tests/sensor/test_vehicle_speed_converter.cpp @@ -13,7 +13,6 @@ public: } void SetUp() override { - dut.inject(); } void SetCoef(float new_coef) { diff --git a/unit_tests/tests/test_accel_enrichment.cpp b/unit_tests/tests/test_accel_enrichment.cpp index 4cc15e3c11..d62cc0f84d 100644 --- a/unit_tests/tests/test_accel_enrichment.cpp +++ b/unit_tests/tests/test_accel_enrichment.cpp @@ -15,7 +15,7 @@ TEST(fuel, testTpsAccelEnrichmentMath) { printf("====================================================================================== testAccelEnrichment\r\n"); - WITH_ENGINE_TEST_HELPER(FORD_ASPIRE_1996); + EngineTestHelper eth(FORD_ASPIRE_1996); engine->rpmCalculator.setRpmValue(600); engine->periodicFastCallback(); @@ -40,7 +40,7 @@ TEST(fuel, testTpsAccelEnrichmentMath) { } TEST(fuel, testTpsAccelEnrichmentScheduling) { - WITH_ENGINE_TEST_HELPER(FORD_ASPIRE_1996); + EngineTestHelper eth(FORD_ASPIRE_1996); setOperationMode(engineConfiguration, FOUR_STROKE_CRANK_SENSOR); engineConfiguration->useOnlyRisingEdgeForTrigger = true; @@ -91,7 +91,7 @@ static void doFractionalTpsIteration(int period, int divisor, int numCycles, std TEST(fuel, testAccelEnrichmentFractionalTps) { printf("====================================================================================== testAccelEnrichmentFractionalTps\r\n"); - WITH_ENGINE_TEST_HELPER(FORD_ASPIRE_1996); + EngineTestHelper eth(FORD_ASPIRE_1996); // setup engineConfiguration->tpsAccelEnrichmentThreshold = 5; diff --git a/unit_tests/tests/test_aux_valves.cpp b/unit_tests/tests/test_aux_valves.cpp index 67234db7db..b01ca15e56 100644 --- a/unit_tests/tests/test_aux_valves.cpp +++ b/unit_tests/tests/test_aux_valves.cpp @@ -12,7 +12,7 @@ TEST(misc, testAuxValves) { Sensor::setMockValue(SensorType::DriverThrottleIntent, 0); - WITH_ENGINE_TEST_HELPER(NISSAN_PRIMERA); + EngineTestHelper eth(NISSAN_PRIMERA); engine->needTdcCallback = false; diff --git a/unit_tests/tests/test_boost.cpp b/unit_tests/tests/test_boost.cpp index 2424b5f4f9..33d4dd304a 100644 --- a/unit_tests/tests/test_boost.cpp +++ b/unit_tests/tests/test_boost.cpp @@ -12,11 +12,10 @@ TEST(BoostControl, Setpoint) { EXPECT_CALL(targetMap, getValue(_, _)) .WillRepeatedly([](float xRpm, float tps) { return tps * 2; }); - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); engineConfiguration->boostType = CLOSED_LOOP; BoostController bc; - bc.inject(); // Should return unexpected without a pedal map cfg'd EXPECT_EQ(bc.getSetpoint(), unexpected); @@ -33,10 +32,9 @@ TEST(BoostControl, Setpoint) { } TEST(BoostControl, ObservePlant) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); BoostController bc; - bc.inject(); Sensor::resetMockValue(SensorType::Map); // Check that invalid MAP returns unexpected @@ -55,10 +53,9 @@ TEST(BoostControl, OpenLoop) { EXPECT_CALL(openMap, getValue(_, _)) .WillRepeatedly([](float xRpm, float tps) { return tps * 2; }); - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); BoostController bc; - bc.inject(); // Without table set, should return unexpected EXPECT_EQ(bc.getOpenLoop(0), unexpected); @@ -71,10 +68,9 @@ TEST(BoostControl, OpenLoop) { } TEST(BoostControl, ClosedLoop) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); BoostController bc; - bc.inject(); pid_s pidCfg = { 1, 0, 0, // P controller, easier to test @@ -111,12 +107,11 @@ TEST(BoostControl, ClosedLoop) { } TEST(BoostControl, SetOutput) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); StrictMock pwm; StrictMock etb; BoostController bc; - bc.inject(); // ETB wastegate position & PWM should both be set EXPECT_CALL(etb, setWastegatePosition(25.0f)); diff --git a/unit_tests/tests/test_change_engine_type.cpp b/unit_tests/tests/test_change_engine_type.cpp index 84a210bca0..ef664c833b 100644 --- a/unit_tests/tests/test_change_engine_type.cpp +++ b/unit_tests/tests/test_change_engine_type.cpp @@ -13,7 +13,7 @@ TEST(misc, changeEngineType) { /** * this configuration has triggerInputDebugPins defined */ - WITH_ENGINE_TEST_HELPER (FORD_ASPIRE_1996); + EngineTestHelper eth (FORD_ASPIRE_1996); brain_pin_e brainPin = engineConfiguration->triggerInputDebugPins[0]; ASSERT_TRUE(brainPin != GPIO_UNASSIGNED); diff --git a/unit_tests/tests/test_dynoview.cpp b/unit_tests/tests/test_dynoview.cpp index 6ed410ca56..9737c7aab2 100644 --- a/unit_tests/tests/test_dynoview.cpp +++ b/unit_tests/tests/test_dynoview.cpp @@ -17,10 +17,9 @@ void printResults(DynoView *dut) { TEST(DynoView, VSS_T1) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); DynoView dut; - dut.inject(); // Test Speed threshold engineConfiguration->vehicleWeight = 900; @@ -37,10 +36,9 @@ TEST(DynoView, VSS_T1) { } TEST(DynoView, algo) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); DynoView dut; - dut.inject(); // Test Speed threshold engineConfiguration->vehicleWeight = 900; @@ -62,10 +60,9 @@ TEST(DynoView, algo) { } TEST(DynoView, VSS_fast) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); DynoView dut; - dut.inject(); // Test Speed threshold engineConfiguration->vehicleWeight = 900; //kg @@ -86,10 +83,9 @@ TEST(DynoView, VSS_fast) { TEST(DynoView, VSS_Torque) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); DynoView dut; - dut.inject(); // Test Speed threshold engineConfiguration->vehicleWeight = 900; //kg diff --git a/unit_tests/tests/test_engine_math.cpp b/unit_tests/tests/test_engine_math.cpp index 4006b9adf2..dc18df9ed9 100644 --- a/unit_tests/tests/test_engine_math.cpp +++ b/unit_tests/tests/test_engine_math.cpp @@ -22,7 +22,7 @@ TEST(misc, structSize) { TEST(misc, testIgnitionPlanning) { printf("*************************************************** testIgnitionPlanning\r\n"); - WITH_ENGINE_TEST_HELPER(FORD_ESCORT_GT); + EngineTestHelper eth(FORD_ESCORT_GT); eth.engine.periodicFastCallback(); assertEqualsM("testIgnitionPlanning_AFR", 13.5, eth.engine.engineState.targetAFR); @@ -33,7 +33,7 @@ TEST(misc, testIgnitionPlanning) { TEST(misc, testEngineMath) { printf("*************************************************** testEngineMath\r\n"); - WITH_ENGINE_TEST_HELPER(FORD_ESCORT_GT); + EngineTestHelper eth(FORD_ESCORT_GT); engineConfiguration->ambiguousOperationMode = FOUR_STROKE_CAM_SENSOR; diff --git a/unit_tests/tests/test_etb.cpp b/unit_tests/tests/test_etb.cpp index f03329aef2..e73b9e4657 100644 --- a/unit_tests/tests/test_etb.cpp +++ b/unit_tests/tests/test_etb.cpp @@ -20,7 +20,7 @@ using ::testing::StrictMock; TEST(etb, initializationNoPedal) { StrictMock mocks[ETB_COUNT]; - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); for (int i = 0; i < ETB_COUNT; i++) { engine->etbControllers[i] = &mocks[i]; @@ -36,7 +36,7 @@ TEST(etb, initializationNoPedal) { TEST(etb, initializationMissingThrottle) { StrictMock mocks[ETB_COUNT]; - WITH_ENGINE_TEST_HELPER_BOARD_CALLBACK(TEST_ENGINE, [](engine_configuration_s* engineConfiguration) { + EngineTestHelper eth(TEST_ENGINE, [](engine_configuration_s* engineConfiguration) { engineConfiguration->etbFunctions[0] = ETB_None; engineConfiguration->etbFunctions[1] = ETB_None; }); @@ -59,7 +59,7 @@ TEST(etb, initializationMissingThrottle) { TEST(etb, initializationSingleThrottle) { StrictMock mocks[ETB_COUNT]; - WITH_ENGINE_TEST_HELPER_BOARD_CALLBACK(TEST_ENGINE, [](engine_configuration_s* engineConfiguration) { + EngineTestHelper eth(TEST_ENGINE, [](engine_configuration_s* engineConfiguration) { engineConfiguration->etbFunctions[0] = ETB_Throttle1; engineConfiguration->etbFunctions[1] = ETB_None; }); @@ -84,7 +84,7 @@ TEST(etb, initializationSingleThrottle) { TEST(etb, initializationSingleThrottleInSecondSlot) { StrictMock mocks[ETB_COUNT]; - WITH_ENGINE_TEST_HELPER_BOARD_CALLBACK(TEST_ENGINE, [](engine_configuration_s* engineConfiguration) { + EngineTestHelper eth(TEST_ENGINE, [](engine_configuration_s* engineConfiguration) { engineConfiguration->etbFunctions[0] = ETB_None; engineConfiguration->etbFunctions[1] = ETB_Throttle1; }); @@ -109,7 +109,7 @@ TEST(etb, initializationSingleThrottleInSecondSlot) { TEST(etb, initializationDualThrottle) { StrictMock mocks[ETB_COUNT]; - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); for (int i = 0; i < ETB_COUNT; i++) { engine->etbControllers[i] = &mocks[i]; @@ -137,7 +137,7 @@ TEST(etb, initializationDualThrottle) { TEST(etb, initializationWastegate) { StrictMock mocks[ETB_COUNT]; - WITH_ENGINE_TEST_HELPER_BOARD_CALLBACK(TEST_ENGINE, [](engine_configuration_s* engineConfiguration) { + EngineTestHelper eth(TEST_ENGINE, [](engine_configuration_s* engineConfiguration) { engineConfiguration->etbFunctions[0] = ETB_Wastegate; engineConfiguration->etbFunctions[1] = ETB_None; }); @@ -217,7 +217,7 @@ TEST(etb, initializationNoThrottles) { // This tests the case where you don't want an ETB, and expect everything to go fine EtbController duts[2]; - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); for (int i = 0; i < ETB_COUNT; i++) { engine->etbControllers[i] = &duts[i]; @@ -240,7 +240,7 @@ TEST(etb, initializationNoThrottles) { TEST(etb, idlePlumbing) { StrictMock mocks[ETB_COUNT]; - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); engineConfiguration->useETBforIdleControl = true; Sensor::setMockValue(SensorType::AcceleratorPedal, 50.0f, true); @@ -255,13 +255,12 @@ TEST(etb, idlePlumbing) { } TEST(etb, testSetpointOnlyPedal) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); // Don't use ETB for idle, we aren't testing that yet - just pedal table for now engineConfiguration->useETBforIdleControl = false; EtbController etb; - etb.inject(); // Mock pedal map that's just passthru pedal -> target StrictMock pedalMap; @@ -325,7 +324,7 @@ TEST(etb, testSetpointOnlyPedal) { } TEST(etb, setpointIdle) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); // Use ETB for idle, but don't give it any range (yet) engineConfiguration->useETBforIdleControl = true; @@ -337,7 +336,6 @@ TEST(etb, setpointIdle) { Sensor::setMockValue(SensorType::AcceleratorPedal, 0.0f, true); EtbController etb; - etb.inject(); // Mock pedal map that's just passthru pedal -> target StrictMock pedalMap; @@ -383,7 +381,7 @@ TEST(etb, setpointIdle) { } TEST(etb, setpointRevLimit) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); // Configure 5000 limit start, with 750 rpm taper engineConfiguration->etbRevLimitStart = 5000; @@ -395,7 +393,6 @@ TEST(etb, setpointRevLimit) { Sensor::setMockValue(SensorType::AcceleratorPedal, 0.0f, true); EtbController etb; - etb.inject(); // Mock pedal map to just return 80% StrictMock pedalMap; @@ -517,7 +514,7 @@ TEST(etb, etbTpsSensor) { } TEST(etb, setOutputInvalid) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); // Redundant TPS & accelerator pedal required for init Sensor::setMockValue(SensorType::Tps1Primary, 0); @@ -527,7 +524,6 @@ TEST(etb, setOutputInvalid) { StrictMock motor; EtbController etb; - etb.inject(); etb.init(ETB_Throttle1, &motor, nullptr, nullptr, true); // Should be disabled in case of unexpected @@ -537,7 +533,7 @@ TEST(etb, setOutputInvalid) { } TEST(etb, setOutputValid) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); StrictMock motor; // Must have TPS & PPS initialized for ETB setup @@ -546,7 +542,6 @@ TEST(etb, setOutputValid) { Sensor::setMockValue(SensorType::AcceleratorPedal, 0.0f, true); EtbController etb; - etb.inject(); etb.init(ETB_Throttle1, &motor, nullptr, nullptr, true); // Should be enabled and value set @@ -558,7 +553,7 @@ TEST(etb, setOutputValid) { } TEST(etb, setOutputValid2) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); StrictMock motor; // Must have TPS & PPS initialized for ETB setup @@ -567,7 +562,6 @@ TEST(etb, setOutputValid2) { Sensor::setMockValue(SensorType::AcceleratorPedal, 0.0f, true); EtbController etb; - etb.inject(); etb.init(ETB_Throttle1, &motor, nullptr, nullptr, true); // Should be enabled and value set @@ -579,7 +573,7 @@ TEST(etb, setOutputValid2) { } TEST(etb, setOutputOutOfRangeHigh) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); StrictMock motor; // Must have TPS & PPS initialized for ETB setup @@ -588,7 +582,6 @@ TEST(etb, setOutputOutOfRangeHigh) { Sensor::setMockValue(SensorType::AcceleratorPedal, 0.0f, true); EtbController etb; - etb.inject(); etb.init(ETB_Throttle1, &motor, nullptr, nullptr, true); // Should be enabled and value set @@ -600,7 +593,7 @@ TEST(etb, setOutputOutOfRangeHigh) { } TEST(etb, setOutputOutOfRangeLow) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); StrictMock motor; // Must have TPS & PPS initialized for ETB setup @@ -609,7 +602,6 @@ TEST(etb, setOutputOutOfRangeLow) { Sensor::setMockValue(SensorType::AcceleratorPedal, 0.0f, true); EtbController etb; - etb.inject(); etb.init(ETB_Throttle1, &motor, nullptr, nullptr, true); // Should be enabled and value set @@ -621,7 +613,7 @@ TEST(etb, setOutputOutOfRangeLow) { } TEST(etb, setOutputPauseControl) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); StrictMock motor; // Must have TPS & PPS initialized for ETB setup @@ -630,7 +622,6 @@ TEST(etb, setOutputPauseControl) { Sensor::setMockValue(SensorType::AcceleratorPedal, 0.0f, true); EtbController etb; - etb.inject(); etb.init(ETB_Throttle1, &motor, nullptr, nullptr, true); // Pause control - should get no output @@ -643,7 +634,7 @@ TEST(etb, setOutputPauseControl) { } TEST(etb, setOutputLimpHome) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); StrictMock motor; // Must have TPS & PPS initialized for ETB setup @@ -652,7 +643,6 @@ TEST(etb, setOutputLimpHome) { Sensor::setMockValue(SensorType::AcceleratorPedal, 0.0f, true); EtbController etb; - etb.inject(); etb.init(ETB_Throttle1, &motor, nullptr, nullptr, true); // Should be disabled when in ETB limp mode @@ -694,7 +684,7 @@ TEST(etb, closedLoopPid) { } TEST(etb, openLoopThrottle) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); // Redundant TPS & accelerator pedal required for init Sensor::setMockValue(SensorType::Tps1Primary, 0); @@ -702,7 +692,6 @@ TEST(etb, openLoopThrottle) { Sensor::setMockValue(SensorType::AcceleratorPedal, 0, true); EtbController etb; - etb.inject(); etb.init(ETB_Throttle1, nullptr, nullptr, nullptr, true); // Map [0, 100] -> [-50, 50] @@ -717,7 +706,7 @@ TEST(etb, openLoopThrottle) { } TEST(etb, openLoopNonThrottle) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); // Redundant TPS & accelerator pedal required for init Sensor::setMockValue(SensorType::Tps1Primary, 0); @@ -725,7 +714,6 @@ TEST(etb, openLoopNonThrottle) { Sensor::setMockValue(SensorType::AcceleratorPedal, 0, true); EtbController etb; - etb.inject(); etb.init(ETB_Wastegate, nullptr, nullptr, nullptr, false); // Map [0, 100] -> [-50, 50] diff --git a/unit_tests/tests/test_fan_control.cpp b/unit_tests/tests/test_fan_control.cpp index 636c2dd0e3..c94b5f7c4b 100644 --- a/unit_tests/tests/test_fan_control.cpp +++ b/unit_tests/tests/test_fan_control.cpp @@ -3,7 +3,7 @@ #include "fan_control.h" TEST(FanControl, fan1) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); engineConfiguration->fanOnTemperature = 90; engineConfiguration->fanOffTemperature = 80; diff --git a/unit_tests/tests/test_gpio.cpp b/unit_tests/tests/test_gpio.cpp index 68bff01ef0..7ba52a6d9b 100644 --- a/unit_tests/tests/test_gpio.cpp +++ b/unit_tests/tests/test_gpio.cpp @@ -1,7 +1,7 @@ #include "pch.h" TEST(gpio, testPinInitNonInverted) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); OutputPin dut; @@ -17,7 +17,7 @@ TEST(gpio, testPinInitNonInverted) { } TEST(gpio, testPinInitInverted) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); OutputPin dut; diff --git a/unit_tests/tests/test_gppwm.cpp b/unit_tests/tests/test_gppwm.cpp index 5868a8d436..91486a199b 100644 --- a/unit_tests/tests/test_gppwm.cpp +++ b/unit_tests/tests/test_gppwm.cpp @@ -74,9 +74,8 @@ TEST(GpPwm, OutputOnOff) { } TEST(GpPwm, GetOutput) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); GppwmChannel ch; - ch.inject(); gppwm_channel cfg; cfg.loadAxis = GPPWM_Tps; diff --git a/unit_tests/tests/test_hardware_reinit.cpp b/unit_tests/tests/test_hardware_reinit.cpp index efba30aa32..b658029e2d 100644 --- a/unit_tests/tests/test_hardware_reinit.cpp +++ b/unit_tests/tests/test_hardware_reinit.cpp @@ -1,7 +1,7 @@ #include "pch.h" TEST(hardware, reinit) { - WITH_ENGINE_TEST_HELPER(FRANKENSO_MIATA_NA6_MAP); + EngineTestHelper eth(FRANKENSO_MIATA_NA6_MAP); ButtonDebounce::stopConfigurationList(); ButtonDebounce::startConfigurationList(); diff --git a/unit_tests/tests/test_idle_controller.cpp b/unit_tests/tests/test_idle_controller.cpp index ca1526dcfd..72e8adcea1 100644 --- a/unit_tests/tests/test_idle_controller.cpp +++ b/unit_tests/tests/test_idle_controller.cpp @@ -19,9 +19,8 @@ using ::testing::_; using ICP = IIdleController::Phase; TEST(idle_v2, timingPid) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); IdleController dut; - dut.inject(); engineConfiguration->useIdleTimingPidControl = true; @@ -55,9 +54,8 @@ TEST(idle_v2, timingPid) { } TEST(idle_v2, testTargetRpm) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); IdleController dut; - dut.inject(); for (size_t i = 0; i < efi::size(engineConfiguration->cltIdleRpmBins); i++) { CONFIG(cltIdleRpmBins)[i] = i * 10; @@ -69,9 +67,8 @@ TEST(idle_v2, testTargetRpm) { } TEST(idle_v2, testDeterminePhase) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); IdleController dut; - dut.inject(); // TPS threshold 5% for easy test CONFIG(idlePidDeactivationTpsThreshold) = 5; @@ -115,9 +112,8 @@ TEST(idle_v2, testDeterminePhase) { } TEST(idle_v2, crankingOpenLoop) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); IdleController dut; - dut.inject(); engineConfiguration->crankingIACposition = 50; @@ -141,9 +137,8 @@ TEST(idle_v2, crankingOpenLoop) { } TEST(idle_v2, runningOpenLoopBasic) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); IdleController dut; - dut.inject(); engineConfiguration->manIdlePosition = 50; @@ -157,9 +152,8 @@ TEST(idle_v2, runningOpenLoopBasic) { } TEST(idle_v2, runningFanAcBump) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); IdleController dut; - dut.inject(); engineConfiguration->manIdlePosition = 50; engineConfiguration->acIdleExtraOffset = 9; @@ -196,9 +190,8 @@ TEST(idle_v2, runningFanAcBump) { } TEST(idle_v2, runningOpenLoopTpsTaper) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); IdleController dut; - dut.inject(); // Zero out base tempco table setArrayValues(config->cltIdleCorr, 0.0f); @@ -224,9 +217,8 @@ struct MockOpenLoopIdler : public IdleController { }; TEST(idle_v2, testOpenLoopCranking) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); StrictMock dut; - dut.inject(); CONFIG(overrideCrankingIacSetting) = true; @@ -237,9 +229,8 @@ TEST(idle_v2, testOpenLoopCranking) { } TEST(idle_v2, openLoopRunningTaper) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); StrictMock dut; - dut.inject(); EXPECT_CALL(dut, getRunningOpenLoop(30, SensorResult(0))).WillRepeatedly(Return(25)); EXPECT_CALL(dut, getCrankingOpenLoop(30)).WillRepeatedly(Return(75)); @@ -262,9 +253,8 @@ TEST(idle_v2, openLoopRunningTaper) { } TEST(idle_v2, getCrankingTaperFraction) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); StrictMock dut; - dut.inject(); CONFIG(afterCrankingIACtaperDuration) = 500; @@ -291,9 +281,8 @@ TEST(idle_v2, getCrankingTaperFraction) { } TEST(idle_v2, openLoopCoastingTable) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); IdleController dut; - dut.inject(); // enable & configure feature CONFIG(useIacTableForCoasting) = true; @@ -309,9 +298,8 @@ TEST(idle_v2, openLoopCoastingTable) { extern int timeNowUs; TEST(idle_v2, closedLoopBasic) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); IdleController dut; - dut.inject(); // Not testing PID here, so we can set very simple PID gains CONFIG(idleRpmPid).pFactor = 0.5; // 0.5 output per 1 RPM error = 50% per 100 rpm @@ -337,9 +325,8 @@ TEST(idle_v2, closedLoopBasic) { } TEST(idle_v2, closedLoopDeadzone) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); IdleController dut; - dut.inject(); // Not testing PID here, so we can set very simple PID gains CONFIG(idleRpmPid).pFactor = 0.5; // 0.5 output per 1 RPM error = 50% per 100 rpm @@ -373,9 +360,8 @@ struct IntegrationIdleMock : public IdleController { }; TEST(idle_v2, IntegrationManual) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); StrictMock dut; - dut.inject(); SensorResult expectedTps = 1; float expectedClt = 37; @@ -406,9 +392,8 @@ TEST(idle_v2, IntegrationManual) { } TEST(idle_v2, IntegrationAutomatic) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); StrictMock dut; - dut.inject(); CONFIG(idleMode) = IM_AUTO; @@ -444,9 +429,8 @@ TEST(idle_v2, IntegrationAutomatic) { } TEST(idle_v2, IntegrationClamping) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); StrictMock dut; - dut.inject(); CONFIG(idleMode) = IM_AUTO; diff --git a/unit_tests/tests/test_knock.cpp b/unit_tests/tests/test_knock.cpp index 3e245c3d28..4eb5b74a0d 100644 --- a/unit_tests/tests/test_knock.cpp +++ b/unit_tests/tests/test_knock.cpp @@ -3,7 +3,7 @@ #include "knock_logic.h" TEST(Knock, Retards) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); // Knock threshold of 20dBv ENGINE(engineState).knockThreshold = 20; @@ -13,7 +13,6 @@ TEST(Knock, Retards) { CONFIG(knockRetardMaximum) = 8; KnockController dut; - dut.inject(); // No retard unless we knock ASSERT_FLOAT_EQ(dut.getKnockRetard(), 0); @@ -40,10 +39,9 @@ TEST(Knock, Retards) { } TEST(Knock, Reapply) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); KnockController dut; - dut.inject(); // Knock threshold of 20dBv ENGINE(engineState).knockThreshold = 20; diff --git a/unit_tests/tests/test_launch.cpp b/unit_tests/tests/test_launch.cpp index 8a1afff502..6bdc0e3466 100644 --- a/unit_tests/tests/test_launch.cpp +++ b/unit_tests/tests/test_launch.cpp @@ -3,10 +3,9 @@ #include "launch_control.h" TEST(LaunchControl, TpsCondition) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); LaunchControlBase dut; - dut.inject(); engineConfiguration->launchTpsTreshold = 10; @@ -25,10 +24,9 @@ TEST(LaunchControl, TpsCondition) { TEST(LaunchControl, VSSCondition) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); LaunchControlBase dut; - dut.inject(); // Test Speed threshold engineConfiguration->launchActivationMode = ALWAYS_ACTIVE_LAUNCH; @@ -43,10 +41,9 @@ TEST(LaunchControl, VSSCondition) { } TEST(LaunchControl, RPMCondition) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); LaunchControlBase dut; - dut.inject(); engineConfiguration->launchRpm = 3000; @@ -56,10 +53,9 @@ TEST(LaunchControl, RPMCondition) { } TEST(LaunchControl, SwitchInputCondition) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); LaunchControlBase dut; - dut.inject(); //activation based on VSS engineConfiguration->launchActivationMode = ALWAYS_ACTIVE_LAUNCH; @@ -99,10 +95,9 @@ TEST(LaunchControl, SwitchInputCondition) { } TEST(LaunchControl, CombinedCondition) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); LaunchControlBase dut; - dut.inject(); //check VSS normal usage engineConfiguration->launchActivationMode = ALWAYS_ACTIVE_LAUNCH; @@ -143,7 +138,7 @@ static void setDefaultLaunchParameters() { } TEST(LaunchControl, CompleteRun) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); initLaunchControl(); diff --git a/unit_tests/tests/test_limp.cpp b/unit_tests/tests/test_limp.cpp index 0a864eb41a..fe4c7b5469 100644 --- a/unit_tests/tests/test_limp.cpp +++ b/unit_tests/tests/test_limp.cpp @@ -21,12 +21,11 @@ TEST(limp, testFatalError) { } TEST(limp, revLimit) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); engineConfiguration->rpmHardLimit = 2500; LimpManager dut; - dut.inject(); // Under rev limit, inj/ign allowed dut.updateState(2000, 0); @@ -45,13 +44,12 @@ TEST(limp, revLimit) { } TEST(limp, boostCut) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); // Cut above 100kPa engineConfiguration->boostCutPressure = 100; LimpManager dut; - dut.inject(); // Below threshold, injection allowed Sensor::setMockValue(SensorType::Map, 80); @@ -78,11 +76,10 @@ TEST(limp, boostCut) { extern int timeNowUs; TEST(limp, oilPressureFailureCase) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); engineConfiguration->minOilPressureAfterStart = 200; LimpManager dut; - dut.inject(); // Low oil pressure! Sensor::setMockValue(SensorType::OilPressure, 50); @@ -112,11 +109,10 @@ TEST(limp, oilPressureFailureCase) { } TEST(limp, oilPressureSuccessCase) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); engineConfiguration->minOilPressureAfterStart = 200; LimpManager dut; - dut.inject(); // Low oil pressure! Sensor::setMockValue(SensorType::OilPressure, 50); diff --git a/unit_tests/tests/test_logic_expression.cpp b/unit_tests/tests/test_logic_expression.cpp index c2a4254732..511ace37a4 100644 --- a/unit_tests/tests/test_logic_expression.cpp +++ b/unit_tests/tests/test_logic_expression.cpp @@ -114,13 +114,13 @@ static void testExpression2(float selfValue, const char *line, float expected, E ASSERT_TRUE(element != NULL) << "Not NULL expected"; LECalculator c; - EXPAND_Engine; + ASSERT_NEAR(expected, c.evaluate("test", selfValue, element), EPS4D) << line; } static void testExpression2(float selfValue, const char *line, float expected, const std::unordered_map& sensorVals = {}) { - WITH_ENGINE_TEST_HELPER_SENS(FORD_INLINE_6_1995, sensorVals); + EngineTestHelper eth(FORD_INLINE_6_1995, sensorVals); testExpression2(selfValue, line, expected, engine); } @@ -129,7 +129,7 @@ static void testExpression(const char *line, float expectedValue, const std::uno } TEST(fsio, testHysteresisSelf) { - WITH_ENGINE_TEST_HELPER(FORD_INLINE_6_1995); + EngineTestHelper eth(FORD_INLINE_6_1995); LEElement thepool[TEST_POOL_SIZE]; LEElementPool pool(thepool, TEST_POOL_SIZE); @@ -234,7 +234,7 @@ TEST(fsio, testLogicExpressions) { testExpression("fan NOT coolant 90 > AND fan coolant 85 > AND OR", 1, sensorVals); { - WITH_ENGINE_TEST_HELPER_SENS(FORD_INLINE_6_1995, sensorVals); + EngineTestHelper eth(FORD_INLINE_6_1995, sensorVals); LEElement thepool[TEST_POOL_SIZE]; LEElementPool pool(thepool, TEST_POOL_SIZE); LEElement * element = pool.parseExpression("fan NOT coolant 90 > AND fan coolant 85 > AND OR"); @@ -248,7 +248,7 @@ TEST(fsio, testLogicExpressions) { } { - WITH_ENGINE_TEST_HELPER_SENS(FORD_INLINE_6_1995, sensorVals); + EngineTestHelper eth(FORD_INLINE_6_1995, sensorVals); engine->fsioState.mockRpm = 900; engine->fsioState.mockCrankingRpm = 200; testExpression2(0, "rpm", 900, engine); @@ -260,7 +260,7 @@ TEST(fsio, testLogicExpressions) { TEST(fsio, fuelPump) { // this will init fuel pump fsio logic - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); // Mock a fuel pump pin CONFIG(fuelPumpPin) = GPIOA_0; diff --git a/unit_tests/tests/test_sensors.cpp b/unit_tests/tests/test_sensors.cpp index 059a3a1cb7..1126135163 100644 --- a/unit_tests/tests/test_sensors.cpp +++ b/unit_tests/tests/test_sensors.cpp @@ -8,14 +8,14 @@ #include "pch.h" TEST(sensors, vrThreshold) { - WITH_ENGINE_TEST_HELPER(HELLEN_128_MERCEDES_4_CYL); + EngineTestHelper eth(HELLEN_128_MERCEDES_4_CYL); auto& cfg = CONFIG(vrThreshold)[0]; ASSERT_FLOAT_EQ(0.8 * PACK_PERCENT_BYTE_MULT, cfg.values[2]); } TEST(sensors, mapDecoding) { - WITH_ENGINE_TEST_HELPER(FORD_INLINE_6_1995); + EngineTestHelper eth(FORD_INLINE_6_1995); air_pressure_sensor_config_s s; s.type = MT_DENSO183; diff --git a/unit_tests/tests/test_start_stop.cpp b/unit_tests/tests/test_start_stop.cpp index 97754aa6a8..8e391a86ce 100644 --- a/unit_tests/tests/test_start_stop.cpp +++ b/unit_tests/tests/test_start_stop.cpp @@ -9,7 +9,7 @@ TEST(start, startStop) { std::unordered_map sensorVals = {{ SensorType::AcceleratorPedal, 0 }}; - WITH_ENGINE_TEST_HELPER_SENS(PROTEUS_BMW_M73, sensorVals); + EngineTestHelper eth(PROTEUS_BMW_M73, sensorVals); eth.moveTimeForwardAndInvokeEventsSec(1); // '0' time has special meaning for implementation so let's move forward // this is a pull-up, so 'true' on start-up diff --git a/unit_tests/tests/test_stft.cpp b/unit_tests/tests/test_stft.cpp index 22e9af8c39..03eefbfc55 100644 --- a/unit_tests/tests/test_stft.cpp +++ b/unit_tests/tests/test_stft.cpp @@ -77,7 +77,7 @@ TEST(ClosedLoopFuel, CellSelection) { } TEST(ClosedLoopFuel, afrLimits) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); engineConfiguration->stft.minAfr = 100; // 10.0 AFR engineConfiguration->stft.maxAfr = 180; // 18.0 AFR diff --git a/unit_tests/tests/test_tacho.cpp b/unit_tests/tests/test_tacho.cpp index 8e5ca904cf..4902d61467 100644 --- a/unit_tests/tests/test_tacho.cpp +++ b/unit_tests/tests/test_tacho.cpp @@ -5,7 +5,7 @@ extern float getTachDuty(void); TEST(tachometer, testPulsePerRev) { // This engine has a tach pin set - we need that - WITH_ENGINE_TEST_HELPER(FRANKENSO_MAZDA_MIATA_2003); + EngineTestHelper eth(FRANKENSO_MAZDA_MIATA_2003); // We don't actually care about ign/inj at all, just tach engineConfiguration->isInjectionEnabled = false; diff --git a/unit_tests/tests/test_tunerstudio.cpp b/unit_tests/tests/test_tunerstudio.cpp index 679339839a..84d10e0be1 100644 --- a/unit_tests/tests/test_tunerstudio.cpp +++ b/unit_tests/tests/test_tunerstudio.cpp @@ -68,7 +68,7 @@ TEST(binary, testWriteCrc) { } TEST(TunerstudioCommands, writeChunkEngineConfig) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); MockTsChannel channel; uint8_t* configBytes = reinterpret_cast(config); @@ -90,7 +90,7 @@ TEST(TunerstudioCommands, writeChunkEngineConfig) { } TEST(TunerstudioCommands, writeChunkOutsideEngineConfig) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); MockTsChannel channel; uint8_t* configBytes = reinterpret_cast(config); diff --git a/unit_tests/tests/test_vvt.cpp b/unit_tests/tests/test_vvt.cpp index 8a51988b3f..2eb55cc0a1 100644 --- a/unit_tests/tests/test_vvt.cpp +++ b/unit_tests/tests/test_vvt.cpp @@ -6,7 +6,7 @@ using ::testing::StrictMock; using ::testing::Return; TEST(Vvt, setpoint) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); // Set up a mock target map StrictMock targetMap; @@ -18,7 +18,6 @@ TEST(Vvt, setpoint) { engine->rpmCalculator.mockRpm = 4321; VvtController dut; - dut.inject(); dut.init(0, 0, 0, &targetMap); // Test dut @@ -26,12 +25,11 @@ TEST(Vvt, setpoint) { } TEST(Vvt, observePlant) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); engine->triggerCentral.vvtPosition[0][0] = 23; VvtController dut; - dut.inject(); dut.init(0, 0, 0, nullptr); EXPECT_EQ(23, dut.observePlant().value_or(0)); diff --git a/unit_tests/tests/trigger/test_2jz_vvt.cpp b/unit_tests/tests/trigger/test_2jz_vvt.cpp index 526e9e27f0..9a3d63f0b8 100644 --- a/unit_tests/tests/trigger/test_2jz_vvt.cpp +++ b/unit_tests/tests/trigger/test_2jz_vvt.cpp @@ -9,7 +9,7 @@ TEST(sensors, test2jz) { - WITH_ENGINE_TEST_HELPER(TOYOTA_2JZ_GTE_VVTi); + EngineTestHelper eth(TOYOTA_2JZ_GTE_VVTi); // this crank trigger would be easier to test, crank shape is less important for this test diff --git a/unit_tests/tests/trigger/test_cam_vvt_input.cpp b/unit_tests/tests/trigger/test_cam_vvt_input.cpp index 633f7993ff..80b37c08bd 100644 --- a/unit_tests/tests/trigger/test_cam_vvt_input.cpp +++ b/unit_tests/tests/trigger/test_cam_vvt_input.cpp @@ -13,7 +13,7 @@ extern WarningCodeState unitTestWarningCodeState; extern WaveChart waveChart; TEST(trigger, testNoStartUpWarningsNoSyncronizationTrigger) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); // one tooth does not need synchronization it just counts tooth eth.setTriggerType(TT_ONE); ASSERT_EQ( 0, GET_RPM()) << "testNoStartUpWarnings RPM"; @@ -24,7 +24,7 @@ TEST(trigger, testNoStartUpWarningsNoSyncronizationTrigger) { } TEST(trigger, testNoStartUpWarnings) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); // for this test we need a trigger with isSynchronizationNeeded=true engineConfiguration->trigger.customTotalToothCount = 3; engineConfiguration->trigger.customSkippedToothCount = 1; @@ -59,7 +59,7 @@ TEST(trigger, testNoStartUpWarnings) { } TEST(trigger, testNoisyInput) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); ASSERT_EQ( 0, GET_RPM()) << "testNoisyInput RPM"; @@ -81,7 +81,7 @@ TEST(trigger, testNoisyInput) { TEST(trigger, testCamInput) { // setting some weird engine - WITH_ENGINE_TEST_HELPER(FORD_ESCORT_GT); + EngineTestHelper eth(FORD_ESCORT_GT); // changing to 'ONE TOOTH' trigger on CRANK with CAM/VVT setOperationMode(engineConfiguration, FOUR_STROKE_CRANK_SENSOR); @@ -122,7 +122,7 @@ TEST(trigger, testCamInput) { } TEST(trigger, testNB2CamInput) { - WITH_ENGINE_TEST_HELPER(FRANKENSO_MAZDA_MIATA_2003); + EngineTestHelper eth(FRANKENSO_MAZDA_MIATA_2003); // this crank trigger would be easier to test, crank shape is less important for this test eth.setTriggerType(TT_ONE); diff --git a/unit_tests/tests/trigger/test_fasterEngineSpinningUp.cpp b/unit_tests/tests/trigger/test_fasterEngineSpinningUp.cpp index b370547bb4..c9fde05c4c 100644 --- a/unit_tests/tests/trigger/test_fasterEngineSpinningUp.cpp +++ b/unit_tests/tests/trigger/test_fasterEngineSpinningUp.cpp @@ -7,7 +7,7 @@ #include "pch.h" TEST(cranking, testFasterEngineSpinningUp) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); ENGINE(tdcMarkEnabled) = false; // turn on FasterEngineSpinUp mode engineConfiguration->isFasterEngineSpinUpEnabled = true; @@ -97,7 +97,7 @@ TEST(cranking, testFasterEngineSpinningUp) { } static void doTestFasterEngineSpinningUp60_2(int startUpDelayMs, int rpm1, int expectedRpm) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); // turn on FasterEngineSpinUp mode engineConfiguration->isFasterEngineSpinUpEnabled = true; diff --git a/unit_tests/tests/trigger/test_injection_scheduling.cpp b/unit_tests/tests/trigger/test_injection_scheduling.cpp index 213089ff61..362762d425 100644 --- a/unit_tests/tests/trigger/test_injection_scheduling.cpp +++ b/unit_tests/tests/trigger/test_injection_scheduling.cpp @@ -9,13 +9,12 @@ using ::testing::InSequence; TEST(injectionScheduling, NormalDutyCycle) { StrictMock mockExec; - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); engine->executor.setMockExecutor(&mockExec); efitick_t nowNt = 1000000; InjectionEvent event; - event.inject(); InjectorOutputPin pin; pin.injectorIndex = 0; event.outputs[0] = &pin; diff --git a/unit_tests/tests/trigger/test_miata_na_tdc.cpp b/unit_tests/tests/trigger/test_miata_na_tdc.cpp index e3c278d953..169afef3d9 100644 --- a/unit_tests/tests/trigger/test_miata_na_tdc.cpp +++ b/unit_tests/tests/trigger/test_miata_na_tdc.cpp @@ -4,7 +4,7 @@ #include "trigger_emulator_algo.h" TEST(miata, miata_na_tdc) { - WITH_ENGINE_TEST_HELPER(FRANKENSO_MIATA_NA6_MAP); + EngineTestHelper eth(FRANKENSO_MIATA_NA6_MAP); #define TEST_REVOLUTIONS 6 diff --git a/unit_tests/tests/trigger/test_nissan_vq_vvt.cpp b/unit_tests/tests/trigger/test_nissan_vq_vvt.cpp index ba873e4db9..cd57120b08 100644 --- a/unit_tests/tests/trigger/test_nissan_vq_vvt.cpp +++ b/unit_tests/tests/trigger/test_nissan_vq_vvt.cpp @@ -22,7 +22,7 @@ public: static void func(TriggerCallback *callback) { int formIndex = callback->toothIndex % callback->form->getSize(); Engine *engine = callback->engine; - EXPAND_Engine; + int value = callback->form->wave->getChannelState(0, formIndex); efitick_t nowNt = getTimeNowNt(); @@ -72,7 +72,7 @@ TEST(nissan, vq_vvt) { // hold a reference to the heap allocated scheduling events until the test is done std::vector> ptrs; - WITH_ENGINE_TEST_HELPER (HELLEN_121_NISSAN_6_CYL); + EngineTestHelper eth (HELLEN_121_NISSAN_6_CYL); engineConfiguration->isIgnitionEnabled = false; engineConfiguration->isInjectionEnabled = false; diff --git a/unit_tests/tests/trigger/test_override_gaps.cpp b/unit_tests/tests/trigger/test_override_gaps.cpp index a559736f81..135098bf3f 100644 --- a/unit_tests/tests/trigger/test_override_gaps.cpp +++ b/unit_tests/tests/trigger/test_override_gaps.cpp @@ -8,7 +8,7 @@ #include "pch.h" TEST(subaru, overrideGap) { - WITH_ENGINE_TEST_HELPER(FRANKENSO_MIATA_NA6_MAP); + EngineTestHelper eth(FRANKENSO_MIATA_NA6_MAP); CONFIG(overrideTriggerGaps) = true; CONFIG(gapTrackingLengthOverride) = 2; diff --git a/unit_tests/tests/trigger/test_quad_cam.cpp b/unit_tests/tests/trigger/test_quad_cam.cpp index 8dc0382a7c..0003965c55 100644 --- a/unit_tests/tests/trigger/test_quad_cam.cpp +++ b/unit_tests/tests/trigger/test_quad_cam.cpp @@ -7,7 +7,7 @@ TEST(trigger, testQuadCam) { // setting some weird engine - WITH_ENGINE_TEST_HELPER(FORD_ESCORT_GT); + EngineTestHelper eth(FORD_ESCORT_GT); setOperationMode(engineConfiguration, FOUR_STROKE_CRANK_SENSOR); diff --git a/unit_tests/tests/trigger/test_real_cranking_miata_NA.cpp b/unit_tests/tests/trigger/test_real_cranking_miata_NA.cpp index 8280a3d130..dd6281a3a7 100644 --- a/unit_tests/tests/trigger/test_real_cranking_miata_NA.cpp +++ b/unit_tests/tests/trigger/test_real_cranking_miata_NA.cpp @@ -15,7 +15,7 @@ TEST(cranking, realCrankingFromFile) { int indeces[2] = {1, 0}; // this logic data file has first trigger channel in second column and second trigger channel in first column reader.open("tests/trigger/resources/cranking_na_3.csv", indeces); - WITH_ENGINE_TEST_HELPER (FRANKENSO_MIATA_NA6_MAP); + EngineTestHelper eth (FRANKENSO_MIATA_NA6_MAP); ssize_t read; diff --git a/unit_tests/tests/trigger/test_real_cranking_miata_na6.cpp b/unit_tests/tests/trigger/test_real_cranking_miata_na6.cpp index 2effa63ada..bd3816a053 100644 --- a/unit_tests/tests/trigger/test_real_cranking_miata_na6.cpp +++ b/unit_tests/tests/trigger/test_real_cranking_miata_na6.cpp @@ -28,14 +28,14 @@ static void fireTriggerEvent(EngineTestHelper*eth, double timestampS, trigger_wh } Engine *engine = ð->engine; - EXPAND_Engine; + timeNowUs = 1'000'000 * timestampS; printf("MIATANA: posting time=%d event=%d\n", timeNowUs, event); hwHandleShaftSignal((int)channel, !isFall, getTimeNowNt()); } TEST(cranking, hardcodedRealCranking) { - WITH_ENGINE_TEST_HELPER(FRANKENSO_MIATA_NA6_VAF); + EngineTestHelper eth(FRANKENSO_MIATA_NA6_VAF); #define EVENT(timestamp, channel, value) { fireTriggerEvent(ð, timestamp, channel, value); } @@ -171,7 +171,7 @@ TEST(cranking, naCrankFromFile) { int indeces[2] = {1, 0}; reader.open("tests/trigger/resources/cranking_na_4.csv", indeces); - WITH_ENGINE_TEST_HELPER(FRANKENSO_MIATA_NA6_VAF); + EngineTestHelper eth(FRANKENSO_MIATA_NA6_VAF); while (reader.haveMore()) { reader.processLine(ð); diff --git a/unit_tests/tests/trigger/test_real_cranking_nissan_vq40.cpp b/unit_tests/tests/trigger/test_real_cranking_nissan_vq40.cpp index a13f876ce2..79dc629f2a 100644 --- a/unit_tests/tests/trigger/test_real_cranking_nissan_vq40.cpp +++ b/unit_tests/tests/trigger/test_real_cranking_nissan_vq40.cpp @@ -13,7 +13,7 @@ TEST(realCrankingVQ40, normalCranking) { int indeces[] = {0}; reader.open("tests/trigger/resources/nissan_vq40_cranking-1.csv", indeces); - WITH_ENGINE_TEST_HELPER (HELLEN_121_NISSAN_6_CYL); + EngineTestHelper eth (HELLEN_121_NISSAN_6_CYL); bool hasSeenFirstVvt = false; diff --git a/unit_tests/tests/trigger/test_real_nb2_cranking.cpp b/unit_tests/tests/trigger/test_real_nb2_cranking.cpp index be179ce24e..7802120a7f 100644 --- a/unit_tests/tests/trigger/test_real_nb2_cranking.cpp +++ b/unit_tests/tests/trigger/test_real_nb2_cranking.cpp @@ -13,7 +13,7 @@ TEST(realCrankingNB2, normalCranking) { int indeces[] = {0}; reader.open("tests/trigger/resources/nb2-cranking-good.csv", indeces); - WITH_ENGINE_TEST_HELPER (HELLEN_NB2); + EngineTestHelper eth (HELLEN_NB2); while (reader.haveMore()) { reader.processLine(ð); @@ -33,7 +33,7 @@ TEST(realCrankingNB2, crankingMissingInjector) { int indeces[] = {0}; reader.open("tests/trigger/resources/nb2-cranking-good-missing-injector-1.csv", indeces); - WITH_ENGINE_TEST_HELPER (HELLEN_NB2); + EngineTestHelper eth (HELLEN_NB2); while (reader.haveMore()) { reader.processLine(ð); diff --git a/unit_tests/tests/trigger/test_real_volkswagen.cpp b/unit_tests/tests/trigger/test_real_volkswagen.cpp index ef84670573..5facc1d2cd 100644 --- a/unit_tests/tests/trigger/test_real_volkswagen.cpp +++ b/unit_tests/tests/trigger/test_real_volkswagen.cpp @@ -14,7 +14,7 @@ TEST(crankingVW, vwRealCrankingFromFile) { int indeces[1] = {0}; reader.open("tests/trigger/resources/nick_1.csv", indeces); - WITH_ENGINE_TEST_HELPER (VW_ABA); + EngineTestHelper eth (VW_ABA); eth.setTriggerType(TT_60_2_VW); while (reader.haveMore()) { @@ -26,7 +26,7 @@ TEST(crankingVW, vwRealCrankingFromFile) { } TEST(crankingVW, crankingTwiceWithGap) { - WITH_ENGINE_TEST_HELPER (VW_ABA); + EngineTestHelper eth (VW_ABA); eth.setTriggerType(TT_60_2_VW); { diff --git a/unit_tests/tests/trigger/test_rpm_multiplier.cpp b/unit_tests/tests/trigger/test_rpm_multiplier.cpp index 503bcfa064..744b6c00f5 100644 --- a/unit_tests/tests/trigger/test_rpm_multiplier.cpp +++ b/unit_tests/tests/trigger/test_rpm_multiplier.cpp @@ -10,7 +10,7 @@ #include "pch.h" static void runRpmTest(operation_mode_e mode, int expected) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); engineConfiguration->ambiguousOperationMode = mode; eth.setTriggerType(TT_ONE); diff --git a/unit_tests/tests/trigger/test_symmetrical_crank.cpp b/unit_tests/tests/trigger/test_symmetrical_crank.cpp index e8a4ad40b5..b9b0322ebf 100644 --- a/unit_tests/tests/trigger/test_symmetrical_crank.cpp +++ b/unit_tests/tests/trigger/test_symmetrical_crank.cpp @@ -15,7 +15,7 @@ static void postFourEvents(EngineTestHelper *eth, float mult) { } TEST(engine, testAngleLogicInSymmetricalCrankIssue2980) { - WITH_ENGINE_TEST_HELPER(FRANKENSO_MAZDA_MIATA_2003); + EngineTestHelper eth(FRANKENSO_MAZDA_MIATA_2003); TriggerFormDetails *triggerForm = &ENGINE(triggerCentral.triggerFormDetails); @@ -44,7 +44,7 @@ TEST(engine, testAngleLogicInSymmetricalCrankIssue2980) { TEST(engine, testSymmetricalCrank) { - WITH_ENGINE_TEST_HELPER(FRANKENSO_MAZDA_MIATA_2003); + EngineTestHelper eth(FRANKENSO_MAZDA_MIATA_2003); // this test is not about isFasterEngineSpinUpEnabled so let's disable it to simplify things CONFIG(isFasterEngineSpinUpEnabled) = false; diff --git a/unit_tests/tests/trigger/test_trigger_decoder.cpp b/unit_tests/tests/trigger/test_trigger_decoder.cpp index 62111417b4..b7d59bd1ec 100644 --- a/unit_tests/tests/trigger/test_trigger_decoder.cpp +++ b/unit_tests/tests/trigger/test_trigger_decoder.cpp @@ -35,7 +35,7 @@ void sendOutConfirmation(char *value, int i) { } static int getTriggerZeroEventIndex(engine_type_e engineType) { - WITH_ENGINE_TEST_HELPER(engineType); + EngineTestHelper eth(engineType); initDataStructures(); @@ -47,7 +47,7 @@ static int getTriggerZeroEventIndex(engine_type_e engineType) { } TEST(misc, testSkipped2_0) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); // for this test we need a trigger with isSynchronizationNeeded=true engineConfiguration->trigger.customTotalToothCount = 2; engineConfiguration->trigger.customSkippedToothCount = 0; @@ -60,7 +60,7 @@ static void testDodgeNeonDecoder() { ASSERT_EQ( 8, getTriggerZeroEventIndex(DODGE_NEON_1995)) << "DODGE_NEON_1995: trigger zero index"; - WITH_ENGINE_TEST_HELPER(DODGE_NEON_1995); + EngineTestHelper eth(DODGE_NEON_1995); TriggerWaveform * shape = ð.engine.triggerCentral.triggerShape; ASSERT_EQ(8, shape->getTriggerWaveformSynchPointIndex()); @@ -110,7 +110,7 @@ static void assertTriggerPosition(event_trigger_position_s *position, int eventI } TEST(misc, testSomethingWeird) { - WITH_ENGINE_TEST_HELPER(FORD_INLINE_6_1995); + EngineTestHelper eth(FORD_INLINE_6_1995); TriggerState state_; TriggerState *sta = &state_; @@ -148,7 +148,7 @@ TEST(misc, testSomethingWeird) { TEST(misc, test1995FordInline6TriggerDecoder) { ASSERT_EQ( 0, getTriggerZeroEventIndex(FORD_INLINE_6_1995)) << "triggerIndex "; - WITH_ENGINE_TEST_HELPER(FORD_INLINE_6_1995); + EngineTestHelper eth(FORD_INLINE_6_1995); setWholeTimingTable(-13); Sensor::setMockValue(SensorType::Iat, 49.579071f); @@ -195,7 +195,7 @@ TEST(misc, test1995FordInline6TriggerDecoder) { } TEST(misc, testGetCoilDutyCycleIssue977) { - WITH_ENGINE_TEST_HELPER(FORD_ASPIRE_1996); + EngineTestHelper eth(FORD_ASPIRE_1996); int rpm = 2000; engine->rpmCalculator.setRpmValue(rpm); @@ -209,7 +209,7 @@ TEST(misc, testFordAspire) { ASSERT_EQ( 4, getTriggerZeroEventIndex(FORD_ASPIRE_1996)) << "getTriggerZeroEventIndex"; - WITH_ENGINE_TEST_HELPER(FORD_ASPIRE_1996); + EngineTestHelper eth(FORD_ASPIRE_1996); ASSERT_EQ( 4, TRIGGER_WAVEFORM(getTriggerWaveformSynchPointIndex())) << "getTriggerWaveformSynchPointIndex"; @@ -229,7 +229,7 @@ static void testTriggerDecoder2(const char *msg, engine_type_e type, int synchPo // Some configs use aux valves, which requires this sensor std::unordered_map sensorVals = {{SensorType::DriverThrottleIntent, 0}}; - WITH_ENGINE_TEST_HELPER_SENS(type, sensorVals); + EngineTestHelper eth(type, sensorVals); TriggerWaveform *t = &ENGINE(triggerCentral.triggerShape); @@ -247,7 +247,7 @@ static void testTriggerDecoder3(const char *msg, engine_type_e type, int synchPo } TEST(misc, testStartupFuelPumping) { - WITH_ENGINE_TEST_HELPER(FORD_INLINE_6_1995); + EngineTestHelper eth(FORD_INLINE_6_1995); StartupFuelPumping sf; @@ -293,7 +293,7 @@ static void assertREqualsM(const char *msg, void *expected, void *actual) { extern bool_t debugSignalExecutor; TEST(misc, testRpmCalculator) { - WITH_ENGINE_TEST_HELPER(FORD_INLINE_6_1995); + EngineTestHelper eth(FORD_INLINE_6_1995); ENGINE(tdcMarkEnabled) = false; @@ -503,7 +503,7 @@ TEST(misc, testTriggerDecoder) { testTriggerDecoder2("testMitsu", MITSU_4G93, 0, 0.3553, 0.3752); { - WITH_ENGINE_TEST_HELPER(MITSU_4G93); + EngineTestHelper eth(MITSU_4G93); eth.persistentConfig.engineConfiguration.useOnlyRisingEdgeForTrigger = false; @@ -519,7 +519,7 @@ TEST(misc, testTriggerDecoder) { testTriggerDecoder3("neon NGC4", DODGE_NEON_2003_CRANK, 6, 0.5000, 0.0, CHRYSLER_NGC4_GAP); { - WITH_ENGINE_TEST_HELPER(DODGE_NEON_2003_CRANK); + EngineTestHelper eth(DODGE_NEON_2003_CRANK); printf("!!!!!!!!!!!!!!!!!! Now trying with only rising edges !!!!!!!!!!!!!!!!!\r\n"); engineConfiguration->useOnlyRisingEdgeForTrigger = true; @@ -562,7 +562,7 @@ static void setTestBug299(EngineTestHelper *eth) { .WillRepeatedly(Return(AirmassResult{0.1008001f, 50.0f})); Engine *engine = ð->engine; - EXPAND_Engine + eth->assertRpm(0, "RPM=0"); @@ -682,7 +682,7 @@ static void setArray(float* p, size_t count, float value) { void doTestFuelSchedulerBug299smallAndMedium(int startUpDelayMs) { printf("*************************************************** testFuelSchedulerBug299 small to medium\r\n"); - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); ENGINE(tdcMarkEnabled) = false; eth.moveTimeForwardMs(startUpDelayMs); // nice to know that same test works the same with different anount of idle time on start setTestBug299(ð); @@ -928,7 +928,7 @@ TEST(big, testFuelSchedulerBug299smallAndMedium) { } TEST(big, testTwoWireBatch) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); setupSimpleTestEngineWithMafAndTT_ONE_trigger(ð); EXPECT_CALL(eth.mockAirmass, getAirmass(_)) .WillRepeatedly(Return(AirmassResult{0.1008f, 50.0f})); @@ -956,7 +956,7 @@ TEST(big, testTwoWireBatch) { TEST(big, testSequential) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); EXPECT_CALL(eth.mockAirmass, getAirmass(_)) .WillRepeatedly(Return(AirmassResult{0.1008f, 50.0f})); @@ -983,7 +983,7 @@ TEST(big, testSequential) { } TEST(big, testFuelSchedulerBug299smallAndLarge) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); ENGINE(tdcMarkEnabled) = false; setTestBug299(ð); ASSERT_EQ( 4, engine->executor.size()) << "Lqs#0"; @@ -1100,7 +1100,7 @@ TEST(big, testFuelSchedulerBug299smallAndLarge) { TEST(big, testSparkReverseOrderBug319) { printf("*************************************************** testSparkReverseOrderBug319 small to medium\r\n"); - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); ENGINE(tdcMarkEnabled) = false; engineConfiguration->useOnlyRisingEdgeForTrigger = false; @@ -1201,7 +1201,7 @@ TEST(big, testSparkReverseOrderBug319) { TEST(big, testMissedSpark299) { printf("*************************************************** testMissedSpark299\r\n"); - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); engineConfiguration->ignitionMode = IM_WASTED_SPARK; engineConfiguration->useOnlyRisingEdgeForTrigger = false; setupSimpleTestEngineWithMafAndTT_ONE_trigger(ð); diff --git a/unit_tests/tests/trigger/test_trigger_multi_sync.cpp b/unit_tests/tests/trigger/test_trigger_multi_sync.cpp index ee156dacb1..a5dfc368ef 100644 --- a/unit_tests/tests/trigger/test_trigger_multi_sync.cpp +++ b/unit_tests/tests/trigger/test_trigger_multi_sync.cpp @@ -13,6 +13,6 @@ TEST(trigger, miataNA) { naShape.useOnlyRisingEdgeForTriggerTemp = false; initializeMazdaMiataNaShape(&naShape); - WITH_ENGINE_TEST_HELPER(FRANKENSO_MIATA_NA6_MAP); + EngineTestHelper eth(FRANKENSO_MIATA_NA6_MAP); // todo: https://github.com/rusefi/rusefi/issues/679 } diff --git a/unit_tests/tests/trigger/test_trigger_noiseless.cpp b/unit_tests/tests/trigger/test_trigger_noiseless.cpp index 9ff27d454b..c4173dc0e2 100644 --- a/unit_tests/tests/trigger/test_trigger_noiseless.cpp +++ b/unit_tests/tests/trigger/test_trigger_noiseless.cpp @@ -162,7 +162,7 @@ static void testNoiselessDecoderProcedure(EngineTestHelper ð, int errorTolera TEST(big, testNoiselessDecoder) { printf("====================================================================================== testNoiselessDecoder\r\n"); - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); engineConfiguration->ignitionMode = IM_WASTED_SPARK; engineConfiguration->useOnlyRisingEdgeForTrigger = true; diff --git a/unit_tests/tests/util/test_timer.cpp b/unit_tests/tests/util/test_timer.cpp index 37e7660684..bfbf24c838 100644 --- a/unit_tests/tests/util/test_timer.cpp +++ b/unit_tests/tests/util/test_timer.cpp @@ -2,7 +2,7 @@ #include "timer.h" TEST(util, timer) { - WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + EngineTestHelper eth(TEST_ENGINE); Timer timer; ASSERT_TRUE(timer.hasElapsedSec(3)); timer.reset();