Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Khouzam2014-12-23 14:45:24 +0000
committerMarc Khouzam2014-12-23 15:58:53 +0000
commit77c0f78b4f096f4a662a1962354b05d574c6a87d (patch)
tree03027ae82cc662177ac81755b26b650b489e3e7a
parent355503f7469a4661dcd60da69d8118710cd7907f (diff)
downloadorg.eclipse.cdt-77c0f78b4f096f4a662a1962354b05d574c6a87d.tar.gz
org.eclipse.cdt-77c0f78b4f096f4a662a1962354b05d574c6a87d.tar.xz
org.eclipse.cdt-77c0f78b4f096f4a662a1962354b05d574c6a87d.zip
Bug 456083 - Wrong preference scope causes test dependencies
Change-Id: I36b91e6c0c8180919e033d7630db92f148b69214 Signed-off-by: Marc Khouzam <marc.khouzam@ericsson.com> Reviewed-on: https://git.eclipse.org/r/38721 Tested-by: Hudson CI
-rw-r--r--dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/OperationsWhileTargetIsRunningTest.java41
1 files changed, 27 insertions, 14 deletions
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 27bd146292..c1861ec3f9 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

Back to the top