-
-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HW CI
- Loading branch information
Showing
4 changed files
with
74 additions
and
25 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
37 changes: 37 additions & 0 deletions
37
java_console/autotest/src/main/java/com/rusefi/f4discovery/PTraceTest.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,37 @@ | ||
package com.rusefi.f4discovery; | ||
|
||
import com.rusefi.RusefiTestBase; | ||
import com.rusefi.io.LinkManager; | ||
import com.rusefi.io.commands.PTraceHelper; | ||
import com.rusefi.tracing.Entry; | ||
import org.junit.Test; | ||
|
||
import java.util.List; | ||
import java.util.concurrent.CountDownLatch; | ||
import java.util.concurrent.TimeUnit; | ||
import java.util.concurrent.atomic.AtomicReference; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
|
||
public class PTraceTest extends RusefiTestBase { | ||
@Test | ||
public void assertPTrace() throws InterruptedException { | ||
LinkManager linkManager = ecu.getLinkManager(); | ||
AtomicReference<List<Entry>> result = new AtomicReference<>(); | ||
|
||
CountDownLatch latch = new CountDownLatch(1); | ||
linkManager.submit(new Runnable() { | ||
@Override | ||
public void run() { | ||
result.set(PTraceHelper.requestWaitAndGetPTrace(linkManager.getBinaryProtocol())); | ||
latch.countDown(); | ||
|
||
} | ||
}); | ||
|
||
|
||
latch.await(30, TimeUnit.SECONDS); | ||
List<Entry> entries = result.get(); | ||
assertTrue(entries != null && !entries.isEmpty()); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
java_console/io/src/main/java/com/rusefi/io/commands/PTraceHelper.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,33 @@ | ||
package com.rusefi.io.commands; | ||
|
||
import com.rusefi.binaryprotocol.BinaryProtocol; | ||
import com.rusefi.config.generated.Fields; | ||
import com.rusefi.tracing.Entry; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.List; | ||
|
||
import static com.rusefi.binaryprotocol.IoHelper.checkResponseCode; | ||
|
||
public class PTraceHelper { | ||
@NotNull | ||
public static List<Entry> requestWaitAndGetPTrace(BinaryProtocol bp) { | ||
bp.executeCommand(Fields.TS_PERF_TRACE_BEGIN, "begin trace"); | ||
try { | ||
Thread.sleep(500); | ||
} catch (InterruptedException e) { | ||
throw new IllegalStateException(e); | ||
} | ||
|
||
return executeGetPTraceCommand(bp); | ||
} | ||
|
||
@NotNull | ||
private static List<Entry> executeGetPTraceCommand(BinaryProtocol bp) { | ||
byte[] packet = bp.executeCommand(Fields.TS_PERF_TRACE_GET_BUFFER, "get trace"); | ||
if (!checkResponseCode(packet, (byte) Fields.TS_RESPONSE_OK) || ((packet.length - 1) % 8) != 0) | ||
throw new IllegalStateException("Unexpected packet, length=" + (packet != null ? 0 : packet.length)); | ||
|
||
return Entry.parseBuffer(packet); | ||
} | ||
} |
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