Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 2de9908980d9ade551b4df22a1888a16380f60f6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
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;
		}
	}

}

Back to the top