Skip to content

Commit

Permalink
blah
Browse files Browse the repository at this point in the history
  • Loading branch information
mck1117 committed Nov 26, 2023
1 parent d624e4d commit 4237e50
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 85 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,4 @@ public static void main(String[] args) {
CommandQueue.DEFAULT_TIMEOUT = 4950;
CmdJUnitRunner.runHardwareTestAndExit(tests);
}

static boolean runHardwareTest() {
return CmdJUnitRunner.runHardwareTest(tests);
}
}
75 changes: 0 additions & 75 deletions java_console/autotest/src/main/java/com/rusefi/TestingUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,81 +28,6 @@ public class TestingUtils {

public static boolean isRealHardware;

static void assertTrue(String msg, boolean b) {
if (!b)
fail("Not true: " + msg);
}

static void assertCloseEnough(String msg, double current, double ratio, double... expectations) {
for (double expected : expectations) {
if (isCloseEnough(fixAngle(expected), current, ratio))
return;
}
if (expectations.length == 1)
fail(msg + ": Got " + current + " while expecting " + Arrays.toString(expectations) + " ratio=" + Math.abs(1 - expectations[0] / current) + printRange(current, ratio));
fail(msg + ": Got " + current + " while expecting " + Arrays.toString(expectations) + printRange(current, ratio));
}

private static String printRange(double current, double ratio) {
return " expected range from " + current / (1 + ratio) + " to " + current / (1 - ratio) + " with ratio " + ratio;
}

private static double fixAngle(double angle) {
while (angle >= 720)
angle -= 720;
return angle;
}

static void assertTrue(boolean b) {
if (!b)
fail("Not true");
}

static void assertWave(EngineChart chart, String key, double width, double... expectedAngles) {
assertWave("", chart, key, width, expectedAngles);
}

static void assertWave(String msg, EngineChart chart, String key, double width, double... expectedAngles) {
assertWave(true, msg, chart, key, width, EngineReport.RATIO, EngineReport.RATIO, expectedAngles);
}

static void assertWaveFall(EngineChart chart, String key, double width, double... expectedAngles) {
assertWaveFall("", chart, key, width, expectedAngles);
}

static void assertWaveFall(String msg, EngineChart chart, String key, double width, double... expectedAngles) {
assertWave(false, msg, chart, key, width, EngineReport.RATIO, EngineReport.RATIO, expectedAngles);
}

static void assertWave(boolean rise, String msg, EngineChart chart, String key, double expectedWidth, double angleRatio, double widthRatio, double... expectedAngles) {
if (isRealHardware)
return;
RevolutionLog revolutionLog = chart.getRevolutionsLog();
if (revolutionLog.getSize() < 2)
throw new IllegalStateException(msg + " Not many revolutions in " + chart);

StringBuilder events = chart.get(key);
assertTrue(msg + " Events not null for " + key, events != null);
List<EngineReport.UpDown> wr = EngineReport.parse(events.toString());
assertTrue(msg + " waves for " + key, !wr.isEmpty());
for (EngineReport.UpDown ud : wr) {
int eventTime = rise ? ud.upTime : ud.downTime;
double angleByTime = revolutionLog.getCrankAngleByTime(eventTime);
assertCloseEnough(msg + " angle for " + key + "@" + eventTime, fixAngle(angleByTime), angleRatio, expectedAngles);

double actualWidth = ud.getDutyCycle(revolutionLog);
if (!isCloseEnough(fixAngle(actualWidth), expectedWidth, widthRatio)) {
System.out.println("f " + revolutionLog.getCrankAngleByTime(ud.downTime));
System.out.println("t " + revolutionLog.getCrankAngleByTime(ud.upTime));
}
assertCloseEnough(msg + " width for " + key, actualWidth, widthRatio, expectedWidth);
}
}

public static void assertNull(String msg, Object value) {
assertTrue(msg, value == null);
}

public static EngineChart nextChart(CommandQueue commandQueue) {
return EngineChartParser.unpackToMap(getNextWaveChart(commandQueue));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import java.util.Arrays;

import static com.rusefi.IoUtil.getEnableCommand;
import static com.rusefi.TestingUtils.assertNull;
import static org.junit.Assert.*;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.rusefi.config.generated.Fields;
import com.rusefi.core.MessagesCentral;

import static com.rusefi.TestingUtils.assertNull;
import static org.junit.Assert.assertNull;

public enum TestHelper {
INSTANCE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static void main(String[] args) throws IOException {
runUtil(fileName);
}

public static String runUtil(String fileName) throws IOException {
public static void runUtil(String fileName) throws IOException {
BufferedReader br = new BufferedReader(new FileReader(fileName));

String line;
Expand Down Expand Up @@ -65,8 +65,6 @@ public static String runUtil(String fileName) throws IOException {
log.info("Got " + line);
}

String report = aa.getReport();
System.out.println(report);
return report;
System.out.println(aa.getReport());
}
}

0 comments on commit 4237e50

Please sign in to comment.