diff --git a/java_console/autotest/src/com/rusefi/FunctionalTestsSuite.java b/java_console/autotest/src/com/rusefi/FunctionalTestsSuite.java index 6dd7c133e0..56f780a9b7 100644 --- a/java_console/autotest/src/com/rusefi/FunctionalTestsSuite.java +++ b/java_console/autotest/src/com/rusefi/FunctionalTestsSuite.java @@ -1,7 +1,6 @@ package com.rusefi; -import com.rusefi.binaryprotocol.BinaryProtocol; import com.rusefi.config.generated.Fields; import com.rusefi.core.Sensor; import com.rusefi.core.SensorCentral; @@ -29,24 +28,14 @@ import static com.rusefi.waves.EngineReport.isCloseEnough; */ public class FunctionalTestsSuite { - private final LinkManager linkManager; private final EcuTestHelper ecu; public FunctionalTestsSuite(LinkManager linkManager, CommandQueue commandQueue) { - ecu = new EcuTestHelper(commandQueue); - this.linkManager = linkManager; + ecu = new EcuTestHelper(linkManager); } void mainTestBody() { - BinaryProtocol bp = linkManager.getCurrentStreamState(); - // let's make sure 'burn' command works since sometimes it does not - bp.burn(); - - ecu.sendCommand(getDisableCommand(Fields.CMD_TRIGGER_HW_INPUT)); - ecu.enableFunctionalMode(); testCustomEngine(); - testVW_60_2(); - testV12(); testMazdaMiata2003(); test2003DodgeNeon(); testFordAspire(); @@ -63,33 +52,12 @@ public class FunctionalTestsSuite { testFordFiesta(); } - private static final Function FAIL = errorCode -> { + public static final Function FAIL = errorCode -> { if (errorCode != null) throw new IllegalStateException("Failed " + errorCode); return null; }; - private void testVW_60_2() { - ecu.setEngineType(ET_VW_ABA); - // trying to disable engine sniffer to help https://github.com/rusefi/rusefi/issues/1849 - ecu.sendCommand("set " + CMD_ENGINESNIFFERRPMTHRESHOLD + " 100"); - ecu.changeRpm(900); - // first let's get to expected RPM - assertRpmDoesNotJump(16000, 5, 40, FAIL, ecu.commandQueue); - } - - private void testV12() { - ecu.setEngineType(ET_BMW_M73_F); - ecu.changeRpm(700); - // first let's get to expected RPM - assertRpmDoesNotJump(16000, 5, 40, FAIL, ecu.commandQueue); - testCaseBug1873(); - } - - private void testCaseBug1873() { - assertRpmDoesNotJump(60, 5, 110, FAIL, ecu.commandQueue); - } - public static void assertRpmDoesNotJump(int rpm, int settleTime, int testDuration, Function callback, CommandQueue commandQueue) { IoUtil.changeRpm(commandQueue, rpm); sleepSeconds(settleTime); diff --git a/java_console/autotest/src/com/rusefi/HighRevTest.java b/java_console/autotest/src/com/rusefi/HighRevTest.java new file mode 100644 index 0000000000..b6949f7ac5 --- /dev/null +++ b/java_console/autotest/src/com/rusefi/HighRevTest.java @@ -0,0 +1,35 @@ +package com.rusefi; + +import com.rusefi.functional_tests.EcuTestHelper; +import org.junit.Test; + +import static com.rusefi.FunctionalTestsSuite.FAIL; +import static com.rusefi.config.generated.Fields.*; + +public class HighRevTest { + @Test + public void testVW() { + EcuTestHelper ecu = EcuTestHelper.createInstance(); + + ecu.setEngineType(ET_VW_ABA); + // trying to disable engine sniffer to help https://github.com/rusefi/rusefi/issues/1849 + ecu.sendCommand("set " + CMD_ENGINESNIFFERRPMTHRESHOLD + " 100"); + ecu.changeRpm(900); + // first let's get to expected RPM + FunctionalTestsSuite.assertRpmDoesNotJump(16000, 5, 40, FAIL, ecu.commandQueue); + } + + @Test + public void testV12() { + EcuTestHelper ecu = EcuTestHelper.createInstance(); + ecu.setEngineType(ET_BMW_M73_F); + ecu.changeRpm(700); + // first let's get to expected RPM + FunctionalTestsSuite.assertRpmDoesNotJump(16000, 5, 40, FAIL, ecu.commandQueue); + testCaseBug1873(ecu); + } + + private void testCaseBug1873(EcuTestHelper ecu) { + FunctionalTestsSuite.assertRpmDoesNotJump(60, 5, 110, FAIL, ecu.commandQueue); + } +} diff --git a/java_console/autotest/src/com/rusefi/MiscTest.java b/java_console/autotest/src/com/rusefi/MiscTest.java new file mode 100644 index 0000000000..064410de14 --- /dev/null +++ b/java_console/autotest/src/com/rusefi/MiscTest.java @@ -0,0 +1,16 @@ +package com.rusefi; + +import com.rusefi.binaryprotocol.BinaryProtocol; +import com.rusefi.functional_tests.EcuTestHelper; +import org.junit.Test; + +public class MiscTest { + @Test + public void burn() { + EcuTestHelper ecu = EcuTestHelper.createInstance(); + + BinaryProtocol bp = ecu.getLinkManager().getCurrentStreamState(); + // let's make sure 'burn' command works since sometimes it does not + bp.burn(); + } +} diff --git a/java_console/autotest/src/com/rusefi/VssHardwareLoopTest.java b/java_console/autotest/src/com/rusefi/VssHardwareLoopTest.java index 86c742e997..9359fbd16a 100644 --- a/java_console/autotest/src/com/rusefi/VssHardwareLoopTest.java +++ b/java_console/autotest/src/com/rusefi/VssHardwareLoopTest.java @@ -19,11 +19,7 @@ import static com.rusefi.config.generated.Fields.*; public class VssHardwareLoopTest { @Test public void test() { - EcuTestHelper ecu = new EcuTestHelper(ControllerConnectorState.getLinkManager().getCommandQueue()); - - ecu.sendCommand(getEnableCommand(Fields.CMD_TRIGGER_HW_INPUT)); - ecu.enableFunctionalMode(); - + EcuTestHelper ecu = EcuTestHelper.createInstance(true); ecu.setEngineType(ET_FRANKENSO_MIATA_NA6); ecu.sendCommand(getDisableCommand(Fields.CMD_SELF_STIMULATION)); @@ -43,4 +39,5 @@ public class VssHardwareLoopTest { if (ControllerConnectorState.firmwareVersion == null) throw new IllegalStateException("firmwareVersion has not arrived"); } + } diff --git a/java_console/autotest/src/com/rusefi/functional_tests/EcuTestHelper.java b/java_console/autotest/src/com/rusefi/functional_tests/EcuTestHelper.java index 5a517c127f..b70cbe1319 100644 --- a/java_console/autotest/src/com/rusefi/functional_tests/EcuTestHelper.java +++ b/java_console/autotest/src/com/rusefi/functional_tests/EcuTestHelper.java @@ -1,11 +1,14 @@ package com.rusefi.functional_tests; import com.devexperts.logging.Logging; +import com.rusefi.ControllerConnectorState; import com.rusefi.IoUtil; import com.rusefi.Timeouts; import com.rusefi.config.generated.Fields; import com.rusefi.io.CommandQueue; +import com.rusefi.io.LinkManager; import com.rusefi.waves.EngineReport; +import org.jetbrains.annotations.NotNull; import static com.devexperts.logging.Logging.getLogging; import static com.rusefi.IoUtil.*; @@ -17,9 +20,17 @@ public class EcuTestHelper { public static final int COMPLEX_COMMAND_RETRY = 10000; public static int currentEngineType; public final CommandQueue commandQueue; + @NotNull + private final LinkManager linkManager; - public EcuTestHelper(CommandQueue commandQueue) { - this.commandQueue = commandQueue; + public EcuTestHelper(LinkManager linkManager) { + this.commandQueue = linkManager.getCommandQueue(); + this.linkManager = linkManager; + } + + @NotNull + public LinkManager getLinkManager() { + return linkManager; } public static void assertEquals(double expected, double actual) { @@ -35,6 +46,23 @@ public class EcuTestHelper { throw new IllegalStateException(msg + " Expected " + expected + " but got " + actual); } + @NotNull + public static EcuTestHelper createInstance() { + return createInstance(false); + } + + @NotNull + public static EcuTestHelper createInstance(boolean allowHardwareTriggerInput) { + EcuTestHelper ecu = new EcuTestHelper(ControllerConnectorState.getLinkManager()); + if (allowHardwareTriggerInput) { + ecu.sendCommand(getEnableCommand(Fields.CMD_TRIGGER_HW_INPUT)); + } else { + ecu.sendCommand(getDisableCommand(Fields.CMD_TRIGGER_HW_INPUT)); + } + ecu.enableFunctionalMode(); + return ecu; + } + public void sendCommand(String command) { sendCommand(command, CommandQueue.DEFAULT_TIMEOUT, Timeouts.CMD_TIMEOUT); }