1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 17:56:01 +02:00

Bug 499778: Stop losing stacktraces in tests

Rather than try/catch/fail just let exception cascade so that the full
stacktrace is available in the test results.

The braces have been left in place for scoping and to minimize changes.

Change-Id: I5407829ea964f828e3f996794489a7b884de25fb
This commit is contained in:
Jonah Graham 2017-04-28 21:11:27 +01:00
parent 10b1e6e4c7
commit 6edd1c6a53
7 changed files with 34 additions and 222 deletions

View file

@ -11,7 +11,6 @@
package org.eclipse.cdt.tests.dsf.gdb.framework; package org.eclipse.cdt.tests.dsf.gdb.framework;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
@ -178,8 +177,8 @@ public abstract class BaseParametrizedTestCase extends BaseTestCase {
} }
@Override @Override
protected void validateGdbVersion(GdbLaunch launch) { protected void validateGdbVersion(GdbLaunch launch) throws CoreException {
try { {
String expected = getGdbVersionParameter(); String expected = getGdbVersionParameter();
if (expected.equals(DEFAULT_VERSION_STRING)) { if (expected.equals(DEFAULT_VERSION_STRING)) {
// If the user has requested the default GDB, we accept whatever version runs. // If the user has requested the default GDB, we accept whatever version runs.
@ -204,8 +203,6 @@ public abstract class BaseParametrizedTestCase extends BaseTestCase {
assertTrue("Unexpected GDB version. Expected " + expected + " actual " + actual, assertTrue("Unexpected GDB version. Expected " + expected + " actual " + actual,
LaunchUtils.compareVersions(expected, comparableActualString) == 0); LaunchUtils.compareVersions(expected, comparableActualString) == 0);
} catch (CoreException e) {
fail(e.getMessage());
} }
} }
} }

View file

@ -185,7 +185,7 @@ public class BaseTestCase {
* *
* @param launch The launch in which we can find the gdb version * @param launch The launch in which we can find the gdb version
*/ */
protected void validateGdbVersion(GdbLaunch launch) {}; protected void validateGdbVersion(GdbLaunch launch) throws Exception {};
/** /**
* We listen for the target to stop at the main breakpoint. This listener is * We listen for the target to stop at the main breakpoint. This listener is

View file

@ -22,9 +22,7 @@ import static org.junit.Assert.fail;
import java.io.File; import java.io.File;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.eclipse.cdt.debug.core.CDIDebugModel; import org.eclipse.cdt.debug.core.CDIDebugModel;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
@ -182,15 +180,9 @@ public class LaunchConfigurationAndRestartTest extends BaseParametrizedTestCase
rm); rm);
} }
}; };
try { {
fExpService.getExecutor().execute(query); fExpService.getExecutor().execute(query);
query.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS); query.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
fail(e.getMessage());
} catch (ExecutionException e) {
fail(e.getCause().getMessage());
} catch (TimeoutException e) {
fail(e.getMessage());
} }
} }
@ -223,7 +215,7 @@ public class LaunchConfigurationAndRestartTest extends BaseParametrizedTestCase
try { try {
doLaunch(); doLaunch();
} catch (CoreException e) { } catch (CoreException e) {
fail("Launch has failed even though the gdbinit file has the default name of .gdbinit"); throw new AssertionError("Launch has failed even though the gdbinit file has the default name of .gdbinit", e);
} }
} }
@ -260,19 +252,13 @@ public class LaunchConfigurationAndRestartTest extends BaseParametrizedTestCase
fExpService.getFormattedValueContext(argcDmc, MIExpressions.DETAILS_FORMAT), rm); fExpService.getFormattedValueContext(argcDmc, MIExpressions.DETAILS_FORMAT), rm);
} }
}; };
try { {
fExpService.getExecutor().execute(query); fExpService.getExecutor().execute(query);
FormattedValueDMData value = query.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS); FormattedValueDMData value = query.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS);
// Argc should be 7: the program name and the six arguments // Argc should be 7: the program name and the six arguments
assertTrue("Expected 7 but got " + value.getFormattedValue(), assertTrue("Expected 7 but got " + value.getFormattedValue(),
value.getFormattedValue().trim().equals("7")); value.getFormattedValue().trim().equals("7"));
} catch (InterruptedException e) {
fail(e.getMessage());
} catch (ExecutionException e) {
fail(e.getCause().getMessage());
} catch (TimeoutException e) {
fail(e.getMessage());
} }
// Check that argv is also correct. For simplicity we only check the last argument // Check that argv is also correct. For simplicity we only check the last argument
@ -284,17 +270,11 @@ public class LaunchConfigurationAndRestartTest extends BaseParametrizedTestCase
fExpService.getFormattedValueContext(argvDmc, MIExpressions.DETAILS_FORMAT), rm); fExpService.getFormattedValueContext(argvDmc, MIExpressions.DETAILS_FORMAT), rm);
} }
}; };
try { {
fExpService.getExecutor().execute(query2); fExpService.getExecutor().execute(query2);
FormattedValueDMData value = query2.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS); FormattedValueDMData value = query2.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS);
assertTrue("Expected \"6\" but got " + value.getFormattedValue(), assertTrue("Expected \"6\" but got " + value.getFormattedValue(),
value.getFormattedValue().trim().endsWith("\"6\"")); value.getFormattedValue().trim().endsWith("\"6\""));
} catch (InterruptedException e) {
fail(e.getMessage());
} catch (ExecutionException e) {
fail(e.getCause().getMessage());
} catch (TimeoutException e) {
fail(e.getMessage());
} }
} }
@ -330,17 +310,11 @@ public class LaunchConfigurationAndRestartTest extends BaseParametrizedTestCase
fExpService.getFormattedValueContext(exprDmc, MIExpressions.DETAILS_FORMAT), rm); fExpService.getFormattedValueContext(exprDmc, MIExpressions.DETAILS_FORMAT), rm);
} }
}; };
try { {
fExpService.getExecutor().execute(query); fExpService.getExecutor().execute(query);
FormattedValueDMData value = query.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS); FormattedValueDMData value = query.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS);
assertTrue("Expected 0x0 but got " + value.getFormattedValue(), assertTrue("Expected 0x0 but got " + value.getFormattedValue(),
value.getFormattedValue().equals("0x0")); value.getFormattedValue().equals("0x0"));
} catch (InterruptedException e) {
fail(e.getMessage());
} catch (ExecutionException e) {
fail(e.getCause().getMessage());
} catch (TimeoutException e) {
fail(e.getMessage());
} }
} }
@ -379,17 +353,11 @@ public class LaunchConfigurationAndRestartTest extends BaseParametrizedTestCase
fExpService.getFormattedValueContext(exprDmc, MIExpressions.DETAILS_FORMAT), rm); fExpService.getFormattedValueContext(exprDmc, MIExpressions.DETAILS_FORMAT), rm);
} }
}; };
try { {
fExpService.getExecutor().execute(query); fExpService.getExecutor().execute(query);
FormattedValueDMData value = query.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS); FormattedValueDMData value = query.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS);
assertTrue("Expected a string ending with \"IS SET\" but got " + value.getFormattedValue(), assertTrue("Expected a string ending with \"IS SET\" but got " + value.getFormattedValue(),
value.getFormattedValue().trim().endsWith("\"IS SET\"")); value.getFormattedValue().trim().endsWith("\"IS SET\""));
} catch (InterruptedException e) {
fail(e.getMessage());
} catch (ExecutionException e) {
fail(e.getCause().getMessage());
} catch (TimeoutException e) {
fail(e.getMessage());
} }
// Check that the normal environment is there by checking that $HOME (which is stored in 'home" exists. // Check that the normal environment is there by checking that $HOME (which is stored in 'home" exists.
@ -401,17 +369,11 @@ public class LaunchConfigurationAndRestartTest extends BaseParametrizedTestCase
fExpService.getFormattedValueContext(exprDmc2, MIExpressions.DETAILS_FORMAT), rm); fExpService.getFormattedValueContext(exprDmc2, MIExpressions.DETAILS_FORMAT), rm);
} }
}; };
try { {
fExpService.getExecutor().execute(query2); fExpService.getExecutor().execute(query2);
FormattedValueDMData value = query2.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS); FormattedValueDMData value = query2.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS);
assertFalse("Expected something else than 0x0", assertFalse("Expected something else than 0x0",
value.getFormattedValue().equals("0x0")); value.getFormattedValue().equals("0x0"));
} catch (InterruptedException e) {
fail(e.getMessage());
} catch (ExecutionException e) {
fail(e.getCause().getMessage());
} catch (TimeoutException e) {
fail(e.getMessage());
} }
} }
@ -453,17 +415,11 @@ public class LaunchConfigurationAndRestartTest extends BaseParametrizedTestCase
fExpService.getFormattedValueContext(exprDmc, MIExpressions.DETAILS_FORMAT), rm); fExpService.getFormattedValueContext(exprDmc, MIExpressions.DETAILS_FORMAT), rm);
} }
}; };
try { {
fExpService.getExecutor().execute(query); fExpService.getExecutor().execute(query);
FormattedValueDMData value = query.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS); FormattedValueDMData value = query.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS);
assertTrue("Expected a string ending with \"IS SET\" but got " + value.getFormattedValue(), assertTrue("Expected a string ending with \"IS SET\" but got " + value.getFormattedValue(),
value.getFormattedValue().trim().endsWith("\"IS SET\"")); value.getFormattedValue().trim().endsWith("\"IS SET\""));
} catch (InterruptedException e) {
fail(e.getMessage());
} catch (ExecutionException e) {
fail(e.getCause().getMessage());
} catch (TimeoutException e) {
fail(e.getMessage());
} }
// The program has stored the content of $HOME into a variable called 'home'. // The program has stored the content of $HOME into a variable called 'home'.
@ -476,17 +432,11 @@ public class LaunchConfigurationAndRestartTest extends BaseParametrizedTestCase
fExpService.getFormattedValueContext(exprDmc2, MIExpressions.DETAILS_FORMAT), rm); fExpService.getFormattedValueContext(exprDmc2, MIExpressions.DETAILS_FORMAT), rm);
} }
}; };
try { {
fExpService.getExecutor().execute(query2); fExpService.getExecutor().execute(query2);
FormattedValueDMData value = query2.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS); FormattedValueDMData value = query2.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS);
assertTrue("Expected 0x0 but got " + value.getFormattedValue(), assertTrue("Expected 0x0 but got " + value.getFormattedValue(),
value.getFormattedValue().equals("0x0")); value.getFormattedValue().equals("0x0"));
} catch (InterruptedException e) {
fail(e.getMessage());
} catch (ExecutionException e) {
fail(e.getCause().getMessage());
} catch (TimeoutException e) {
fail(e.getMessage());
} }
} }
@ -523,19 +473,13 @@ public class LaunchConfigurationAndRestartTest extends BaseParametrizedTestCase
fExpService.getFormattedValueContext(argcDmc, MIExpressions.DETAILS_FORMAT), rm); fExpService.getFormattedValueContext(argcDmc, MIExpressions.DETAILS_FORMAT), rm);
} }
}; };
try { {
fExpService.getExecutor().execute(query); fExpService.getExecutor().execute(query);
FormattedValueDMData value = query.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS); FormattedValueDMData value = query.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS);
// Argc should be 7: the program name and the six arguments // Argc should be 7: the program name and the six arguments
assertTrue("Expected 7 but got " + value.getFormattedValue(), assertTrue("Expected 7 but got " + value.getFormattedValue(),
value.getFormattedValue().trim().equals("7")); value.getFormattedValue().trim().equals("7"));
} catch (InterruptedException e) {
fail(e.getMessage());
} catch (ExecutionException e) {
fail(e.getCause().getMessage());
} catch (TimeoutException e) {
fail(e.getMessage());
} }
// Check that argv is also correct. For simplicity we only check the last argument // Check that argv is also correct. For simplicity we only check the last argument
@ -547,17 +491,11 @@ public class LaunchConfigurationAndRestartTest extends BaseParametrizedTestCase
fExpService.getFormattedValueContext(argvDmc, MIExpressions.DETAILS_FORMAT), rm); fExpService.getFormattedValueContext(argvDmc, MIExpressions.DETAILS_FORMAT), rm);
} }
}; };
try { {
fExpService.getExecutor().execute(query2); fExpService.getExecutor().execute(query2);
FormattedValueDMData value = query2.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS); FormattedValueDMData value = query2.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS);
assertTrue("Expected \"6\" but got " + value.getFormattedValue(), assertTrue("Expected \"6\" but got " + value.getFormattedValue(),
value.getFormattedValue().trim().endsWith("\"6\"")); value.getFormattedValue().trim().endsWith("\"6\""));
} catch (InterruptedException e) {
fail(e.getMessage());
} catch (ExecutionException e) {
fail(e.getCause().getMessage());
} catch (TimeoutException e) {
fail(e.getMessage());
} }
} }
@ -745,7 +683,7 @@ public class LaunchConfigurationAndRestartTest extends BaseParametrizedTestCase
}); });
} }
}; };
try { {
fExpService.getExecutor().execute(query); fExpService.getExecutor().execute(query);
MIBreakListInfo value = query.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS); MIBreakListInfo value = query.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS);
MIBreakpoint[] bps = value.getMIBreakpoints(); MIBreakpoint[] bps = value.getMIBreakpoints();
@ -753,12 +691,6 @@ public class LaunchConfigurationAndRestartTest extends BaseParametrizedTestCase
bps.length == 1); bps.length == 1);
assertTrue("Expending a <PENDING> breakpoint but got one at " + bps[0].getAddress(), assertTrue("Expending a <PENDING> breakpoint but got one at " + bps[0].getAddress(),
bps[0].getAddress().equals("<PENDING>")); bps[0].getAddress().equals("<PENDING>"));
} catch (InterruptedException e) {
fail(e.getMessage());
} catch (ExecutionException e) {
fail(e.getCause().getMessage());
} catch (TimeoutException e) {
fail(e.getMessage());
} }
} }
@ -813,15 +745,9 @@ public class LaunchConfigurationAndRestartTest extends BaseParametrizedTestCase
rm); rm);
} }
}; };
try { {
fGdbControl.getExecutor().execute(query); fGdbControl.getExecutor().execute(query);
query.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS); query.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
fail(e.getMessage());
} catch (ExecutionException e) {
fail(e.getCause().getMessage());
} catch (TimeoutException e) {
fail(e.getMessage());
} }
stoppedEvent = eventWaitor.waitForEvent(TestsPlugin.massageTimeout(1000)); stoppedEvent = eventWaitor.waitForEvent(TestsPlugin.massageTimeout(1000));
@ -889,15 +815,9 @@ public class LaunchConfigurationAndRestartTest extends BaseParametrizedTestCase
rm); rm);
} }
}; };
try { {
fGdbControl.getExecutor().execute(query2); fGdbControl.getExecutor().execute(query2);
query2.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS); query2.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
fail(e.getMessage());
} catch (ExecutionException e) {
fail(e.getCause().getMessage());
} catch (TimeoutException e) {
fail(e.getMessage());
} }
stoppedEvent = eventWaitor.waitForEvent(TestsPlugin.massageTimeout(1000)); stoppedEvent = eventWaitor.waitForEvent(TestsPlugin.massageTimeout(1000));
@ -972,15 +892,9 @@ public class LaunchConfigurationAndRestartTest extends BaseParametrizedTestCase
rm); rm);
} }
}; };
try { {
fGdbControl.getExecutor().execute(query2); fGdbControl.getExecutor().execute(query2);
query2.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS); query2.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
fail(e.getMessage());
} catch (ExecutionException e) {
fail(e.getCause().getMessage());
} catch (TimeoutException e) {
fail(e.getMessage());
} }
stoppedEvent = eventWaitor.waitForEvent(TestsPlugin.massageTimeout(1000)); stoppedEvent = eventWaitor.waitForEvent(TestsPlugin.massageTimeout(1000));

View file

@ -15,7 +15,6 @@ import static org.junit.Assert.fail;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
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.CountingRequestMonitor; import org.eclipse.cdt.dsf.concurrent.CountingRequestMonitor;
@ -47,9 +46,6 @@ import org.junit.runners.Parameterized;
*/ */
@RunWith(Parameterized.class) @RunWith(Parameterized.class)
public class MIRunControlTargetAvailableTest extends BaseParametrizedTestCase { public class MIRunControlTargetAvailableTest extends BaseParametrizedTestCase {
private static final String TIMEOUT_MESSAGE = "Timeout";
private DsfServicesTracker fServicesTracker; private DsfServicesTracker fServicesTracker;
private IGDBControl fGDBCtrl; private IGDBControl fGDBCtrl;
@ -127,15 +123,9 @@ public class MIRunControlTargetAvailableTest extends BaseParametrizedTestCase {
fRunCtrl.executeWithTargetAvailable(fContainerDmc, steps, rm); fRunCtrl.executeWithTargetAvailable(fContainerDmc, steps, rm);
} }
}; };
try { {
fRunCtrl.getExecutor().execute(query); fRunCtrl.getExecutor().execute(query);
query.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS); query.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
fail(e.getMessage());
} catch (ExecutionException e) {
fail(e.getCause().getMessage());
} catch (TimeoutException e) {
fail(TIMEOUT_MESSAGE);
} }
// Now resume the target and check that we stop at the breakpoint. // Now resume the target and check that we stop at the breakpoint.
@ -182,15 +172,9 @@ public class MIRunControlTargetAvailableTest extends BaseParametrizedTestCase {
fRunCtrl.executeWithTargetAvailable(fContainerDmc, steps, rm); fRunCtrl.executeWithTargetAvailable(fContainerDmc, steps, rm);
} }
}; };
try { {
fRunCtrl.getExecutor().execute(query); fRunCtrl.getExecutor().execute(query);
query.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS); query.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
fail(e.getMessage());
} catch (ExecutionException e) {
fail(e.getCause().getMessage());
} catch (TimeoutException e) {
fail(TIMEOUT_MESSAGE);
} }
// Now check that the target is stopped at the breakpoint. // Now check that the target is stopped at the breakpoint.
@ -244,15 +228,9 @@ public class MIRunControlTargetAvailableTest extends BaseParametrizedTestCase {
fRunCtrl.executeWithTargetAvailable(fContainerDmc, steps, rm); fRunCtrl.executeWithTargetAvailable(fContainerDmc, steps, rm);
} }
}; };
try { {
fRunCtrl.getExecutor().execute(query); fRunCtrl.getExecutor().execute(query);
query.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS); query.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
fail(e.getMessage());
} catch (ExecutionException e) {
fail(e.getCause().getMessage());
} catch (TimeoutException e) {
fail(TIMEOUT_MESSAGE);
} }
// Now resume the target three times and check that we stop three times. // Now resume the target three times and check that we stop three times.
@ -318,13 +296,9 @@ public class MIRunControlTargetAvailableTest extends BaseParametrizedTestCase {
try { try {
fRunCtrl.getExecutor().execute(query); fRunCtrl.getExecutor().execute(query);
query.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS); query.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
fail(e.getMessage());
} catch (ExecutionException e) { } catch (ExecutionException e) {
// We want to detect the error, so this is success // We want to detect the error, so this is success
return; return;
} catch (TimeoutException e) {
fail(TIMEOUT_MESSAGE);
} }
fail("Did not detect the error of the step"); fail("Did not detect the error of the step");
@ -381,15 +355,9 @@ public class MIRunControlTargetAvailableTest extends BaseParametrizedTestCase {
fRunCtrl.executeWithTargetAvailable(fContainerDmc, steps, rm); fRunCtrl.executeWithTargetAvailable(fContainerDmc, steps, rm);
} }
}; };
try { {
fRunCtrl.getExecutor().execute(query); fRunCtrl.getExecutor().execute(query);
query.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS); query.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
fail(e.getMessage());
} catch (ExecutionException e) {
fail(e.getCause().getMessage());
} catch (TimeoutException e) {
fail(TIMEOUT_MESSAGE);
} }
// Now resume the target three times and check that we stop three times. // Now resume the target three times and check that we stop three times.
@ -463,12 +431,8 @@ public class MIRunControlTargetAvailableTest extends BaseParametrizedTestCase {
try { try {
fRunCtrl.getExecutor().execute(query); fRunCtrl.getExecutor().execute(query);
query.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS); query.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
fail(e.getMessage());
} catch (ExecutionException e) { } catch (ExecutionException e) {
caughtError = true; caughtError = true;
} catch (TimeoutException e) {
fail(TIMEOUT_MESSAGE);
} }
Assert.assertTrue("Did not catch the error of the step", caughtError); Assert.assertTrue("Did not catch the error of the step", caughtError);
@ -524,15 +488,9 @@ public class MIRunControlTargetAvailableTest extends BaseParametrizedTestCase {
crm.setDoneCount(index); crm.setDoneCount(index);
} }
}; };
try { {
fRunCtrl.getExecutor().execute(query); fRunCtrl.getExecutor().execute(query);
query.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS); query.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
fail(e.getMessage());
} catch (ExecutionException e) {
fail(e.getCause().getMessage());
} catch (TimeoutException e) {
fail(TIMEOUT_MESSAGE);
} }
for (int i=0; i<steps.length; i++) { for (int i=0; i<steps.length; i++) {
@ -599,15 +557,9 @@ public class MIRunControlTargetAvailableTest extends BaseParametrizedTestCase {
crm.setDoneCount(index); crm.setDoneCount(index);
} }
}; };
try { {
fRunCtrl.getExecutor().execute(query); fRunCtrl.getExecutor().execute(query);
query.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS); query.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
fail(e.getMessage());
} catch (ExecutionException e) {
fail(e.getCause().getMessage());
} catch (TimeoutException e) {
fail(TIMEOUT_MESSAGE);
} }
for (int i=0; i<steps.length; i++) { for (int i=0; i<steps.length; i++) {
@ -668,15 +620,9 @@ public class MIRunControlTargetAvailableTest extends BaseParametrizedTestCase {
fRunCtrl.executeWithTargetAvailable(fContainerDmc, steps, rm); fRunCtrl.executeWithTargetAvailable(fContainerDmc, steps, rm);
} }
}; };
try { {
fRunCtrl.getExecutor().execute(query); fRunCtrl.getExecutor().execute(query);
query.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS); query.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
fail(e.getMessage());
} catch (ExecutionException e) {
fail(e.getCause().getMessage());
} catch (TimeoutException e) {
fail(TIMEOUT_MESSAGE);
} }
for (int i=0; i<2; i++) { for (int i=0; i<2; i++) {
@ -742,15 +688,9 @@ public class MIRunControlTargetAvailableTest extends BaseParametrizedTestCase {
fRunCtrl.executeWithTargetAvailable(fContainerDmc, steps, rm); fRunCtrl.executeWithTargetAvailable(fContainerDmc, steps, rm);
} }
}; };
try { {
fRunCtrl.getExecutor().execute(query); fRunCtrl.getExecutor().execute(query);
query.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS); query.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
fail(e.getMessage());
} catch (ExecutionException e) {
fail(e.getCause().getMessage());
} catch (TimeoutException e) {
fail(TIMEOUT_MESSAGE);
} }
for (int i=0; i<2; i++) { for (int i=0; i<2; i++) {
@ -809,15 +749,9 @@ public class MIRunControlTargetAvailableTest extends BaseParametrizedTestCase {
fRunCtrl.executeWithTargetAvailable(fContainerDmc, steps, rm); fRunCtrl.executeWithTargetAvailable(fContainerDmc, steps, rm);
} }
}; };
try { {
fRunCtrl.getExecutor().execute(query); fRunCtrl.getExecutor().execute(query);
query.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS); query.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
fail(e.getMessage());
} catch (ExecutionException e) {
fail(e.getCause().getMessage());
} catch (TimeoutException e) {
fail(TIMEOUT_MESSAGE);
} }
for (int i=0; i<2; i++) { for (int i=0; i<2; i++) {
@ -881,15 +815,9 @@ public class MIRunControlTargetAvailableTest extends BaseParametrizedTestCase {
fRunCtrl.executeWithTargetAvailable(fContainerDmc, steps, rm); fRunCtrl.executeWithTargetAvailable(fContainerDmc, steps, rm);
} }
}; };
try { {
fRunCtrl.getExecutor().execute(query); fRunCtrl.getExecutor().execute(query);
query.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS); query.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
fail(e.getMessage());
} catch (ExecutionException e) {
fail(e.getCause().getMessage());
} catch (TimeoutException e) {
fail(TIMEOUT_MESSAGE);
} }
for (int i=0; i<2; i++) { for (int i=0; i<2; i++) {

View file

@ -10,11 +10,7 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.tests.dsf.gdb.tests; package org.eclipse.cdt.tests.dsf.gdb.tests;
import static org.junit.Assert.fail;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
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;
@ -53,9 +49,6 @@ import org.osgi.service.prefs.Preferences;
*/ */
@RunWith(Parameterized.class) @RunWith(Parameterized.class)
public class OperationsWhileTargetIsRunningTest extends BaseParametrizedTestCase { public class OperationsWhileTargetIsRunningTest extends BaseParametrizedTestCase {
private static final String TIMEOUT_MESSAGE = "Timeout";
private DsfServicesTracker fServicesTracker; private DsfServicesTracker fServicesTracker;
private IGDBProcesses fProcesses; private IGDBProcesses fProcesses;
private IMIContainerDMContext fContainerDmc; private IMIContainerDMContext fContainerDmc;
@ -241,15 +234,9 @@ public class OperationsWhileTargetIsRunningTest extends BaseParametrizedTestCase
fProcesses.terminate(processDmc, rm); fProcesses.terminate(processDmc, rm);
} }
}; };
try { {
fProcesses.getExecutor().execute(query); fProcesses.getExecutor().execute(query);
query.get(TestsPlugin.massageTimeout(1000), TimeUnit.MILLISECONDS); query.get(TestsPlugin.massageTimeout(1000), TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
fail(e.getMessage());
} catch (ExecutionException e) {
fail(e.getCause().getMessage());
} catch (TimeoutException e) {
fail(TIMEOUT_MESSAGE);
} }
IExitedDMEvent event = exitedEventWaitor.waitForEvent(TestsPlugin.massageTimeout(500)); IExitedDMEvent event = exitedEventWaitor.waitForEvent(TestsPlugin.massageTimeout(500));
@ -329,15 +316,9 @@ public class OperationsWhileTargetIsRunningTest extends BaseParametrizedTestCase
fProcesses.detachDebuggerFromProcess(fContainerDmc, rm); fProcesses.detachDebuggerFromProcess(fContainerDmc, rm);
} }
}; };
try { {
fProcesses.getExecutor().execute(query); fProcesses.getExecutor().execute(query);
query.get(TestsPlugin.massageTimeout(1000), TimeUnit.MILLISECONDS); query.get(TestsPlugin.massageTimeout(1000), TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
fail(e.getMessage());
} catch (ExecutionException e) {
fail(e.getCause().getMessage());
} catch (TimeoutException e) {
fail(TIMEOUT_MESSAGE);
} }
IExitedDMEvent event = exitedEventWaitor.waitForEvent(TestsPlugin.massageTimeout(500)); IExitedDMEvent event = exitedEventWaitor.waitForEvent(TestsPlugin.massageTimeout(500));

View file

@ -465,11 +465,8 @@ public class PostMortemCoreTest extends BaseParametrizedTestCase {
fSession.getExecutor().execute(query); fSession.getExecutor().execute(query);
FormattedValueDMData value = null; FormattedValueDMData value = null;
try { {
value = query.get(TestsPlugin.massageTimeout(2000), TimeUnit.MILLISECONDS); value = query.get(TestsPlugin.massageTimeout(2000), TimeUnit.MILLISECONDS);
} catch (Exception e) {
fail(e.getMessage());
return null;
} }
return new Addr64(value.getFormattedValue()); return new Addr64(value.getFormattedValue());

View file

@ -17,7 +17,6 @@ import static org.junit.Assert.fail;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
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;
@ -110,11 +109,11 @@ public class GDBMultiNonStopRunControlTest extends BaseParametrizedTestCase {
public abstract void run(DataRequestMonitor<V> drm); public abstract void run(DataRequestMonitor<V> drm);
}; };
private <V> V runAsyncCall(final AsyncRunnable<V> runnable) { private <V> V runAsyncCall(final AsyncRunnable<V> runnable) throws Exception {
return runAsyncCall(runnable, false); return runAsyncCall(runnable, false);
} }
private <V> V runAsyncCall(final AsyncRunnable<V> runnable, boolean expectExecutionException) { private <V> V runAsyncCall(final AsyncRunnable<V> runnable, boolean expectExecutionException) throws Exception {
Query<V> query = new Query<V>() { Query<V> query = new Query<V>() {
@Override @Override
protected void execute(DataRequestMonitor<V> rm) { protected void execute(DataRequestMonitor<V> rm) {
@ -126,15 +125,11 @@ public class GDBMultiNonStopRunControlTest extends BaseParametrizedTestCase {
try { try {
fMultiRun.getExecutor().execute(query); fMultiRun.getExecutor().execute(query);
result = query.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS); result = query.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
fail(e.getMessage());
} catch (ExecutionException e) { } catch (ExecutionException e) {
if (expectExecutionException) { if (expectExecutionException) {
return null; return null;
} }
fail(e.getCause().getMessage()); throw new AssertionError(e);
} catch (TimeoutException e) {
fail(e.getMessage());
} }
if (expectExecutionException) { if (expectExecutionException) {