diff options
author | Vincent Guignot | 2016-08-26 13:06:35 +0000 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org | 2016-09-21 14:01:49 +0000 |
commit | 2b728ed027bbd920dc3f8f68002acc2aacd101ca (patch) | |
tree | 347823f7490586e3eb1cb5639924e5c898b37aa6 /dsf-gdb/org.eclipse.cdt.dsf.gdb.tests | |
parent | 2a4e3e11e43955b3ec26ef0d6e83faae935d6c1e (diff) | |
download | org.eclipse.cdt-2b728ed027bbd920dc3f8f68002acc2aacd101ca.tar.gz org.eclipse.cdt-2b728ed027bbd920dc3f8f68002acc2aacd101ca.tar.xz org.eclipse.cdt-2b728ed027bbd920dc3f8f68002acc2aacd101ca.zip |
Bug 497693/ Sysroot with spaces
If the sysroot path contains a space, CDT adds doubles quote to escape
the space (in MIStandardParameterAdjustable class) . But Gdb client (7.5
and 7.11) doesn’t understand the double quotes path.
This patch do not add double quotes when the path contains spaces.
Add test case.
Change-Id: I8c54fa625ce1fb1f1b9249361ca07060b56ba90c
Signed-off-by: Vincent Guignot <vincent.guignot@ingenico.com>
Diffstat (limited to 'dsf-gdb/org.eclipse.cdt.dsf.gdb.tests')
2 files changed, 76 insertions, 1 deletions
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.tests/src/org/eclipse/cdt/dsf/gdb/tests/AllTests.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.tests/src/org/eclipse/cdt/dsf/gdb/tests/AllTests.java index 451dd8eaece..9bcdeff4be6 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.tests/src/org/eclipse/cdt/dsf/gdb/tests/AllTests.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.tests/src/org/eclipse/cdt/dsf/gdb/tests/AllTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2014, 2015 Ericsson AB and others. + * Copyright (c) 2014, 2016 Ericsson AB and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -12,6 +12,7 @@ package org.eclipse.cdt.dsf.gdb.tests; import org.eclipse.cdt.dsf.mi.service.command.commands.TestMIBreakInsertCommand; import org.eclipse.cdt.dsf.mi.service.command.commands.TestMICommandConstructCommand; +import org.eclipse.cdt.dsf.mi.service.command.commands.TestMIGDBSetSysroot; import org.eclipse.cdt.dsf.mi.service.command.output.MIStringHandlerTests; import org.eclipse.cdt.dsf.mi.service.command.output.MIThreadTests; import org.junit.runner.RunWith; @@ -24,6 +25,7 @@ import org.junit.runners.Suite.SuiteClasses; @SuiteClasses({MIThreadTests.class, TestMIBreakInsertCommand.class, TestMICommandConstructCommand.class, + TestMIGDBSetSysroot.class, LaunchUtilsTest.class, MIStringHandlerTests.class, ProcStatParserTest.class, diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.tests/src/org/eclipse/cdt/dsf/mi/service/command/commands/TestMIGDBSetSysroot.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.tests/src/org/eclipse/cdt/dsf/mi/service/command/commands/TestMIGDBSetSysroot.java new file mode 100644 index 00000000000..2de9908980d --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.tests/src/org/eclipse/cdt/dsf/mi/service/command/commands/TestMIGDBSetSysroot.java @@ -0,0 +1,73 @@ +/*******************************************************************************
+ * Copyright (c) 2016 Ingenico.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ingenico - Sysroot with spaces (Bug 497693)
+ *******************************************************************************/
+package org.eclipse.cdt.dsf.mi.service.command.commands;
+
+import static org.junit.Assert.assertEquals;
+
+import org.eclipse.cdt.dsf.concurrent.DefaultDsfExecutor;
+import org.eclipse.cdt.dsf.datamodel.IDMContext;
+import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext;
+import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
+import org.eclipse.cdt.dsf.gdb.service.command.GDBControlDMContext;
+import org.eclipse.cdt.dsf.service.DsfSession;
+import org.junit.Test;
+
+/**
+ * Verifies that the set sysroot MI command don't add double quotes if path contains space.
+ *
+ */
+public class TestMIGDBSetSysroot {
+
+ @Test
+ public void pathWithSpaceShouldNotBe() {
+ MIGDBSetSysroot setSysrootCommand = new MIGDBSetSysroot(new TestContext(), "/tmp/test with space/");
+ assertEquals("Wrong syntax for command", "-gdb-set sysroot /tmp/test with space/\n",
+ setSysrootCommand.constructCommand());
+ }
+
+ @Test
+ public void pathWithDoubleQuotesShouldNotBe() {
+ MIGDBSetSysroot setSysrootCommand = new MIGDBSetSysroot(new TestContext(), "/tmp/test with\"double quotes/");
+ assertEquals("Wrong syntax for command", "-gdb-set sysroot /tmp/test with\"double quotes/\n",
+ setSysrootCommand.constructCommand());
+
+
+ }
+
+ private class TestContext implements ICommandControlDMContext {
+ private DsfSession session = null;
+
+ public TestContext() {
+ session = DsfSession.startSession(new DefaultDsfExecutor(GdbPlugin.PLUGIN_ID), GdbPlugin.PLUGIN_ID);
+ }
+
+ @Override
+ public IDMContext[] getParents() {
+ return new IDMContext[] { new GDBControlDMContext(getSessionId(), "1") };
+ }
+
+ @Override
+ public String getSessionId() {
+ return session.getId();
+ }
+
+ @Override
+ public <T> T getAdapter(Class<T> adapter) {
+ return null;
+ }
+
+ @Override
+ public String getCommandControlId() {
+ return null;
+ }
+ }
+
+}
|