aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugene Tarassov2017-07-26 23:29:16 -0400
committerEugene Tarassov2017-07-26 23:29:16 -0400
commitccba156bef2b9023730cde263ffbe62bf160e344 (patch)
tree66e2f8ab563ac45b85ea507d3d03197df4b05631
parentfd9473805e8d6ea67317be3bcd1fff3a25b10ce6 (diff)
downloadorg.eclipse.tcf-ccba156bef2b9023730cde263ffbe62bf160e344.tar.gz
org.eclipse.tcf-ccba156bef2b9023730cde263ffbe62bf160e344.tar.xz
org.eclipse.tcf-ccba156bef2b9023730cde263ffbe62bf160e344.zip
TCF Tests: more tests for GDB Remote Serial Protocol
-rw-r--r--tests/plugins/org.eclipse.tcf.debug.gdb.test/src/org/eclipse/tcf/debug/gdb/test/Main.java6
-rw-r--r--tests/plugins/org.eclipse.tcf.debug.gdb.test/src/org/eclipse/tcf/debug/gdb/test/TestThread.java32
2 files changed, 20 insertions, 18 deletions
diff --git a/tests/plugins/org.eclipse.tcf.debug.gdb.test/src/org/eclipse/tcf/debug/gdb/test/Main.java b/tests/plugins/org.eclipse.tcf.debug.gdb.test/src/org/eclipse/tcf/debug/gdb/test/Main.java
index 3fd7a6fe2..7b739bb1f 100644
--- a/tests/plugins/org.eclipse.tcf.debug.gdb.test/src/org/eclipse/tcf/debug/gdb/test/Main.java
+++ b/tests/plugins/org.eclipse.tcf.debug.gdb.test/src/org/eclipse/tcf/debug/gdb/test/Main.java
@@ -27,8 +27,6 @@ import org.eclipse.tcf.services.IRunControl;
public class Main {
- private static String gdb;
-
private static class EventQueue extends Thread implements IEventQueue {
private final LinkedList<Runnable> queue = new LinkedList<Runnable>();
@@ -180,7 +178,7 @@ public class Main {
return;
}
if (test_thread == null) {
- new TestThread(gdb).start();
+ new TestThread().start();
return;
}
exit(new Exception("Internal error"));
@@ -241,8 +239,6 @@ public class Main {
System.err.println("Missing command line argument - peer identification string");
System.exit(4);
}
- gdb = System.getenv().get("TCF_TEST_GDB");
- if (gdb == null) gdb = "gdb";
Protocol.setEventQueue(new EventQueue());
Protocol.invokeLater(new Runnable() {
public void run() {
diff --git a/tests/plugins/org.eclipse.tcf.debug.gdb.test/src/org/eclipse/tcf/debug/gdb/test/TestThread.java b/tests/plugins/org.eclipse.tcf.debug.gdb.test/src/org/eclipse/tcf/debug/gdb/test/TestThread.java
index e36c8af0b..281f6c8bf 100644
--- a/tests/plugins/org.eclipse.tcf.debug.gdb.test/src/org/eclipse/tcf/debug/gdb/test/TestThread.java
+++ b/tests/plugins/org.eclipse.tcf.debug.gdb.test/src/org/eclipse/tcf/debug/gdb/test/TestThread.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.tcf.debug.gdb.test;
+import java.io.BufferedInputStream;
import java.io.BufferedWriter;
import java.io.InputStream;
import java.io.OutputStreamWriter;
@@ -19,21 +20,16 @@ import java.util.LinkedList;
class TestThread extends Thread {
- final String gdb;
final Object sync = new Object();
final String prompt = "(gdb) ";
- TestThread(String gdb) {
- this.gdb = gdb;
- }
-
class OutputReader extends Thread {
final InputStream inp;
final StringBuffer buf = new StringBuffer();
final LinkedList<String> lst = new LinkedList<String>();
OutputReader(InputStream inp) {
- this.inp = inp;
+ this.inp = new BufferedInputStream(inp);
}
@Override
@@ -79,8 +75,9 @@ class TestThread extends Thread {
System.out.println(std_out.lst.removeFirst());
System.out.flush();
}
- if (std_out.buf.length() > 0 && std_out.buf.toString().equals(prompt)) break;
- sync.wait(500);
+ sync.wait(100);
+ if (std_err.lst.isEmpty() && std_out.lst.isEmpty() &&
+ std_out.buf.length() > 0 && std_out.buf.toString().equals(prompt)) break;
}
}
while (System.currentTimeMillis() < time + 10000);
@@ -99,8 +96,8 @@ class TestThread extends Thread {
std_inp.flush();
System.out.println(c);
System.out.flush();
- if (c.startsWith("mon ")) {
- sleep(2000); // Need to sleep because command output goes to stderr
+ if (c.startsWith("mon ") || c.startsWith("target ")) {
+ sleep(1000); // Need to sleep because command output goes to stderr
}
synchronized (sync) {
for (;;) {
@@ -114,11 +111,16 @@ class TestThread extends Thread {
@Override
public void run() {
try {
+ String gdb = System.getenv().get("TCF_TEST_GDB_EXE");
+ if (gdb == null) gdb = "gdb";
+
+ String port = System.getenv().get("TCF_TEST_GDB_PORT");
+ if (port == null) port = "3000";
+
BigInteger prev_pc = null;
prs = Runtime.getRuntime().exec(new String[] {
- gdb, "-q",
- "--eval-command=set remotetimeout 1000",
- "--eval-command=target extended-remote 127.0.0.1:3000"
+ gdb,
+ "-q"
}, null);
std_inp = new BufferedWriter(new OutputStreamWriter(prs.getOutputStream()));
std_out = new OutputReader(prs.getInputStream());
@@ -126,6 +128,10 @@ class TestThread extends Thread {
std_out.start();
std_err.start();
+ cmd("set remotetimeout 1000");
+
+ cmd("target extended-remote 127.0.0.1:" + port);
+
cmd("mon ps");
if (std_err.lst.size() < 1)
throw new Exception("Invalid 'mon ps' reply: cnt < 1");