Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Loskutov2019-06-04 04:10:12 -0400
committerAndrey Loskutov2019-06-04 04:10:12 -0400
commit59bd1e5f10df5fa7f887ba396a5470afdfb5f80b (patch)
treebfa42c053e0b4c0732101930237ab5e745ed114f
parent75f3e352a42c492d320c07a30923f559c39bbf8c (diff)
downloadeclipse.jdt.core-I20190604-0600.tar.gz
eclipse.jdt.core-I20190604-0600.tar.xz
eclipse.jdt.core-I20190604-0600.zip
Applied same changes as on EvaluationSetup on DebugEvaluationSetup: - doubled timeout time for opening connection - fail the test if the connection is timed out - added printStackTrace() in all cases where it was missing Also added a bit more info to the printed messages. Additionally, added assertions in setUp() about evaluation context and vm. Change-Id: I6f939760fc428283ed2a6b8bab79a7cfaded0661 Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/DebugEvaluationSetup.java47
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/DebugEvaluationTest.java11
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/EvaluationSetup.java2
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/EvaluationTest.java6
4 files changed, 45 insertions, 21 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/DebugEvaluationSetup.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/DebugEvaluationSetup.java
index 0bbdda14e7..1e4651ee58 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/DebugEvaluationSetup.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/DebugEvaluationSetup.java
@@ -13,6 +13,8 @@
*******************************************************************************/
package org.eclipse.jdt.core.tests.eval;
+import static org.junit.Assert.assertTrue;
+
import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
@@ -57,19 +59,22 @@ public class DebugEvaluationSetup extends EvaluationSetup {
launcher.setDebugPort(debugPort);
this.launchedVM = launcher.launch();
} catch (TargetException e) {
- throw new Error(e.getMessage());
+ e.printStackTrace();
+ throw new Error(e.getMessage(), e);
}
// Thread that read the stout of the VM so that the VM doesn't block
try {
startReader("VM's stdout reader", this.launchedVM.getInputStream(), System.out);
} catch (TargetException e) {
+ e.printStackTrace();
}
// Thread that read the sterr of the VM so that the VM doesn't block
try {
startReader("VM's sterr reader", this.launchedVM.getErrorStream(), System.err);
} catch (TargetException e) {
+ e.printStackTrace();
}
// Start JDI connection (try 10 times)
@@ -77,8 +82,10 @@ public class DebugEvaluationSetup extends EvaluationSetup {
try {
VirtualMachineManager manager = org.eclipse.jdi.Bootstrap.virtualMachineManager();
List connectors = manager.attachingConnectors();
- if (connectors.size() == 0)
+ if (connectors.size() == 0) {
+ System.err.println(getName() + ": could not get attachingConnectors() from VM");
break;
+ }
AttachingConnector connector = (AttachingConnector)connectors.get(0);
Map args = connector.defaultArguments();
Connector.Argument argument = (Connector.Argument)args.get("port");
@@ -91,27 +98,22 @@ public class DebugEvaluationSetup extends EvaluationSetup {
}
argument = (Connector.Argument)args.get("timeout");
if (argument != null) {
- argument.setValue("10000");
+ argument.setValue("20000");
}
this.vm = connector.attach(args);
-
+ System.out.println(getName() + ": connected to VM using port " + debugPort);
+
// workaround pb with some VMs
this.vm.resume();
break;
- } catch (IllegalConnectorArgumentsException e) {
+ } catch (IllegalConnectorArgumentsException | IOException e) {
e.printStackTrace();
try {
- System.out.println("Could not contact the VM at " + launcher.getTargetAddress() + ":" + debugPort + ". Retrying...");
- Thread.sleep(100);
- } catch (InterruptedException e2) {
- }
- } catch (IOException e) {
- e.printStackTrace();
- try {
- System.out.println("Could not contact the VM at " + launcher.getTargetAddress() + ":" + debugPort + ". Retrying...");
+ System.out.println(getName() + ": could not contact the VM at " + launcher.getTargetAddress() + ":" + debugPort + ". Retrying...");
Thread.sleep(100);
} catch (InterruptedException e2) {
+ e2.printStackTrace();
}
}
}
@@ -128,8 +130,8 @@ public class DebugEvaluationSetup extends EvaluationSetup {
System.out.print((char)read);
} while (read != -1);
}
- } catch (TargetException e) {
- } catch (IOException e) {
+ } catch (TargetException | IOException e) {
+ e.printStackTrace();
}
// Shut it down
@@ -142,15 +144,17 @@ public class DebugEvaluationSetup extends EvaluationSetup {
try {
Thread.sleep(retry * 100);
} catch (InterruptedException e) {
+ e.printStackTrace();
}
}
if (this.launchedVM.isRunning()) {
this.launchedVM.shutDown();
}
} catch (TargetException e) {
+ e.printStackTrace();
}
}
- System.err.println("Could not contact the VM");
+ System.err.println(getName() + ": could not contact the VM");
return;
}
@@ -159,12 +163,19 @@ public class DebugEvaluationSetup extends EvaluationSetup {
// Create target
this.target = new TargetInterface();
- this.target.connect(evalServer, 30000); // allow 30s max to connect (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=188127)
+
+ // allow 30s max to connect (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=188127)
+ // Increased to 60 s for https://bugs.eclipse.org/bugs/show_bug.cgi?id=547417
+ this.target.connect(evalServer, 60000);
+ assertTrue(getName() + ": failed to connect VM server", this.target.isConnected());
+
+ System.out.println(getName() + ": connected to target using port " + debugPort);
+
// Create name environment
this.env = new FileSystem(Util.getJavaClassLibs(), new String[0], null);
} catch (IOException e1) {
- throw new Error("Failed to open socket", e1);
+ throw new Error(getName() + ": Failed to open socket", e1);
}
}
super.setUp();
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/DebugEvaluationTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/DebugEvaluationTest.java
index 75cdc67535..a30900281c 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/DebugEvaluationTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/DebugEvaluationTest.java
@@ -175,10 +175,15 @@ public class DebugEvaluationTest extends EvaluationTest {
}
public void initialize(CompilerTestSetup setUp) {
super.initialize(setUp);
- if (setUp instanceof DebugEvaluationSetup) {
- this.jdiVM = ((DebugEvaluationSetup)setUp).vm;
- }
+ this.jdiVM = ((DebugEvaluationSetup)setUp).vm;
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ assertNotNull("VM is null, probably VM connection error", this.jdiVM);
}
+
public void removeTempClass(String className) {
resetEnv(); // needed to reinitialize the caches
Util.delete(SOURCE_DIRECTORY + File.separator + className + ".java");
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/EvaluationSetup.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/EvaluationSetup.java
index 8153472966..cdf0ea6e70 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/EvaluationSetup.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/EvaluationSetup.java
@@ -87,6 +87,8 @@ public class EvaluationSetup extends CompilerTestSetup {
assertTrue("Failed to connect VM server", this.target.isConnected());
+ System.out.println(getName() + ": connected to target");
+
// Create name environment
this.env = new FileSystem(Util.getJavaClassLibs(), new String[0], null);
} catch (IOException e1) {
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/EvaluationTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/EvaluationTest.java
index 2f9a68add9..79c9a27372 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/EvaluationTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/EvaluationTest.java
@@ -505,6 +505,12 @@ public class EvaluationTest extends AbstractCompilerTest implements StopableTest
this.env = evalSetUp.env;
}
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ assertNotNull("Evaluation context is null, probably VM connection error", this.context);
+ }
+
/**
* Installs all the variables and check that the number of installed variables is the given number.
*/

Back to the top