1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-06 09:16:02 +02:00

Bug 378834 - Update Debug JUnit tests to run on Hudson

Change-Id: Ie93ef3b2401b6823afd96504de1b5b5c577f1da4
Reviewed-on: https://git.eclipse.org/r/9656
Reviewed-by: Marc Khouzam <marc.khouzam@ericsson.com>
IP-Clean: Marc Khouzam <marc.khouzam@ericsson.com>
Tested-by: Marc Khouzam <marc.khouzam@ericsson.com>
This commit is contained in:
Marc Khouzam 2013-01-14 06:23:04 -05:00
parent 3222ba63ed
commit 9e6ee807a9
12 changed files with 117 additions and 69 deletions

View file

@ -9,9 +9,10 @@
# Wind River Systems - initial API and implementation
# IBM Corporation
###############################################################################
output.tests.jar = bin/
bin.includes = fragment.xml,\
META-INF/,\
.
.,\
data/,\
about.html
source.. = src/
src.includes = about.html

View file

@ -1,6 +1,6 @@
src = $(wildcard *.cc *.c)
destDir = ../bin
GCCFLAGS = -gdwarf-2 -pthread -m32
GCCFLAGS = -gdwarf-2 -pthread
all:
@mkdir -p $(destDir)

View file

@ -21,8 +21,8 @@ unsigned int __stdcall PrintHello(void *threadid)
void *PrintHello(void *threadid)
#endif
{
int tid = (int)threadid;
printf("Hello World! It's me, thread #%d!\n", tid);
long tid = (long)threadid;
printf("Hello World! It's me, thread #%ld!\n", tid);
SLEEP(2); // keep this thread around for a bit; the tests will check for its existence while the main thread is stopped at a breakpoint
#ifdef __MINGW32__

View file

@ -14,9 +14,9 @@ typedef pthread_t TID;
#endif
// Set a breakpoint here so that both threads stop.
void firstBreakpoint(int id)
void firstBreakpoint(long id)
{
printf("First breakpoint method from thread %d\n", id);
printf("First breakpoint method from thread %ld\n", id);
}
@ -26,7 +26,7 @@ unsigned int __stdcall PrintHello(void *threadid)
void *PrintHello(void *threadId)
#endif
{
int tId = (int)threadId;
long tId = (long)threadId;
firstBreakpoint(tId); // Stop a first time
SLEEP(1); // Keep state running a little

View file

@ -73,8 +73,8 @@ unsigned int __stdcall testTracepoints(void *threadid)
void *testTracepoints(void *threadid)
#endif
{
int tid = (int)threadid;
printf("Hello World! It's me, thread #%d!\n", tid);
long tid = (long)threadid;
printf("Hello World! It's me, thread #%ld!\n", tid);
int lIntVar = 12345;
double lDoubleVar = 12345.12345;

View file

@ -24,15 +24,53 @@
</repository>
</repositories>-->
<profiles>
<profile>
<id>production</id>
<properties>
<gdbPathOption>-Dcdt.tests.dsf.gdb.path=/opt/public/download-staging.priv/tools/cdt/gdb</gdbPathOption>
</properties>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>clean</id>
<phase>clean</phase>
<configuration>
<tasks>
<ant antfile="TestAppBuilder.xml" target="clean"/>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
<execution>
<id>prepare</id>
<phase>validate</phase>
<configuration>
<tasks>
<ant antfile="TestAppBuilder.xml" target="makeTestApps"/>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<useUIHarness>true</useUIHarness>
<argLine>-Xms256m -Xmx512m -XX:MaxPermSize=256M</argLine>
<argLine>-Xms256m -Xmx512m -XX:MaxPermSize=256M ${gdbPathOption}</argLine>
<includes>
<include>**/AutomatedSuite.*</include>
</includes>

View file

@ -21,6 +21,8 @@ import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.dsf.datamodel.IDMEvent;
import org.eclipse.cdt.dsf.debug.service.IRunControl.ISuspendedDMEvent;
import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants;
import org.eclipse.cdt.dsf.gdb.internal.GdbDebugOptions;
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch;
import org.eclipse.cdt.dsf.mi.service.command.events.IMIDMEvent;
import org.eclipse.cdt.dsf.mi.service.command.events.MIStoppedEvent;
@ -218,10 +220,10 @@ public class BaseTestCase {
protected void doLaunch() throws Exception {
boolean remote = launchAttributes.get(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE).equals(IGDBLaunchConfigurationConstants.DEBUGGER_MODE_REMOTE);
System.out.println("====================================================================================================");
System.out.println(String.format("Running test: %s using GDB: %s remote %s",
testName.getMethodName(), launchAttributes.get(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME), remote ? "on" : "off"));
System.out.println("====================================================================================================");
if(GdbDebugOptions.DEBUG) GdbDebugOptions.trace("===============================================================================================\n");
System.out.println(String.format("%s \"%s\" launching %s %s",
GdbPlugin.getDebugTime(), testName.getMethodName(), launchAttributes.get(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME), remote ? "with gdbserver" : ""));
if(GdbDebugOptions.DEBUG) GdbDebugOptions.trace("===============================================================================================\n");
boolean postMortemLaunch = launchAttributes.get(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE)
.equals(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE);
@ -320,7 +322,7 @@ public class BaseTestCase {
BufferedReader reader = new BufferedReader(r);
String line;
while ((line = reader.readLine()) != null) {
System.out.println(line);
if(GdbDebugOptions.DEBUG) GdbDebugOptions.trace(line + "\n");
line = line.trim();
if (line.startsWith("Listening on port")) {
break;
@ -351,8 +353,15 @@ public class BaseTestCase {
public static void setGdbProgramNamesLaunchAttributes(String version) {
// See bugzilla 303811 for why we have to append ".exe" on Windows
boolean isWindows = Platform.getOS().equals(Platform.OS_WIN32);
setGlobalLaunchAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME, "gdb." + version + (isWindows ? ".exe" : ""));
setGlobalLaunchAttribute(ATTR_DEBUG_SERVER_NAME, "gdbserver." + version + (isWindows ? ".exe" : ""));
String gdbPath = System.getProperty("cdt.tests.dsf.gdb.path");
String debugName = "gdb." + version + (isWindows ? ".exe" : "");
String debugServerName = "gdbserver." + version + (isWindows ? ".exe" : "");
if (gdbPath != null) {
debugName = gdbPath + "/" + debugName;
debugServerName = gdbPath + "/" + debugServerName;
}
setGlobalLaunchAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME, debugName);
setGlobalLaunchAttribute(ATTR_DEBUG_SERVER_NAME, debugServerName);
}
protected void setGdbVersion() {

View file

@ -10,7 +10,7 @@
*******************************************************************************/
package org.eclipse.cdt.tests.dsf.gdb.tests;
import org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_4.Suite_7_4;
import org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_5.Suite_7_5;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@ -21,7 +21,7 @@ import org.junit.runners.Suite;
@RunWith(Suite.class)
@Suite.SuiteClasses({
Suite_7_4.class,
Suite_7_5.class,
// Can't run the Remote test just yet because they
// have the same names on the local tests, which is
// not handled by JUnit (https://bugs.eclipse.org/172256)

View file

@ -37,7 +37,8 @@ import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMContex
import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMData;
import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext;
import org.eclipse.cdt.dsf.debug.service.IStack.IFrameDMContext;
import org.eclipse.cdt.dsf.internal.DsfPlugin;
import org.eclipse.cdt.dsf.gdb.internal.GdbDebugOptions;
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
import org.eclipse.cdt.dsf.mi.service.MIBreakpointDMData;
import org.eclipse.cdt.dsf.mi.service.MIBreakpoints;
import org.eclipse.cdt.dsf.mi.service.MIBreakpoints.MIBreakpointDMContext;
@ -240,7 +241,7 @@ public class MIBreakpointsTest extends BaseTestCase {
@DsfServiceEventHandler
public void eventDispatched(IBreakpointsAddedEvent e) {
synchronized (lock) {
System.out.println(DsfPlugin.getDebugTime() + " Got bp added event");
if(GdbDebugOptions.DEBUG) GdbDebugOptions.trace(GdbPlugin.getDebugTime() + " Got bp added event\n");
fBreakpointEvents[BP_ADDED]++;
fBreakpointEventCount++;
fBreakpointRef = ((MIBreakpointDMContext) e.getBreakpoints()[0]).getReference();
@ -251,7 +252,7 @@ public class MIBreakpointsTest extends BaseTestCase {
@DsfServiceEventHandler
public void eventDispatched(IBreakpointsUpdatedEvent e) {
synchronized (lock) {
System.out.println(DsfPlugin.getDebugTime() + " Got bp updated event");
if(GdbDebugOptions.DEBUG) GdbDebugOptions.trace(GdbPlugin.getDebugTime() + " Got bp updated event\n");
fBreakpointEvents[BP_UPDATED]++;
fBreakpointEventCount++;
fBreakpointRef = ((MIBreakpointDMContext) e.getBreakpoints()[0]).getReference();
@ -262,7 +263,7 @@ public class MIBreakpointsTest extends BaseTestCase {
@DsfServiceEventHandler
public void eventDispatched(IBreakpointsRemovedEvent e) {
synchronized (lock) {
System.out.println(DsfPlugin.getDebugTime() + " Got bp removed event");
if(GdbDebugOptions.DEBUG) GdbDebugOptions.trace(GdbPlugin.getDebugTime() + " Got bp removed event\n");
fBreakpointEvents[BP_REMOVED]++;
fBreakpointEventCount++;
fBreakpointRef = ((MIBreakpointDMContext) e.getBreakpoints()[0]).getReference();
@ -273,7 +274,7 @@ public class MIBreakpointsTest extends BaseTestCase {
@DsfServiceEventHandler
public void eventDispatched(MIBreakpointHitEvent e) {
synchronized (lock) {
System.out.println(DsfPlugin.getDebugTime() + " Got bp hit event");
if(GdbDebugOptions.DEBUG) GdbDebugOptions.trace(GdbPlugin.getDebugTime() + " Got bp hit event\n");
fBreakpointEvents[BP_HIT]++;
fBreakpointEventCount++;
fBreakpointRef = e.getNumber();
@ -284,7 +285,7 @@ public class MIBreakpointsTest extends BaseTestCase {
@DsfServiceEventHandler
public void eventDispatched(MIWatchpointTriggerEvent e) {
synchronized (lock) {
System.out.println(DsfPlugin.getDebugTime() + " Got wp hit event");
if(GdbDebugOptions.DEBUG) GdbDebugOptions.trace(GdbPlugin.getDebugTime() + " Got wp hit event\n");
fBreakpointEvents[WP_HIT]++;
fBreakpointEventCount++;
fBreakpointRef = e.getNumber();
@ -295,7 +296,7 @@ public class MIBreakpointsTest extends BaseTestCase {
@DsfServiceEventHandler
public void eventDispatched(MIWatchpointScopeEvent e) {
synchronized (lock) {
System.out.println(DsfPlugin.getDebugTime() + " Got wp scope event");
if(GdbDebugOptions.DEBUG) GdbDebugOptions.trace(GdbPlugin.getDebugTime() + " Got wp scope event\n");
fBreakpointEvents[WP_OOS]++;
fBreakpointEventCount++;
fBreakpointRef = e.getNumber();

View file

@ -43,7 +43,8 @@ import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMContex
import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMData;
import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext;
import org.eclipse.cdt.dsf.debug.service.IStack.IFrameDMContext;
import org.eclipse.cdt.dsf.internal.DsfPlugin;
import org.eclipse.cdt.dsf.gdb.internal.GdbDebugOptions;
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
import org.eclipse.cdt.dsf.mi.service.MIBreakpointDMData;
import org.eclipse.cdt.dsf.mi.service.MIBreakpoints;
import org.eclipse.cdt.dsf.mi.service.MIBreakpoints.MIBreakpointDMContext;
@ -225,7 +226,7 @@ public class MICatchpointsTest extends BaseTestCase {
synchronized (fEventHandlerLock) {
fBreakpointEvents[BP_ADDED]++;
fBreakpointRef = ((MIBreakpointDMContext) e.getBreakpoints()[0]).getReference();
System.out.println(DsfPlugin.getDebugTime() + " Got bp added event (#" + fBreakpointRef + ")");
if(GdbDebugOptions.DEBUG) GdbDebugOptions.trace(GdbPlugin.getDebugTime() + " Got bp added event (#" + fBreakpointRef + ")\n");
fEventHandlerLock.notifyAll();
}
}
@ -235,7 +236,7 @@ public class MICatchpointsTest extends BaseTestCase {
synchronized (fEventHandlerLock) {
fBreakpointEvents[BP_UPDATED]++;
fBreakpointRef = ((MIBreakpointDMContext) e.getBreakpoints()[0]).getReference();
System.out.println(DsfPlugin.getDebugTime() + " Got bp updated event (#" + fBreakpointRef + ")");
if(GdbDebugOptions.DEBUG) GdbDebugOptions.trace(GdbPlugin.getDebugTime() + " Got bp updated event (#" + fBreakpointRef + ")\n");
fEventHandlerLock.notifyAll();
}
}
@ -245,7 +246,7 @@ public class MICatchpointsTest extends BaseTestCase {
synchronized (fEventHandlerLock) {
fBreakpointEvents[BP_REMOVED]++;
fBreakpointRef = ((MIBreakpointDMContext) e.getBreakpoints()[0]).getReference();
System.out.println(DsfPlugin.getDebugTime() + " Got bp removed event (#" + fBreakpointRef + ")");
if(GdbDebugOptions.DEBUG) GdbDebugOptions.trace(GdbPlugin.getDebugTime() + " Got bp removed event (#" + fBreakpointRef + ")\n");
fEventHandlerLock.notifyAll();
}
}
@ -255,7 +256,7 @@ public class MICatchpointsTest extends BaseTestCase {
synchronized (fEventHandlerLock) {
fBreakpointEvents[BP_HIT]++;
fBreakpointRef = e.getNumber();
System.out.println(DsfPlugin.getDebugTime() + " Got bp hit event (#" + fBreakpointRef + ")");
if(GdbDebugOptions.DEBUG) GdbDebugOptions.trace(GdbPlugin.getDebugTime() + " Got bp hit event (#" + fBreakpointRef + ")\n");
fEventHandlerLock.notifyAll();
}
}

View file

@ -14,7 +14,6 @@ package org.eclipse.cdt.tests.dsf.gdb.tests;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
@ -43,10 +42,12 @@ import org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext;
import org.eclipse.cdt.dsf.debug.service.IRunControl.StepType;
import org.eclipse.cdt.dsf.debug.service.IStack.IFrameDMContext;
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService;
import org.eclipse.cdt.dsf.mi.service.IMICommandControl;
import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext;
import org.eclipse.cdt.dsf.mi.service.IMIProcesses;
import org.eclipse.cdt.dsf.mi.service.MIProcesses;
import org.eclipse.cdt.dsf.mi.service.command.events.MIStoppedEvent;
import org.eclipse.cdt.dsf.mi.service.command.output.MIDataListRegisterNamesInfo;
import org.eclipse.cdt.dsf.service.DsfServicesTracker;
import org.eclipse.cdt.dsf.service.DsfSession;
import org.eclipse.cdt.tests.dsf.gdb.framework.AsyncCompletionWaitor;
@ -54,7 +55,6 @@ import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase;
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.Assert;
import org.junit.Ignore;
import org.junit.Test;
@ -62,18 +62,40 @@ import org.junit.runner.RunWith;
@RunWith(BackgroundRunner.class)
public class MIRegistersTest extends BaseTestCase {
// Static list of register names as obtained directly from GDB.
// We make it static it does not get re-set for every test
protected static List<String> fRegisterNames = null;
protected List<String> get_X86_REGS() {
List<String> list = new LinkedList<String>(Arrays.asList("eax","ecx","edx","ebx","esp","ebp","esi","edi","eip","eflags",
"cs","ss","ds","es","fs","gs","st0","st1","st2","st3",
"st4","st5","st6","st7","fctrl","fstat","ftag","fiseg","fioff","foseg",
"fooff","fop","xmm0","xmm1","xmm2","xmm3","xmm4","xmm5","xmm6","xmm7",
"mxcsr","orig_eax","mm0","mm1","mm2","mm3","mm4","mm5","mm6","mm7"));
// On Windows, gdb doesn't report "orig_eax" as a register. Apparently it does on Linux
if (Platform.getOS().equals(Platform.OS_WIN32)) {
list.remove("orig_eax");
}
return list;
protected List<String> get_X86_REGS() throws Throwable {
if (fRegisterNames == null) {
// The tests must run on different machines, so the set of registers can change.
// To deal with this we ask GDB for the list of registers.
// Note that we send an MI Command in this code and do not use the IRegister service;
// this is because we want to test the service later, comparing it to what we find
// by asking GDB directly.
Query<MIDataListRegisterNamesInfo> query = new Query<MIDataListRegisterNamesInfo>() {
@Override
protected void execute(DataRequestMonitor<MIDataListRegisterNamesInfo> rm) {
IMICommandControl controlService = fServicesTracker.getService(IMICommandControl.class);
controlService.queueCommand(
controlService.getCommandFactory().createMIDataListRegisterNames(fContainerDmc), rm);
}
};
fSession.getExecutor().execute(query);
MIDataListRegisterNamesInfo data = query.get();
String[] names = data.getRegisterNames();
// Remove registers with empty names since the service also
// remove them. I don't know why GDB returns such empty names.
fRegisterNames = new LinkedList<String>();
for (String name : names) {
if (!name.isEmpty()) {
fRegisterNames.add(name);
}
}
}
return fRegisterNames;
}
/*

View file

@ -10,14 +10,9 @@
*******************************************************************************/
package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_2;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
import org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_1.MIRegistersTest_7_1;
import org.eclipse.core.runtime.Platform;
import org.junit.runner.RunWith;
@RunWith(BackgroundRunner.class)
@ -26,23 +21,4 @@ public class MIRegistersTest_7_2 extends MIRegistersTest_7_1 {
protected void setGdbVersion() {
setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_2);
}
// GDB's list of registers is different with GDB 7.2
@Override
protected List<String> get_X86_REGS() {
List<String> list = new LinkedList<String>(Arrays.asList("eax","ecx","edx","ebx","esp","ebp","esi","edi","eip","eflags",
"cs","ss","ds","es","fs","gs","st0","st1","st2","st3",
"st4","st5","st6","st7","fctrl","fstat","ftag","fiseg","fioff","foseg",
"fooff","fop","xmm0","xmm1","xmm2","xmm3","xmm4","xmm5","xmm6","xmm7",
"mxcsr",/*"","","","","","","","",*/"orig_eax",
"al","cl","dl","bl","ah","ch","dh","bh","ax","cx",
"dx","bx",/*"",*/"bp","si","di","mm0","mm1","mm2","mm3",
"mm4","mm5","mm6","mm7"));
// On Windows, gdb doesn't report "orig_eax" as a register. Apparently it does on Linux
if (Platform.getOS().equals(Platform.OS_WIN32)) {
list.remove("orig_eax");
}
return list;
}
}