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

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
This commit is contained in:
Jonah Graham 2018-03-19 11:09:23 +00:00
parent 9394a679c5
commit 4a447ce1a6
6 changed files with 34 additions and 3 deletions

View file

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

View file

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

View file

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

View file

@ -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();

View file

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

View file

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