1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-05 16:15:25 +02:00

Bug 378834 - Make register tests independent of the computer they are

run on.

Change-Id: Iac58e7517fa13d0fe2878ce22b9f1d423cdce73d
This commit is contained in:
Marc Khouzam 2013-01-13 22:02:59 -05:00
parent b2d04ae8ac
commit 0c5bb6307e
2 changed files with 35 additions and 44 deletions

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,11 +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.MIRegisters.MIRegisterDMC;
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;
@ -55,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;
@ -63,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");
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);
}
return list;
};
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;
}
/*
@ -190,12 +211,6 @@ public class MIRegistersTest extends BaseTestCase {
protected void handleCompleted() {
if (isSuccess()) {
fWait.setReturnInfo(getData());
// TODO Remove
for (IRegisterDMContext dmcr : getData()) {
System.out.print(((MIRegisterDMC)dmcr).getName()+",");
}
System.out.println();
// TODO Remove
}
fWait.waitFinished(getStatus());

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;
}
}