diff options
author | Jonah Graham | 2018-03-19 11:09:23 +0000 |
---|---|---|
committer | Jonah Graham | 2018-03-19 12:13:20 +0000 |
commit | 4a447ce1a6dbd59000293810eddd75bac33f6f10 (patch) | |
tree | d1961d4b00d6dbf7c16efa8163a70a5a1af78bf7 | |
parent | 9394a679c5a28f69590c39e18e74405294de66c9 (diff) | |
download | org.eclipse.cdt-4a447ce1a6dbd59000293810eddd75bac33f6f10.tar.gz org.eclipse.cdt-4a447ce1a6dbd59000293810eddd75bac33f6f10.tar.xz org.eclipse.cdt-4a447ce1a6dbd59000293810eddd75bac33f6f10.zip |
Bug 532592: [tests] properly exclude non-remote tests
This includes changing BaseParametrizedTestCase.remote to be a
Boolean so that users of remote before it is initialzed causes
an NPE. For example, GDBRemoteTracepointsTest was never running
because of this logic error.
Change-Id: I3fb46fd67c554af7ec912f175815165533021a1b
6 files changed, 34 insertions, 3 deletions
diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/BaseParametrizedTestCase.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/BaseParametrizedTestCase.java index 242be8406e0..7568bb99e6d 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/BaseParametrizedTestCase.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/BaseParametrizedTestCase.java @@ -41,7 +41,7 @@ public abstract class BaseParametrizedTestCase extends BaseTestCase { @Parameter public String parameter; // other fields private String gdbVersionPostfix; // this is how we want to invoke it - protected boolean remote; // this is if we want remote tests (gdbserver) + protected Boolean remote; // this is if we want remote tests (gdbserver) -- it is null until we have made the determination protected static List<String> calculateVersions() { if (globalVersion != null) { @@ -142,6 +142,30 @@ public abstract class BaseParametrizedTestCase extends BaseTestCase { return LaunchUtils.compareVersions(checkVersion, gdbVersion) <= 0; } + /** + * Assumption to make sure test only runs on remote test session. + * + * This method is better than {@link #isRemoteSession()} as it can be called + * at any time and does not require launch attributes to be set-up + */ + public void assumeRemoteSession() { + // remote is calculated as side-effect of parsing GDB version parameters + getGdbVersionParameter(); + Assume.assumeTrue("Skipping non-remote tests", remote); + } + + /** + * Assumption to make sure test only runs on non-remote test session. + * + * This method is better than {@link #isRemoteSession()} as it can be called + * at any time and does not require launch attributes to be set-up + */ + public void assumeLocalSession() { + // remote is calculated as side-effect of parsing GDB version parameters + getGdbVersionParameter(); + Assume.assumeFalse("Skipping remote tests", remote); + } + public void assumeGdbVersionAtLeast(String checkVersion) { String gdbVersion = getGdbVersion(); if (gdbVersion == GDB_NOT_FOUND) { 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 40695521447..f9ec5b1dd13 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 @@ -176,6 +176,11 @@ public class BaseTestCase { public synchronized MIStoppedEvent getInitialStoppedEvent() { return fInitialStoppedEvent; } + /** + * Return whether this is a remote session. + * + * WARNING: This method must only be called after launch attributes are initialized. + */ public boolean isRemoteSession() { return launchAttributes.get(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE) .equals(IGDBLaunchConfigurationConstants.DEBUGGER_MODE_REMOTE); diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/CommandLineArgsTest.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/CommandLineArgsTest.java index fc2983d237e..098dcb38dc4 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/CommandLineArgsTest.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/CommandLineArgsTest.java @@ -50,6 +50,7 @@ public class CommandLineArgsTest extends BaseParametrizedTestCase { @Override public void doBeforeTest() throws Exception { + assumeLocalSession(); removeTeminatedLaunchesBeforeTest(); setLaunchAttributes(); // Can't run the launch right away because each test needs to first set diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/GDBRemoteTracepointsTest.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/GDBRemoteTracepointsTest.java index b0631a6125c..f68ace839c7 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/GDBRemoteTracepointsTest.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/GDBRemoteTracepointsTest.java @@ -45,7 +45,6 @@ import org.eclipse.cdt.tests.dsf.gdb.framework.BaseParametrizedTestCase; import org.eclipse.cdt.tests.dsf.gdb.framework.SyncUtil; import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin; import org.eclipse.core.runtime.Platform; -import org.junit.Assume; import org.junit.BeforeClass; import org.junit.Ignore; import org.junit.Test; @@ -150,7 +149,7 @@ public class GDBRemoteTracepointsTest extends BaseParametrizedTestCase { @Override public void doBeforeTest() throws Exception { - Assume.assumeTrue("Skipping non-remote", remote); + assumeRemoteSession(); super.doBeforeTest(); fSession = getGDBLaunch().getSession(); diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/LaunchConfigurationAndRestartTest.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/LaunchConfigurationAndRestartTest.java index 57f0e7f4159..0f1c0c26517 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/LaunchConfigurationAndRestartTest.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/LaunchConfigurationAndRestartTest.java @@ -96,6 +96,7 @@ public class LaunchConfigurationAndRestartTest extends BaseParametrizedTestCase @Override public void doBeforeTest() throws Exception { + assumeLocalSession(); removeTeminatedLaunchesBeforeTest(); setLaunchAttributes(); // Can't run the launch right away because each test needs to first set some diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/PostMortemCoreTest.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/PostMortemCoreTest.java index caea8e3412b..05e011042bb 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/PostMortemCoreTest.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/PostMortemCoreTest.java @@ -70,6 +70,7 @@ public class PostMortemCoreTest extends BaseParametrizedTestCase { @Override public void doBeforeTest() throws Exception { + assumeLocalSession(); removeTeminatedLaunchesBeforeTest(); setLaunchAttributes(); // Can't run the launch right away because each test needs to first set some |