From 435211b161fe27ed13d84df32f8ef06ea05a6140 Mon Sep 17 00:00:00 2001 From: rusefi Date: Sat, 21 Dec 2019 13:44:07 -0500 Subject: [PATCH] allowing functional test from console command line --- .../autotest/src/com/rusefi/RealHwTest.java | 38 ++++++++++++------- java_console/ui/src/com/rusefi/Launcher.java | 6 +++ 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/java_console/autotest/src/com/rusefi/RealHwTest.java b/java_console/autotest/src/com/rusefi/RealHwTest.java index e503d2da22..fd0d5e5870 100644 --- a/java_console/autotest/src/com/rusefi/RealHwTest.java +++ b/java_console/autotest/src/com/rusefi/RealHwTest.java @@ -1,6 +1,7 @@ package com.rusefi; import com.rusefi.io.LinkManager; +import org.jetbrains.annotations.NotNull; import static com.rusefi.AutoTest.mainTestBody; import static com.rusefi.Timeouts.SECOND; @@ -17,28 +18,37 @@ public class RealHwTest { System.out.println("Sleeping " + STARTUP_SLEEP + " seconds to give OS time to connect VCP driver"); Thread.sleep(STARTUP_SLEEP * SECOND); long start = System.currentTimeMillis(); - String port = startRealHardwareTest(args); - if (port == null) - return; - boolean failed = false; - try { - runRealHardwareTest(port); - } catch (Throwable e) { - e.printStackTrace(); - failed = true; - } - if (failed) + boolean isSuccess = runHardwareTest(args, start); + if (!isSuccess) System.exit(-1); FileLog.MAIN.logLine("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"); FileLog.MAIN.logLine("++++++++++++++++++++++++++++++++++++ Real Hardware Test Passed +++++++++++++++"); FileLog.MAIN.logLine("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"); - long time = (System.currentTimeMillis() - start) / 1000; - FileLog.MAIN.logLine("Done in " + time + "secs"); System.exit(0); // this is a safer method eliminating the issue of non-daemon threads } - static String startRealHardwareTest(String[] args) { + /** + * @return true if test is a SUCCESS, false if a FAILURE + */ + public static boolean runHardwareTest(String[] args, long start) { + String port = startRealHardwareTest(args); + if (port == null) { + return false; + } else { + try { + runRealHardwareTest(port); + } catch (Throwable e) { + e.printStackTrace(); + return false; + } + long time = (System.currentTimeMillis() - start) / 1000; + FileLog.MAIN.logLine("Done in " + time + "secs"); + } + return true; + } + + static String startRealHardwareTest(@NotNull String[] args) { /** * with real hardware we have noise on all analog inputs which gives us random sensor data, we cannot really * test exact numbers yet diff --git a/java_console/ui/src/com/rusefi/Launcher.java b/java_console/ui/src/com/rusefi/Launcher.java index 5c29dff36c..e3acacefbf 100644 --- a/java_console/ui/src/com/rusefi/Launcher.java +++ b/java_console/ui/src/com/rusefi/Launcher.java @@ -60,6 +60,7 @@ public class Launcher { private static final String TOOL_NAME_COMPILE_FSIO_FILE = "compile_fsio_file"; private static final String TOOL_NAME_REBOOT_ECU = "reboot_ecu"; private static final String TOOL_NAME_FIRING_ORDER = "firing_order"; + private static final String TOOL_NAME_FUNCTIONAL_TEST = "functional_test"; private static final String TOOL_NAME_PERF_ENUMS = "ptrace_enums"; // todo: rename to something more FSIO-specific? would need to update documentation somewhere private static final String TOOL_NAME_COMPILE = "compile"; @@ -322,6 +323,11 @@ public class Launcher { public static void main(final String[] args) throws Exception { String toolName = args.length == 0 ? null : args[0]; + if (TOOL_NAME_FUNCTIONAL_TEST.equals(toolName)) { + RealHwTest.main(new String[0]); + return; + } + if (TOOL_NAME_COMPILE_FSIO_FILE.equalsIgnoreCase(toolName)) { int returnCode = invokeCompileFileTool(args); System.exit(returnCode);