1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

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
This commit is contained in:
Marc Khouzam 2014-12-23 09:45:24 -05:00
parent 355503f746
commit 77c0f78b4f

View file

@ -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