mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 381804: Add test for arguments using quotes.
Change-Id: I36dbc43fb1f98c05ee905a8152a012ff16476475 Reviewed-on: https://git.eclipse.org/r/6344 Reviewed-by: Marc Khouzam <marc.khouzam@ericsson.com> IP-Clean: Marc Khouzam <marc.khouzam@ericsson.com> Tested-by: Marc Khouzam <marc.khouzam@ericsson.com>
This commit is contained in:
parent
805136a9e4
commit
f55fb58cad
1 changed files with 72 additions and 0 deletions
|
@ -535,6 +535,78 @@ public class LaunchConfigurationAndRestartTest extends BaseTestCase {
|
|||
testSettingArguments();
|
||||
}
|
||||
|
||||
/**
|
||||
* This test will tell the launch to set some arguments for the program. We will
|
||||
* then check that the program has the same arguments.
|
||||
* See bug 381804
|
||||
*/
|
||||
@Test
|
||||
public void testSettingArgumentsWithSymbols() throws Throwable {
|
||||
// Set a argument with double quotes and spaces, which should be considered a single argument
|
||||
String argumentToPreserveSpaces = "--c=\"c < s: 'a' t: 'b'>\"";
|
||||
String argumentUsedByGDB = "\"--c=c < s: 'a' t: 'b'>\"";
|
||||
|
||||
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, argumentToPreserveSpaces);
|
||||
doLaunch();
|
||||
|
||||
MIStoppedEvent stoppedEvent = getInitialStoppedEvent();
|
||||
|
||||
// Check that argc is correct
|
||||
final IExpressionDMContext argcDmc = SyncUtil.createExpression(stoppedEvent.getDMContext(), "argc");
|
||||
Query<FormattedValueDMData> query = new Query<FormattedValueDMData>() {
|
||||
@Override
|
||||
protected void execute(DataRequestMonitor<FormattedValueDMData> rm) {
|
||||
fExpService.getFormattedExpressionValue(
|
||||
fExpService.getFormattedValueContext(argcDmc, MIExpressions.DETAILS_FORMAT), rm);
|
||||
}
|
||||
};
|
||||
try {
|
||||
fExpService.getExecutor().execute(query);
|
||||
FormattedValueDMData value = query.get(500, TimeUnit.MILLISECONDS);
|
||||
|
||||
// Argc should be 2: the program name and the one arguments
|
||||
assertTrue("Expected 2 but got " + value.getFormattedValue(),
|
||||
value.getFormattedValue().trim().equals("2"));
|
||||
} 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.
|
||||
final IExpressionDMContext argvDmc = SyncUtil.createExpression(stoppedEvent.getDMContext(), "argv[argc-1]");
|
||||
Query<FormattedValueDMData> query2 = new Query<FormattedValueDMData>() {
|
||||
@Override
|
||||
protected void execute(DataRequestMonitor<FormattedValueDMData> rm) {
|
||||
fExpService.getFormattedExpressionValue(
|
||||
fExpService.getFormattedValueContext(argvDmc, MIExpressions.DETAILS_FORMAT), rm);
|
||||
}
|
||||
};
|
||||
try {
|
||||
fExpService.getExecutor().execute(query2);
|
||||
FormattedValueDMData value = query2.get(500, TimeUnit.MILLISECONDS);
|
||||
assertTrue("Expected \"" + argumentUsedByGDB + "\" but got " + value.getFormattedValue(),
|
||||
value.getFormattedValue().trim().endsWith(argumentUsedByGDB));
|
||||
} catch (InterruptedException e) {
|
||||
fail(e.getMessage());
|
||||
} catch (ExecutionException e) {
|
||||
fail(e.getCause().getMessage());
|
||||
} catch (TimeoutException e) {
|
||||
fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Repeat the test testSettingArguments, but after a restart.
|
||||
*/
|
||||
@Test
|
||||
public void testSettingArgumentsWithSymbolsRestart() throws Throwable {
|
||||
fRestart = true;
|
||||
testSettingArgumentsWithSymbols();
|
||||
}
|
||||
|
||||
/**
|
||||
* This test will tell the launch to "stop on main" at method main(), which we will verify.
|
||||
*/
|
||||
|
|
Loading…
Add table
Reference in a new issue