-
-
Notifications
You must be signed in to change notification settings - Fork 232
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* testability: bench test commands should have automated coverage using simulator #5562 * testability: bench test commands should have automated coverage using simulator #5562
- Loading branch information
Showing
5 changed files
with
95 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
java_console/autotest/src/main/java/com/rusefi/simulator/SimulatorFunctionalTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.rusefi.simulator; | ||
|
||
import com.rusefi.io.LinkManager; | ||
import etch.util.CircularByteBuffer; | ||
|
||
import java.io.EOFException; | ||
import java.util.concurrent.CountDownLatch; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import static com.rusefi.binaryprotocol.IoHelper.swap16; | ||
import static com.rusefi.config.generated.Fields.TS_SIMULATE_CAN; | ||
|
||
public class SimulatorFunctionalTest { | ||
private final LinkManager linkManager; | ||
|
||
public SimulatorFunctionalTest(LinkManager linkManager) { | ||
this.linkManager = linkManager; | ||
} | ||
|
||
public void mainTestBody() throws InterruptedException { | ||
CountDownLatch gotCan = new CountDownLatch(1); | ||
linkManager.submit(new Runnable() { | ||
@Override | ||
public void run() { | ||
byte[] response = linkManager.getBinaryProtocol().executeCommand(TS_SIMULATE_CAN, "TS_SIMULATE_CAN"); | ||
|
||
if (response == null) { | ||
return; | ||
} | ||
CircularByteBuffer c = new CircularByteBuffer(response); | ||
try { | ||
int count = swap16(c.getShort()); | ||
|
||
c.get(); | ||
int dataLength = c.get(); | ||
c.get(); | ||
int ide = c.get(); | ||
int eid = c.getInt(); | ||
|
||
System.out.println("Got " + count + " packets"); | ||
System.out.println(response); | ||
gotCan.countDown(); | ||
|
||
} catch (EOFException e) { | ||
throw new IllegalStateException(e); | ||
} | ||
|
||
|
||
} | ||
}); | ||
gotCan.await(1, TimeUnit.MINUTES); | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters