diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/OperationsWhileTargetIsRunningTest.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/OperationsWhileTargetIsRunningTest.java index 27bd1462920..c1861ec3f9e 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/OperationsWhileTargetIsRunningTest.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/OperationsWhileTargetIsRunningTest.java @@ -37,8 +37,11 @@ import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase; import org.eclipse.cdt.tests.dsf.gdb.framework.ServiceEventWaitor; import org.eclipse.cdt.tests.dsf.gdb.framework.SyncUtil; import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin; -import org.eclipse.core.runtime.preferences.DefaultScope; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.preferences.IEclipsePreferences; +import org.eclipse.core.runtime.preferences.InstanceScope; import org.junit.Assert; +import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; import org.osgi.service.prefs.Preferences; @@ -58,15 +61,21 @@ public class OperationsWhileTargetIsRunningTest extends BaseTestCase { private IMIContainerDMContext fContainerDmc; private IGDBControl fControl; - /* - * Path to executable - */ private static final String EXEC_PATH = "data/launch/bin/"; - /* - * Name of the executable - */ private static final String EXEC_NAME = "TargetAvail.exe"; - + + private static boolean fgAutoTerminate; + + @BeforeClass + public static void doBeforeClass() throws Exception { + // Save the original values of the preferences used in this class + fgAutoTerminate = Platform.getPreferencesService().getBoolean( + GdbPlugin.PLUGIN_ID, + IGdbDebugPreferenceConstants.PREF_AUTO_TERMINATE_GDB, + true, + null ); + } + @Override public void doBeforeTest() throws Exception { super.doBeforeTest(); @@ -96,6 +105,10 @@ public class OperationsWhileTargetIsRunningTest extends BaseTestCase { super.doAfterTest(); fServicesTracker.dispose(); + + // Restore the different preferences we might have changed + IEclipsePreferences node = InstanceScope.INSTANCE.getNode( GdbPlugin.PLUGIN_ID ); + node.putBoolean( IGdbDebugPreferenceConstants.PREF_AUTO_TERMINATE_GDB, fgAutoTerminate ); } @Override @@ -120,7 +133,7 @@ public class OperationsWhileTargetIsRunningTest extends BaseTestCase { } // First set the preference to kill GDB (although it should not happen in this test) - Preferences node = DefaultScope.INSTANCE.getNode(GdbPlugin.PLUGIN_ID); + Preferences node = InstanceScope.INSTANCE.getNode(GdbPlugin.PLUGIN_ID); node.putBoolean(IGdbDebugPreferenceConstants.PREF_AUTO_TERMINATE_GDB, true); // The target is currently stopped. We resume to get it running @@ -150,7 +163,7 @@ public class OperationsWhileTargetIsRunningTest extends BaseTestCase { } // First set the preference not to kill gdb - Preferences node = DefaultScope.INSTANCE.getNode(GdbPlugin.PLUGIN_ID); + Preferences node = InstanceScope.INSTANCE.getNode(GdbPlugin.PLUGIN_ID); node.putBoolean(IGdbDebugPreferenceConstants.PREF_AUTO_TERMINATE_GDB, false); // The target is currently stopped. We resume to get it running @@ -173,7 +186,7 @@ public class OperationsWhileTargetIsRunningTest extends BaseTestCase { @Test public void terminateWhileTargetRunningKillGDB() throws Throwable { // First set the preference to kill GDB - Preferences node = DefaultScope.INSTANCE.getNode(GdbPlugin.PLUGIN_ID); + Preferences node = InstanceScope.INSTANCE.getNode(GdbPlugin.PLUGIN_ID); node.putBoolean(IGdbDebugPreferenceConstants.PREF_AUTO_TERMINATE_GDB, true); // The target is currently stopped. We resume to get it running @@ -211,7 +224,7 @@ public class OperationsWhileTargetIsRunningTest extends BaseTestCase { @Test public void terminateWhileTargetRunningKeepGDBAlive() throws Throwable { // First set the preference not to kill gdb - Preferences node = DefaultScope.INSTANCE.getNode(GdbPlugin.PLUGIN_ID); + Preferences node = InstanceScope.INSTANCE.getNode(GdbPlugin.PLUGIN_ID); node.putBoolean(IGdbDebugPreferenceConstants.PREF_AUTO_TERMINATE_GDB, false); // The target is currently stopped. We resume to get it running @@ -263,7 +276,7 @@ public class OperationsWhileTargetIsRunningTest extends BaseTestCase { @Test public void detachWhileTargetRunningKillGDB() throws Throwable { // First set the preference to kill GDB - Preferences node = DefaultScope.INSTANCE.getNode(GdbPlugin.PLUGIN_ID); + Preferences node = InstanceScope.INSTANCE.getNode(GdbPlugin.PLUGIN_ID); node.putBoolean(IGdbDebugPreferenceConstants.PREF_AUTO_TERMINATE_GDB, true); // The target is currently stopped. We resume to get it running @@ -300,7 +313,7 @@ public class OperationsWhileTargetIsRunningTest extends BaseTestCase { @Test public void detachWhileTargetRunningGDBAlive() throws Throwable { // First set the preference not to kill gdb - Preferences node = DefaultScope.INSTANCE.getNode(GdbPlugin.PLUGIN_ID); + Preferences node = InstanceScope.INSTANCE.getNode(GdbPlugin.PLUGIN_ID); node.putBoolean(IGdbDebugPreferenceConstants.PREF_AUTO_TERMINATE_GDB, false); // The target is currently stopped. We resume to get it running