mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 23:05:47 +02:00
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>
This commit is contained in:
parent
24301e7396
commit
9bbd8d4f3e
3 changed files with 24 additions and 21 deletions
|
@ -22,7 +22,9 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
import org.eclipse.cdt.dsf.concurrent.CountingRequestMonitor;
|
import org.eclipse.cdt.dsf.concurrent.CountingRequestMonitor;
|
||||||
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
|
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
|
||||||
|
@ -632,9 +634,11 @@ public class SyncUtil {
|
||||||
*
|
*
|
||||||
* @return the process context
|
* @return the process context
|
||||||
* @throws InterruptedException
|
* @throws InterruptedException
|
||||||
|
* @throws TimeoutException
|
||||||
|
* @throws ExecutionException
|
||||||
*/
|
*/
|
||||||
@ThreadSafeAndProhibitedFromDsfExecutor("fSession.getExecutor()")
|
@ThreadSafeAndProhibitedFromDsfExecutor("fSession.getExecutor()")
|
||||||
public static IContainerDMContext getContainerContext() throws InterruptedException {
|
public static IContainerDMContext getContainerContext() throws InterruptedException, ExecutionException, TimeoutException {
|
||||||
assert !fProcessesService.getExecutor().isInExecutorThread();
|
assert !fProcessesService.getExecutor().isInExecutorThread();
|
||||||
|
|
||||||
Query<IContainerDMContext> query = new Query<IContainerDMContext>() {
|
Query<IContainerDMContext> query = new Query<IContainerDMContext>() {
|
||||||
|
@ -661,19 +665,16 @@ public class SyncUtil {
|
||||||
};
|
};
|
||||||
|
|
||||||
fGdbControl.getExecutor().execute(query);
|
fGdbControl.getExecutor().execute(query);
|
||||||
try {
|
return query.get(TestsPlugin.massageTimeout(2000), TimeUnit.MILLISECONDS);
|
||||||
return query.get(TestsPlugin.massageTimeout(2000), TimeUnit.MILLISECONDS);
|
|
||||||
} catch (Exception e) {
|
|
||||||
fail(e.getMessage());
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility method to return all thread execution contexts.
|
* Utility method to return all thread execution contexts.
|
||||||
|
* @throws TimeoutException
|
||||||
|
* @throws ExecutionException
|
||||||
*/
|
*/
|
||||||
@ThreadSafeAndProhibitedFromDsfExecutor("fSession.getExecutor()")
|
@ThreadSafeAndProhibitedFromDsfExecutor("fSession.getExecutor()")
|
||||||
public static IMIExecutionDMContext[] getExecutionContexts() throws InterruptedException {
|
public static IMIExecutionDMContext[] getExecutionContexts() throws InterruptedException, ExecutionException, TimeoutException {
|
||||||
assert !fProcessesService.getExecutor().isInExecutorThread();
|
assert !fProcessesService.getExecutor().isInExecutorThread();
|
||||||
|
|
||||||
final IContainerDMContext containerDmc = SyncUtil.getContainerContext();
|
final IContainerDMContext containerDmc = SyncUtil.getContainerContext();
|
||||||
|
@ -700,18 +701,16 @@ public class SyncUtil {
|
||||||
};
|
};
|
||||||
|
|
||||||
fGdbControl.getExecutor().execute(query);
|
fGdbControl.getExecutor().execute(query);
|
||||||
try {
|
return query.get(TestsPlugin.massageTimeout(2000), TimeUnit.MILLISECONDS);
|
||||||
return query.get(TestsPlugin.massageTimeout(2000), TimeUnit.MILLISECONDS);
|
|
||||||
} catch (Exception e) {
|
|
||||||
fail(e.getMessage());
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility method to return a specific execution DM context.
|
* Utility method to return a specific execution DM context.
|
||||||
|
* @throws TimeoutException
|
||||||
|
* @throws ExecutionException
|
||||||
*/
|
*/
|
||||||
@ThreadSafeAndProhibitedFromDsfExecutor("fSession.getExecutor()")
|
@ThreadSafeAndProhibitedFromDsfExecutor("fSession.getExecutor()")
|
||||||
public static IMIExecutionDMContext getExecutionContext(int threadIndex) throws InterruptedException {
|
public static IMIExecutionDMContext getExecutionContext(int threadIndex) throws InterruptedException, ExecutionException, TimeoutException {
|
||||||
IMIExecutionDMContext[] threads = getExecutionContexts();
|
IMIExecutionDMContext[] threads = getExecutionContexts();
|
||||||
assertTrue("unexpected number of threads", threadIndex < threads.length);
|
assertTrue("unexpected number of threads", threadIndex < threads.length);
|
||||||
assertNotNull("unexpected thread context type ", threads[threadIndex]);
|
assertNotNull("unexpected thread context type ", threads[threadIndex]);
|
||||||
|
|
|
@ -16,6 +16,8 @@ package org.eclipse.cdt.tests.dsf.gdb.tests;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
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.Matcher;
|
||||||
import java.util.regex.Pattern;
|
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
|
* 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
|
* Create a request monitor
|
||||||
|
@ -150,7 +152,7 @@ public class GDBProcessesTest extends BaseTestCase {
|
||||||
* getThreadData() for multiple threads
|
* getThreadData() for multiple threads
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void getThreadData() throws InterruptedException{
|
public void getThreadData() throws InterruptedException, ExecutionException, TimeoutException {
|
||||||
|
|
||||||
final String THREAD_ID = "1";
|
final String THREAD_ID = "1";
|
||||||
final DataRequestMonitor<IThreadDMData> rm =
|
final DataRequestMonitor<IThreadDMData> rm =
|
||||||
|
|
|
@ -20,6 +20,8 @@ import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.LinkedList;
|
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.debug.core.ICDTLaunchConfigurationConstants;
|
||||||
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
|
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.
|
* For Multi-threaded application - In case of one thread, Thread id should start with 1.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void getExecutionContext() throws InterruptedException{
|
public void getExecutionContext() throws InterruptedException, ExecutionException, TimeoutException {
|
||||||
final AsyncCompletionWaitor wait = new AsyncCompletionWaitor();
|
final AsyncCompletionWaitor wait = new AsyncCompletionWaitor();
|
||||||
/*
|
/*
|
||||||
* Create a request monitor
|
* Create a request monitor
|
||||||
|
@ -334,7 +336,7 @@ public class MIRunControlTest extends BaseTestCase {
|
||||||
* Testing getModelData() for ExecutionDMC
|
* Testing getModelData() for ExecutionDMC
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void getModelDataForThread() throws InterruptedException{
|
public void getModelDataForThread() throws InterruptedException, ExecutionException, TimeoutException {
|
||||||
final AsyncCompletionWaitor wait = new AsyncCompletionWaitor();
|
final AsyncCompletionWaitor wait = new AsyncCompletionWaitor();
|
||||||
/*
|
/*
|
||||||
* Create a request monitor
|
* Create a request monitor
|
||||||
|
@ -572,7 +574,7 @@ public class MIRunControlTest extends BaseTestCase {
|
||||||
|
|
||||||
//Also test Cache after ContainerResumeEvent
|
//Also test Cache after ContainerResumeEvent
|
||||||
@Test
|
@Test
|
||||||
public void resume() throws InterruptedException{
|
public void resume() throws InterruptedException, ExecutionException, TimeoutException {
|
||||||
final AsyncCompletionWaitor wait = new AsyncCompletionWaitor();
|
final AsyncCompletionWaitor wait = new AsyncCompletionWaitor();
|
||||||
|
|
||||||
final DataRequestMonitor<MIInfo> rm =
|
final DataRequestMonitor<MIInfo> rm =
|
||||||
|
@ -624,7 +626,7 @@ public class MIRunControlTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void resumeContainerContext() throws InterruptedException{
|
public void resumeContainerContext() throws InterruptedException, ExecutionException, TimeoutException {
|
||||||
final AsyncCompletionWaitor wait = new AsyncCompletionWaitor();
|
final AsyncCompletionWaitor wait = new AsyncCompletionWaitor();
|
||||||
|
|
||||||
final DataRequestMonitor<MIInfo> rm =
|
final DataRequestMonitor<MIInfo> rm =
|
||||||
|
|
Loading…
Add table
Reference in a new issue