Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Marchi2014-12-24 18:45:08 +0000
committerMarc Khouzam2014-12-25 18:51:00 +0000
commit9bbd8d4f3edf90ec3f9df76726130d810c790d75 (patch)
treeaa8fe1092bab93659105df622f3617b53f577d46
parent24301e7396ffc7d39b70e4ed1f1c2ed2a1b53bf9 (diff)
downloadorg.eclipse.cdt-9bbd8d4f3edf90ec3f9df76726130d810c790d75.tar.gz
org.eclipse.cdt-9bbd8d4f3edf90ec3f9df76726130d810c790d75.tar.xz
org.eclipse.cdt-9bbd8d4f3edf90ec3f9df76726130d810c790d75.zip
debug tests: Don't catch exception in SyncUtil context getters
When catching the exception and failing the test manually, we loose the information about the root cause of the problem. We let the exception propagate so that JUnit will show a useful trace. Change-Id: I1df26283f42b58b4dda68ab9e8c11cca27ae81c8 Signed-off-by: Simon Marchi <simon.marchi@polymtl.ca> Reviewed-on: https://git.eclipse.org/r/38771 Reviewed-by: Marc Khouzam <marc.khouzam@ericsson.com> Tested-by: Marc Khouzam <marc.khouzam@ericsson.com>
-rw-r--r--dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/SyncUtil.java29
-rw-r--r--dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/GDBProcessesTest.java6
-rw-r--r--dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIRunControlTest.java10
3 files changed, 24 insertions, 21 deletions
diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/SyncUtil.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/SyncUtil.java
index 4372b3a6cc..7e8e628496 100644
--- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/SyncUtil.java
+++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/SyncUtil.java
@@ -22,7 +22,9 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
import org.eclipse.cdt.dsf.concurrent.CountingRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
@@ -632,9 +634,11 @@ public class SyncUtil {
*
* @return the process context
* @throws InterruptedException
+ * @throws TimeoutException
+ * @throws ExecutionException
*/
@ThreadSafeAndProhibitedFromDsfExecutor("fSession.getExecutor()")
- public static IContainerDMContext getContainerContext() throws InterruptedException {
+ public static IContainerDMContext getContainerContext() throws InterruptedException, ExecutionException, TimeoutException {
assert !fProcessesService.getExecutor().isInExecutorThread();
Query<IContainerDMContext> query = new Query<IContainerDMContext>() {
@@ -661,19 +665,16 @@ public class SyncUtil {
};
fGdbControl.getExecutor().execute(query);
- try {
- return query.get(TestsPlugin.massageTimeout(2000), TimeUnit.MILLISECONDS);
- } catch (Exception e) {
- fail(e.getMessage());
- }
- return null;
+ return query.get(TestsPlugin.massageTimeout(2000), TimeUnit.MILLISECONDS);
}
/**
* Utility method to return all thread execution contexts.
+ * @throws TimeoutException
+ * @throws ExecutionException
*/
@ThreadSafeAndProhibitedFromDsfExecutor("fSession.getExecutor()")
- public static IMIExecutionDMContext[] getExecutionContexts() throws InterruptedException {
+ public static IMIExecutionDMContext[] getExecutionContexts() throws InterruptedException, ExecutionException, TimeoutException {
assert !fProcessesService.getExecutor().isInExecutorThread();
final IContainerDMContext containerDmc = SyncUtil.getContainerContext();
@@ -700,18 +701,16 @@ public class SyncUtil {
};
fGdbControl.getExecutor().execute(query);
- try {
- return query.get(TestsPlugin.massageTimeout(2000), TimeUnit.MILLISECONDS);
- } catch (Exception e) {
- fail(e.getMessage());
- }
- return null;
+ return query.get(TestsPlugin.massageTimeout(2000), TimeUnit.MILLISECONDS);
}
+
/**
* Utility method to return a specific execution DM context.
+ * @throws TimeoutException
+ * @throws ExecutionException
*/
@ThreadSafeAndProhibitedFromDsfExecutor("fSession.getExecutor()")
- public static IMIExecutionDMContext getExecutionContext(int threadIndex) throws InterruptedException {
+ public static IMIExecutionDMContext getExecutionContext(int threadIndex) throws InterruptedException, ExecutionException, TimeoutException {
IMIExecutionDMContext[] threads = getExecutionContexts();
assertTrue("unexpected number of threads", threadIndex < threads.length);
assertNotNull("unexpected thread context type ", threads[threadIndex]);
diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/GDBProcessesTest.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/GDBProcessesTest.java
index 22eca349e6..a977ae2ff7 100644
--- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/GDBProcessesTest.java
+++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/GDBProcessesTest.java
@@ -16,6 +16,8 @@ package org.eclipse.cdt.tests.dsf.gdb.tests;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeoutException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -95,7 +97,7 @@ public class GDBProcessesTest extends BaseTestCase {
/*
* Get the process data for the current program. Process is executable name in case of GDB back end
*/
- public void getProcessData() throws InterruptedException{
+ public void getProcessData() throws InterruptedException, ExecutionException, TimeoutException {
/*
* Create a request monitor
@@ -150,7 +152,7 @@ public class GDBProcessesTest extends BaseTestCase {
* getThreadData() for multiple threads
*/
@Test
- public void getThreadData() throws InterruptedException{
+ public void getThreadData() throws InterruptedException, ExecutionException, TimeoutException {
final String THREAD_ID = "1";
final DataRequestMonitor<IThreadDMData> rm =
diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIRunControlTest.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIRunControlTest.java
index a55c6037af..11d6d43988 100644
--- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIRunControlTest.java
+++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIRunControlTest.java
@@ -20,6 +20,8 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Arrays;
import java.util.LinkedList;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeoutException;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
@@ -187,7 +189,7 @@ public class MIRunControlTest extends BaseTestCase {
* For Multi-threaded application - In case of one thread, Thread id should start with 1.
*/
@Test
- public void getExecutionContext() throws InterruptedException{
+ public void getExecutionContext() throws InterruptedException, ExecutionException, TimeoutException {
final AsyncCompletionWaitor wait = new AsyncCompletionWaitor();
/*
* Create a request monitor
@@ -334,7 +336,7 @@ public class MIRunControlTest extends BaseTestCase {
* Testing getModelData() for ExecutionDMC
*/
@Test
- public void getModelDataForThread() throws InterruptedException{
+ public void getModelDataForThread() throws InterruptedException, ExecutionException, TimeoutException {
final AsyncCompletionWaitor wait = new AsyncCompletionWaitor();
/*
* Create a request monitor
@@ -572,7 +574,7 @@ public class MIRunControlTest extends BaseTestCase {
//Also test Cache after ContainerResumeEvent
@Test
- public void resume() throws InterruptedException{
+ public void resume() throws InterruptedException, ExecutionException, TimeoutException {
final AsyncCompletionWaitor wait = new AsyncCompletionWaitor();
final DataRequestMonitor<MIInfo> rm =
@@ -624,7 +626,7 @@ public class MIRunControlTest extends BaseTestCase {
}
@Test
- public void resumeContainerContext() throws InterruptedException{
+ public void resumeContainerContext() throws InterruptedException, ExecutionException, TimeoutException {
final AsyncCompletionWaitor wait = new AsyncCompletionWaitor();
final DataRequestMonitor<MIInfo> rm =

Back to the top