diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/BaseRemoteSuite.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/BaseRemoteSuite.java new file mode 100644 index 00000000000..010566a9557 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/BaseRemoteSuite.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2011 Ericsson 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Ericsson - Initial Implementation + *******************************************************************************/ +package org.eclipse.cdt.tests.dsf.gdb.framework; + +import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; +import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants; +import org.junit.AfterClass; +import org.junit.BeforeClass; + +/** + * This base class sets the attributes necessary to do a + * remote debugging session. + */ +public class BaseRemoteSuite { + @BeforeClass + public static void beforeClassMethod() { + BaseTestCase.setGlobalLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, + IGDBLaunchConfigurationConstants.DEBUGGER_MODE_REMOTE); + } + @AfterClass + public static void afterClassMethod() { + BaseTestCase.removeGlobalLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE); + } +} diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/BaseTestCase.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/BaseTestCase.java index 381d5d4a2cb..6a9c4c5daea 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/BaseTestCase.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/BaseTestCase.java @@ -59,8 +59,20 @@ public class BaseTestCase { private static final String DEFAULT_TEST_APP = "data/launch/bin/GDBMIGenericTestApp"; private static GdbLaunch fLaunch; - private static Map attrs; - private static Process gdbserverProc; + + // The set of attributes used for the launch + // These are seset to their default whenever a new class + // of tests is started. + private static Map launchAttributes; + + // A set of global launch attributes which are not + // reset when we load a new class of tests. + // This allows a Suite to set an attribute + // The suite is reponsible for clearing those attributes + // once it is finished + private static Map globalLaunchAttributes; + + private static Process gdbserverProc; /** The MI event associated with the breakpoint at main() */ private MIStoppedEvent fInitialStoppedEvent; @@ -74,7 +86,20 @@ public class BaseTestCase { public GdbLaunch getGDBLaunch() { return fLaunch; } public static void setLaunchAttribute(String key, Object value) { - attrs.put(key, value); + launchAttributes.put(key, value); + } + + public static void setGlobalLaunchAttribute(String key, Object value) { + if (globalLaunchAttributes == null) { + globalLaunchAttributes = new HashMap(); + } + globalLaunchAttributes.put(key, value); + } + + public static void removeGlobalLaunchAttribute(String key) { + if (globalLaunchAttributes != null) { + globalLaunchAttributes.remove(key); + } } public synchronized MIStoppedEvent getInitialStoppedEvent() { return fInitialStoppedEvent; } @@ -119,31 +144,34 @@ public class BaseTestCase { @BeforeClass public static void baseBeforeClassMethod() { - // Must clear all the attributes, because some tests change them. - attrs = new HashMap(); + // Clear all launch attributes before starting a new class of tests + launchAttributes = new HashMap(); // Setup information for the launcher - attrs.put(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, DEFAULT_TEST_APP); + launchAttributes.put(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, DEFAULT_TEST_APP); - attrs.put(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, true); - attrs.put(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN_SYMBOL, ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_SYMBOL_DEFAULT); - attrs.put(IGDBLaunchConfigurationConstants.ATTR_GDB_INIT, ".gdbinit"); + launchAttributes.put(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, true); + launchAttributes.put(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN_SYMBOL, ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_SYMBOL_DEFAULT); + launchAttributes.put(IGDBLaunchConfigurationConstants.ATTR_GDB_INIT, ".gdbinit"); - if (attrs.get(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE) == null) { - attrs.put(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN ); + if (launchAttributes.get(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE) == null) { + launchAttributes.put(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN ); } // Set these up in case we will be running Remote tests. They will be ignored if we don't - attrs.put(ATTR_DEBUG_SERVER_NAME, "gdbserver"); - attrs.put(IGDBLaunchConfigurationConstants.ATTR_REMOTE_TCP, true); - attrs.put(IGDBLaunchConfigurationConstants.ATTR_HOST, "localhost"); - attrs.put(IGDBLaunchConfigurationConstants.ATTR_PORT, "9999"); + launchAttributes.put(ATTR_DEBUG_SERVER_NAME, "gdbserver"); + launchAttributes.put(IGDBLaunchConfigurationConstants.ATTR_REMOTE_TCP, true); + launchAttributes.put(IGDBLaunchConfigurationConstants.ATTR_HOST, "localhost"); + launchAttributes.put(IGDBLaunchConfigurationConstants.ATTR_PORT, "9999"); + + // Set the global launch attributes + launchAttributes.putAll(globalLaunchAttributes); } @Before public void baseBeforeMethod() throws Exception { System.out.println("===================================================================================================="); - System.out.println("Running test: " + testName.getMethodName() + " using GDB: " + attrs.get(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME)); + System.out.println("Running test: " + testName.getMethodName() + " using GDB: " + launchAttributes.get(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME)); System.out.println("===================================================================================================="); // First check if we should launch gdbserver in the case of a remote session @@ -157,7 +185,7 @@ public class BaseTestCase { null, launchMgr.generateLaunchConfigurationName("Test Launch")); //$NON-NLS-1$ assert lcWorkingCopy != null; - lcWorkingCopy.setAttributes(attrs); + lcWorkingCopy.setAttributes(launchAttributes); final ILaunchConfiguration lc = lcWorkingCopy.doSave(); @@ -221,12 +249,12 @@ public class BaseTestCase { * If the user specified a different host, things won't work. */ private static void launchGdbServer() { - if (attrs.get(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE) + if (launchAttributes.get(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE) .equals(IGDBLaunchConfigurationConstants.DEBUGGER_MODE_REMOTE)) { - if (attrs.get(IGDBLaunchConfigurationConstants.ATTR_REMOTE_TCP).equals(Boolean.TRUE)) { - String server = (String)attrs.get(ATTR_DEBUG_SERVER_NAME); - String port = (String)attrs.get(IGDBLaunchConfigurationConstants.ATTR_PORT); - String program = (String)attrs.get(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME); + if (launchAttributes.get(IGDBLaunchConfigurationConstants.ATTR_REMOTE_TCP).equals(Boolean.TRUE)) { + String server = (String)launchAttributes.get(ATTR_DEBUG_SERVER_NAME); + String port = (String)launchAttributes.get(IGDBLaunchConfigurationConstants.ATTR_PORT); + String program = (String)launchAttributes.get(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME); String commandLine = server + " :" + port + " " + program; try { System.out.println("Staring gdbserver with command: " + commandLine); diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_6/Suite_Remote_6_6.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_6/Suite_Remote_6_6.java index 69b69af69d5..19d259a4ff0 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_6/Suite_Remote_6_6.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_6/Suite_Remote_6_6.java @@ -10,11 +10,8 @@ *******************************************************************************/ package org.eclipse.cdt.tests.dsf.gdb.tests.tests_6_6; -import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; -import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants; import org.eclipse.cdt.dsf.mi.service.command.commands.Suite_Sessionless_Tests; -import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase; -import org.junit.BeforeClass; +import org.eclipse.cdt.tests.dsf.gdb.framework.BaseRemoteSuite; import org.junit.runner.RunWith; import org.junit.runners.Suite; @@ -44,10 +41,5 @@ import org.junit.runners.Suite; /* Add your test class here */ }) -public class Suite_Remote_6_6 { - @BeforeClass - public static void beforeClassMethod() { - BaseTestCase.setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, - IGDBLaunchConfigurationConstants.DEBUGGER_MODE_REMOTE); - } +public class Suite_Remote_6_6 extends BaseRemoteSuite { } diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_7/Suite_Remote_6_7.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_7/Suite_Remote_6_7.java index aefa2fce6f5..504ca779574 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_7/Suite_Remote_6_7.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_7/Suite_Remote_6_7.java @@ -10,11 +10,8 @@ *******************************************************************************/ package org.eclipse.cdt.tests.dsf.gdb.tests.tests_6_7; -import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; -import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants; import org.eclipse.cdt.dsf.mi.service.command.commands.Suite_Sessionless_Tests; -import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase; -import org.junit.BeforeClass; +import org.eclipse.cdt.tests.dsf.gdb.framework.BaseRemoteSuite; import org.junit.runner.RunWith; import org.junit.runners.Suite; @@ -44,10 +41,5 @@ import org.junit.runners.Suite; /* Add your test class here */ }) -public class Suite_Remote_6_7 { - @BeforeClass - public static void beforeClassMethod() { - BaseTestCase.setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, - IGDBLaunchConfigurationConstants.DEBUGGER_MODE_REMOTE); - } +public class Suite_Remote_6_7 extends BaseRemoteSuite { } diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_8/Suite_Remote_6_8.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_8/Suite_Remote_6_8.java index 10bd4c72c06..286ad3e06dc 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_8/Suite_Remote_6_8.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_8/Suite_Remote_6_8.java @@ -10,11 +10,8 @@ *******************************************************************************/ package org.eclipse.cdt.tests.dsf.gdb.tests.tests_6_8; -import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; -import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants; import org.eclipse.cdt.dsf.mi.service.command.commands.Suite_Sessionless_Tests; -import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase; -import org.junit.BeforeClass; +import org.eclipse.cdt.tests.dsf.gdb.framework.BaseRemoteSuite; import org.junit.runner.RunWith; import org.junit.runners.Suite; @@ -44,10 +41,5 @@ import org.junit.runners.Suite; /* Add your test class here */ }) -public class Suite_Remote_6_8 { - @BeforeClass - public static void beforeClassMethod() { - BaseTestCase.setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, - IGDBLaunchConfigurationConstants.DEBUGGER_MODE_REMOTE); - } +public class Suite_Remote_6_8 extends BaseRemoteSuite { } diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/Suite_Remote_7_0.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/Suite_Remote_7_0.java index b0c14208037..3869ccee90d 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/Suite_Remote_7_0.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/Suite_Remote_7_0.java @@ -10,11 +10,8 @@ *******************************************************************************/ package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_0; -import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; -import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants; import org.eclipse.cdt.dsf.mi.service.command.commands.Suite_Sessionless_Tests; -import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase; -import org.junit.BeforeClass; +import org.eclipse.cdt.tests.dsf.gdb.framework.BaseRemoteSuite; import org.junit.runner.RunWith; import org.junit.runners.Suite; @@ -47,10 +44,5 @@ import org.junit.runners.Suite; /* Add your test class here */ }) -public class Suite_Remote_7_0 { - @BeforeClass - public static void beforeClassMethod() { - BaseTestCase.setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, - IGDBLaunchConfigurationConstants.DEBUGGER_MODE_REMOTE); - } +public class Suite_Remote_7_0 extends BaseRemoteSuite { } diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_1/Suite_Remote_7_1.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_1/Suite_Remote_7_1.java index b5ebedcc6ec..ac73aa23356 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_1/Suite_Remote_7_1.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_1/Suite_Remote_7_1.java @@ -10,11 +10,8 @@ *******************************************************************************/ package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_1; -import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; -import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants; import org.eclipse.cdt.dsf.mi.service.command.commands.Suite_Sessionless_Tests; -import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase; -import org.junit.BeforeClass; +import org.eclipse.cdt.tests.dsf.gdb.framework.BaseRemoteSuite; import org.junit.runner.RunWith; import org.junit.runners.Suite; @@ -47,10 +44,5 @@ import org.junit.runners.Suite; /* Add your test class here */ }) -public class Suite_Remote_7_1 { - @BeforeClass - public static void beforeClassMethod() { - BaseTestCase.setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, - IGDBLaunchConfigurationConstants.DEBUGGER_MODE_REMOTE); - } +public class Suite_Remote_7_1 extends BaseRemoteSuite { } diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_2/Suite_Remote_7_2.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_2/Suite_Remote_7_2.java index 32ee042ea23..48269bfc10b 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_2/Suite_Remote_7_2.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_2/Suite_Remote_7_2.java @@ -10,11 +10,8 @@ *******************************************************************************/ package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_2; -import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; -import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants; import org.eclipse.cdt.dsf.mi.service.command.commands.Suite_Sessionless_Tests; -import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase; -import org.junit.BeforeClass; +import org.eclipse.cdt.tests.dsf.gdb.framework.BaseRemoteSuite; import org.junit.runner.RunWith; import org.junit.runners.Suite; @@ -47,10 +44,5 @@ import org.junit.runners.Suite; /* Add your test class here */ }) -public class Suite_Remote_7_2 { - @BeforeClass - public static void beforeClassMethod() { - BaseTestCase.setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, - IGDBLaunchConfigurationConstants.DEBUGGER_MODE_REMOTE); - } +public class Suite_Remote_7_2 extends BaseRemoteSuite { } diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_3/Suite_Remote_7_3.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_3/Suite_Remote_7_3.java index 2f7f74edd9d..5baac54dcf3 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_3/Suite_Remote_7_3.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_3/Suite_Remote_7_3.java @@ -10,11 +10,8 @@ *******************************************************************************/ package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_3; -import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; -import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants; import org.eclipse.cdt.dsf.mi.service.command.commands.Suite_Sessionless_Tests; -import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase; -import org.junit.BeforeClass; +import org.eclipse.cdt.tests.dsf.gdb.framework.BaseRemoteSuite; import org.junit.runner.RunWith; import org.junit.runners.Suite; @@ -47,10 +44,5 @@ import org.junit.runners.Suite; /* Add your test class here */ }) -public class Suite_Remote_7_3 { - @BeforeClass - public static void beforeClassMethod() { - BaseTestCase.setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, - IGDBLaunchConfigurationConstants.DEBUGGER_MODE_REMOTE); - } +public class Suite_Remote_7_3 extends BaseRemoteSuite { }