trigger and VSS hw integrated testing #1668

This commit is contained in:
rusefi 2020-08-08 17:07:23 -04:00
parent e936c2742c
commit 8ca0427122
8 changed files with 62 additions and 41 deletions

View File

@ -2,8 +2,6 @@
<configuration default="false" name="RealHwTest" type="Application" factoryName="Application" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="com.rusefi.RealHwTest" />
<module name="autotest" />
<option name="PROGRAM_PARAMETERS" value="COM56" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="com.rusefi.ui.console.*" />

View File

@ -3,11 +3,9 @@ package com.rusefi;
import com.rusefi.binaryprotocol.BinaryProtocol;
import com.rusefi.config.generated.Fields;
import com.rusefi.core.MessagesCentral;
import com.rusefi.core.Sensor;
import com.rusefi.core.SensorCentral;
import com.rusefi.functional_tests.BaseTest;
import com.rusefi.functional_tests.TestHelper;
import com.rusefi.io.CommandQueue;
import com.rusefi.io.LinkManager;
import com.rusefi.waves.EngineChart;
@ -17,10 +15,8 @@ import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Function;
import static com.rusefi.IoUtil.*;
import static com.rusefi.IoUtil.getEnableCommand;
import static com.rusefi.TestingUtils.*;
import static com.rusefi.config.generated.Fields.ET_CITROEN_TU3JP;
import static com.rusefi.config.generated.Fields.MOCK_MAF_COMMAND;
import static com.rusefi.config.generated.Fields.*;
import static com.rusefi.waves.EngineReport.isCloseEnough;
/**
@ -32,8 +28,6 @@ import static com.rusefi.waves.EngineReport.isCloseEnough;
* 3/5/14
*/
public class AutoTest extends BaseTest {
public static final int COMPLEX_COMMAND_RETRY = 10000;
static int currentEngineType;
private final LinkManager linkManager;
@ -117,13 +111,13 @@ public class AutoTest extends BaseTest {
}
private void testMazdaMiata2003() {
setEngineType(47);
setEngineType(ET_FRANKENSO_MIATA_NB2);
sendCommand("get cranking_dwell"); // just test coverage
// sendCommand("get nosuchgettersdfsdfsdfsdf"); // just test coverage
}
private void testCamaro() {
setEngineType(35);
setEngineType(ET_CAMARO);
}
private void testSachs() {
@ -134,7 +128,7 @@ public class AutoTest extends BaseTest {
}
private void testBmwE34() {
setEngineType(25);
setEngineType(ET_BMW_E34);
sendCommand("chart 1");
String msg = "BMW";
EngineChart chart;
@ -173,16 +167,6 @@ public class AutoTest extends BaseTest {
// todo: add more content
}
private void setEngineType(int type) {
FileLog.MAIN.logLine("AUTOTEST setEngineType " + type);
// sendCommand(CMD_PINS);
currentEngineType = type;
sendCommand("set " + Fields.CMD_ENGINE_TYPE + " " + type, COMPLEX_COMMAND_RETRY, Timeouts.SET_ENGINE_TIMEOUT);
// TODO: document the reason for this sleep?!
sleepSeconds(1);
sendCommand(getEnableCommand("self_stimulation"));
}
private void testMazda626() {
setEngineType(28);
String msg = "mazda 626 default cranking";
@ -326,11 +310,11 @@ public class AutoTest extends BaseTest {
}
private void testRoverV8() {
setEngineType(10);
setEngineType(ET_ROVER_V8);
}
private void testFordFiesta() {
setEngineType(4);
setEngineType(ET_FORD_FIESTA);
EngineChart chart;
changeRpm(2000);
chart = nextChart();
@ -344,7 +328,7 @@ public class AutoTest extends BaseTest {
}
private void testFord6() {
setEngineType(7);
setEngineType(ET_FORD_INLINE_6);
EngineChart chart;
changeRpm(2000);
chart = nextChart();
@ -361,7 +345,7 @@ public class AutoTest extends BaseTest {
}
private void testFordAspire() {
setEngineType(3);
setEngineType(ET_FORD_ASPIRE);
sendCommand("disable cylinder_cleanup");
sendCommand("set mock_map_voltage 1");
sendCommand("set mock_vbatt_voltage 2.2");

View File

@ -1,6 +1,7 @@
package com.rusefi;
import com.rusefi.config.generated.Fields;
import com.rusefi.functional_tests.BaseTest;
import com.rusefi.io.CommandQueue;
import com.rusefi.io.LinkManager;
@ -28,13 +29,13 @@ public class EnduranceTest {
IoUtil.realHardwareConnect(linkManager, port);
for (int i = 0; i < count; i++) {
AutoTest.currentEngineType = 3;
sendCommand("set " + Fields.CMD_ENGINE_TYPE + " " + 3, AutoTest.COMPLEX_COMMAND_RETRY, Timeouts.SET_ENGINE_TIMEOUT, commandQueue);
BaseTest.currentEngineType = 3;
sendCommand("set " + Fields.CMD_ENGINE_TYPE + " " + 3, BaseTest.COMPLEX_COMMAND_RETRY, Timeouts.SET_ENGINE_TIMEOUT, commandQueue);
sleepSeconds(2);
sendCommand(getEnableCommand("self_stimulation"), commandQueue);
// IoUtil.changeRpm(1200);
AutoTest.currentEngineType = 28;
sendCommand("set " + Fields.CMD_ENGINE_TYPE + " " + 28, AutoTest.COMPLEX_COMMAND_RETRY, Timeouts.SET_ENGINE_TIMEOUT, commandQueue);
BaseTest.currentEngineType = 28;
sendCommand("set " + Fields.CMD_ENGINE_TYPE + " " + 28, BaseTest.COMPLEX_COMMAND_RETRY, Timeouts.SET_ENGINE_TIMEOUT, commandQueue);
sleepSeconds(2);
FileLog.MAIN.logLine("++++++++++++++++++++++++++++++++++++ " + i + " +++++++++++++++");
}

View File

@ -4,7 +4,9 @@ import com.rusefi.config.generated.Fields;
import com.rusefi.functional_tests.BaseTest;
import com.rusefi.io.CommandQueue;
import static com.rusefi.IoUtil.getDisableCommand;
import static com.rusefi.IoUtil.getEnableCommand;
import static com.rusefi.config.generated.Fields.*;
public class HardwareTests extends BaseTest {
@ -16,5 +18,10 @@ public class HardwareTests extends BaseTest {
sendCommand(getEnableCommand(Fields.CMD_TRIGGER_HW_INPUT));
enableFunctionalMode();
setEngineType(ET_FRANKENSO_MIATA_NA6);
sendCommand(getDisableCommand(Fields.CMD_SELF_STIMULATION));
changeRpm(1400);
}
}

View File

@ -1,18 +1,20 @@
package com.rusefi;
import com.devexperts.logging.Logging;
import com.rusefi.config.generated.Fields;
import com.rusefi.core.EngineState;
import com.rusefi.core.Sensor;
import com.rusefi.core.SensorCentral;
import com.rusefi.io.CommandQueue;
import com.rusefi.io.ConnectionStateListener;
import com.rusefi.io.InvocationConfirmationListener;
import com.rusefi.io.LinkManager;
import com.rusefi.io.tcp.TcpConnector;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import static com.devexperts.logging.Logging.getLogging;
import static com.rusefi.config.generated.Fields.CMD_RPM;
import static com.rusefi.waves.EngineReport.isCloseEnough;
/**
@ -20,6 +22,7 @@ import static com.rusefi.waves.EngineReport.isCloseEnough;
* 3/19/14.
*/
public class IoUtil {
private static final Logging log = getLogging(IoUtil.class);
/**
* Send a command and wait for the confirmation
@ -44,16 +47,16 @@ public class IoUtil {
public static void sendCommand(String command, int retryTimeoutMs, int timeoutMs, CommandQueue commandQueue) {
final CountDownLatch responseLatch = new CountDownLatch(1);
long time = System.currentTimeMillis();
FileLog.MAIN.logLine("Sending command [" + command + "]");
log.info("Sending command [" + command + "]");
final long begin = System.currentTimeMillis();
commandQueue.write(command, retryTimeoutMs, () -> {
responseLatch.countDown();
FileLog.MAIN.logLine("Got confirmation in " + (System.currentTimeMillis() - begin) + "ms");
log.info("Got confirmation in " + (System.currentTimeMillis() - begin) + "ms");
});
wait(responseLatch, timeoutMs);
if (responseLatch.getCount() > 0)
FileLog.MAIN.logLine("No confirmation in " + retryTimeoutMs);
FileLog.MAIN.logLine("Command [" + command + "] executed in " + (System.currentTimeMillis() - time));
log.info("No confirmation in " + retryTimeoutMs);
log.info("Command [" + command + "] executed in " + (System.currentTimeMillis() - time));
}
static void wait(CountDownLatch responseLatch, int milliseconds) {
@ -65,8 +68,8 @@ public class IoUtil {
}
public static void changeRpm(CommandQueue commandQueue, final int rpm) {
FileLog.MAIN.logLine("AUTOTEST rpm EN " + rpm);
sendCommand("rpm " + rpm, commandQueue);
log.info("AUTOTEST rpm EN " + rpm);
sendCommand(CMD_RPM + " " + rpm, commandQueue);
long time = System.currentTimeMillis();
final CountDownLatch rpmLatch = new CountDownLatch(1);
@ -88,11 +91,11 @@ public class IoUtil {
if (!isCloseEnough(rpm, actualRpm))
throw new IllegalStateException("rpm change did not happen: " + rpm + ", actual " + actualRpm);
// sendCommand(Fields.CMD_RESET_ENGINE_SNIFFER);
FileLog.MAIN.logLine("AUTOTEST RPM change [" + rpm + "] executed in " + (System.currentTimeMillis() - time));
log.info("AUTOTEST RPM change [" + rpm + "] executed in " + (System.currentTimeMillis() - time));
}
static void waitForFirstResponse() throws InterruptedException {
FileLog.MAIN.logLine("Let's give it some time to start...");
log.info("Let's give it some time to start...");
final CountDownLatch startup = new CountDownLatch(1);
SensorCentral.SensorListener listener = value -> startup.countDown();
long waitStart = System.currentTimeMillis();

View File

@ -12,6 +12,12 @@ import static com.devexperts.logging.Logging.getLogging;
import static com.rusefi.Timeouts.SECOND;
/**
* A few jumper wires are used to test some subsystems as realistically as possible:
* PD1 <=> PC6
* PD2 <=> PA5
*
*
*
* this test connects to real hardware via serial port
* Andrey Belomutskiy, (c) 2013-2020
* 2/22/2015

View File

@ -1,7 +1,9 @@
package com.rusefi;
import com.devexperts.logging.Logging;
import com.rusefi.config.generated.Fields;
import com.rusefi.core.EngineState;
import com.rusefi.functional_tests.BaseTest;
import com.rusefi.io.CommandQueue;
import com.rusefi.waves.EngineChart;
import com.rusefi.waves.EngineReport;
@ -13,6 +15,7 @@ import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicReference;
import static com.devexperts.logging.Logging.getLogging;
import static com.rusefi.waves.EngineReport.isCloseEnough;
/**
@ -20,6 +23,8 @@ import static com.rusefi.waves.EngineReport.isCloseEnough;
* 3/19/14.
*/
public class TestingUtils {
private static final Logging log = getLogging(TestingUtils.class);
static boolean isRealHardware;
static void assertTrue(String msg, boolean b) {
@ -48,7 +53,7 @@ public class TestingUtils {
}
private static void fail(String message) {
FileLog.MAIN.logLine("FAILURE: " + message);
log.info("FAILURE: " + message);
IllegalStateException exception = new IllegalStateException(message);
FileLog.MAIN.log(exception);
throw exception;
@ -140,7 +145,7 @@ public class TestingUtils {
int timeoutMs = 60 * Timeouts.SECOND;
long waitStartTime = System.currentTimeMillis();
IoUtil.wait(engineChartLatch, timeoutMs);
FileLog.MAIN.logLine("got next chart in " + (System.currentTimeMillis() - waitStartTime) + "ms for engine_type " + AutoTest.currentEngineType);
log.info("got next chart in " + (System.currentTimeMillis() - waitStartTime) + "ms for engine_type " + BaseTest.currentEngineType);
commandQueue.getLinkManager().getEngineState().replaceStringValueAction(EngineReport.ENGINE_CHART, (EngineState.ValueCallback<String>) EngineState.ValueCallback.VOID);
if (result.get() == null)
throw new IllegalStateException("Chart timeout: " + timeoutMs);

View File

@ -1,13 +1,20 @@
package com.rusefi.functional_tests;
import com.devexperts.logging.Logging;
import com.rusefi.IoUtil;
import com.rusefi.Timeouts;
import com.rusefi.config.generated.Fields;
import com.rusefi.io.CommandQueue;
import static com.devexperts.logging.Logging.getLogging;
import static com.rusefi.IoUtil.getEnableCommand;
import static com.rusefi.IoUtil.sleepSeconds;
public class BaseTest {
private static final Logging log = getLogging(BaseTest.class);
public static final int COMPLEX_COMMAND_RETRY = 10000;
public static int currentEngineType;
protected final CommandQueue commandQueue;
public BaseTest(CommandQueue commandQueue) {
@ -33,4 +40,14 @@ public class BaseTest {
protected void changeRpm(final int rpm) {
IoUtil.changeRpm(commandQueue, rpm);
}
protected void setEngineType(int type) {
log.info("AUTOTEST setEngineType " + type);
currentEngineType = type;
// sendCommand(CMD_PINS);
sendCommand("set " + Fields.CMD_ENGINE_TYPE + " " + type, COMPLEX_COMMAND_RETRY, Timeouts.SET_ENGINE_TIMEOUT);
// TODO: document the reason for this sleep?!
sleepSeconds(1);
sendCommand(getEnableCommand(Fields.CMD_SELF_STIMULATION));
}
}