Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPawel Piech2012-06-13 15:27:57 +0000
committerEugene Tarassov2012-06-14 21:45:02 +0000
commit5f0f2f1290a8a192bb72f1e19f9147cedf38a3e8 (patch)
tree6c5af825ab11f04f437ad585e1d9ed6742ad128a /tests/plugins
parentf3ee64e04546eeab10a5ccb52b0c3c086953e101 (diff)
downloadorg.eclipse.tcf-5f0f2f1290a8a192bb72f1e19f9147cedf38a3e8.tar.gz
org.eclipse.tcf-5f0f2f1290a8a192bb72f1e19f9147cedf38a3e8.tar.xz
org.eclipse.tcf-5f0f2f1290a8a192bb72f1e19f9147cedf38a3e8.zip
Bug 381993 - [breakpoints] Add a detail pane in breakpoints view to show breakpoints' scope setting
Added unit tests for basic operation.
Diffstat (limited to 'tests/plugins')
-rw-r--r--tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/AbstractTcfUITest.java91
-rw-r--r--tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/BreakpointDetailPaneTest.java169
-rw-r--r--tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/BreakpointsTest.java12
-rw-r--r--tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/SampleTest.java122
-rw-r--r--tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/TestProcessInfo.java37
-rw-r--r--tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/ViewerUpdatesListener.java34
-rw-r--r--tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/VirtualViewerUpdatesListener.java65
-rw-r--r--tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/ProcessesCM.java99
8 files changed, 469 insertions, 160 deletions
diff --git a/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/AbstractTcfUITest.java b/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/AbstractTcfUITest.java
index f32988ca3..f07031ede 100644
--- a/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/AbstractTcfUITest.java
+++ b/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/AbstractTcfUITest.java
@@ -51,6 +51,7 @@ import org.eclipse.swt.widgets.Display;
import org.eclipse.tcf.debug.test.services.BreakpointsCM;
import org.eclipse.tcf.debug.test.services.DiagnosticsCM;
import org.eclipse.tcf.debug.test.services.LineNumbersCM;
+import org.eclipse.tcf.debug.test.services.ProcessesCM;
import org.eclipse.tcf.debug.test.services.RegistersCM;
import org.eclipse.tcf.debug.test.services.RunControlCM;
import org.eclipse.tcf.debug.test.services.RunControlCM.ContextState;
@@ -76,6 +77,7 @@ import org.eclipse.tcf.services.IDiagnostics.ISymbol;
import org.eclipse.tcf.services.IExpressions;
import org.eclipse.tcf.services.ILineNumbers;
import org.eclipse.tcf.services.IMemoryMap;
+import org.eclipse.tcf.services.IProcesses;
import org.eclipse.tcf.services.IRegisters;
import org.eclipse.tcf.services.IRegisters.RegistersContext;
import org.eclipse.tcf.services.IRunControl;
@@ -122,6 +124,7 @@ public abstract class AbstractTcfUITest extends TcfTestCase implements IViewerUp
protected IMemoryMap fMemoryMap;
protected ILineNumbers fLineNumbers;
protected IRegisters fRegisters;
+ protected IProcesses fProcesses;
protected RunControlCM fRunControlCM;
protected DiagnosticsCM fDiagnosticsCM;
@@ -130,11 +133,8 @@ public abstract class AbstractTcfUITest extends TcfTestCase implements IViewerUp
protected SymbolsCM fSymbolsCM;
protected LineNumbersCM fLineNumbersCM;
protected RegistersCM fRegistersCM;
- protected String fTestId;
- protected RunControlContext fTestCtx;
- protected String fProcessId = "";
- protected String fThreadId = "";
- protected RunControlContext fThreadCtx;
+ protected ProcessesCM fProcessesCM;
+
/* (non-Javadoc)
* @see org.eclipse.tcf.te.tests.CoreTestCase#getTestBundle()
@@ -245,9 +245,11 @@ public abstract class AbstractTcfUITest extends TcfTestCase implements IViewerUp
fSymbolsCM = new SymbolsCM(syms, fRunControlCM, fMemoryMap);
fLineNumbersCM = new LineNumbersCM(fLineNumbers, fMemoryMap, fRunControlCM);
fRegistersCM = new RegistersCM(fRegisters, rc);
+ fProcessesCM = new ProcessesCM(fProcesses);
}
protected void tearDownServiceListeners() throws Exception{
+ fProcessesCM.dispose();
fRegistersCM.dispose();
fSymbolsCM.dispose();
fBreakpointsCM.dispose();
@@ -369,6 +371,7 @@ public abstract class AbstractTcfUITest extends TcfTestCase implements IViewerUp
fMemoryMap = channels[0].getRemoteService(IMemoryMap.class);
fLineNumbers = channels[0].getRemoteService(ILineNumbers.class);
fRegisters = channels[0].getRemoteService(IRegisters.class);
+ fProcesses = channels[0].getRemoteService(IProcesses.class);
};
});
}
@@ -541,40 +544,42 @@ public abstract class AbstractTcfUITest extends TcfTestCase implements IViewerUp
}.get();
}
- private void startProcess() throws InterruptedException, ExecutionException {
- new Transaction<Object>() {
+ private TestProcessInfo startProcess() throws InterruptedException, ExecutionException {
+ return new Transaction<TestProcessInfo>() {
@Override
- protected Object process() throws Transaction.InvalidCacheException ,ExecutionException {
- fTestId = validate( fDiagnosticsCM.runTest(getDiagnosticsTestName(), this) );
- fTestCtx = validate( fRunControlCM.getContext(fTestId) );
- fProcessId = fTestCtx.getProcessID();
+ protected TestProcessInfo process() throws Transaction.InvalidCacheException ,ExecutionException {
+ String testId = validate( fDiagnosticsCM.runTest(getDiagnosticsTestName(), this) );
+ RunControlContext testCtx = validate( fRunControlCM.getContext(testId) );
+ String processId = testCtx.getProcessID();
// Create the cache to listen for exceptions.
- fRunControlCM.waitForContextException(fTestId, fTestRunKey);
+ fRunControlCM.waitForContextException(testId, fTestRunKey);
- if (!fProcessId.equals(fTestId)) {
- fThreadId = fTestId;
+ String threadId = "";
+ if (!processId.equals(testId)) {
+ threadId = testId;
} else {
- String[] threads = validate( fRunControlCM.getChildren(fProcessId) );
- fThreadId = threads[0];
+ String[] threads = validate( fRunControlCM.getChildren(processId) );
+ threadId = threads[0];
}
- fThreadCtx = validate( fRunControlCM.getContext(fThreadId) );
+ RunControlContext threadCtx = validate( fRunControlCM.getContext(threadId) );
- Assert.assertTrue("Invalid thread context", fThreadCtx.hasState());
- return new Object();
+ Assert.assertTrue("Invalid thread context", threadCtx.hasState());
+
+ return new TestProcessInfo(testId, testCtx, processId, threadId, threadCtx);
};
}.get();
}
- private boolean runToTestEntry(final String testFunc) throws InterruptedException, ExecutionException {
+ private boolean runToTestEntry(final TestProcessInfo processInfo, final String testFunc) throws InterruptedException, ExecutionException {
return new Transaction<Boolean>() {
Object fWaitForResumeKey;
Object fWaitForSuspendKey;
boolean fSuspendEventReceived = false;
@Override
protected Boolean process() throws Transaction.InvalidCacheException ,ExecutionException {
- ISymbol sym_func0 = validate( fDiagnosticsCM.getSymbol(fProcessId, testFunc) );
+ ISymbol sym_func0 = validate( fDiagnosticsCM.getSymbol(processInfo.fProcessId, testFunc) );
String sym_func0_value = sym_func0.getValue().toString();
- ContextState state = validate (fRunControlCM.getState(fThreadId));
+ ContextState state = validate (fRunControlCM.getState(processInfo.fThreadId));
while (!state.suspended || !new BigInteger(state.pc).equals(new BigInteger(sym_func0_value))) {
if (state.suspended && fWaitForSuspendKey == null) {
@@ -582,24 +587,24 @@ public abstract class AbstractTcfUITest extends TcfTestCase implements IViewerUp
// We are not at test entry. Create a new suspend wait cache.
fWaitForResumeKey = new Object();
fWaitForSuspendKey = new Object();
- ICache<Object> waitForResume = fRunControlCM.waitForContextResumed(fThreadId, fWaitForResumeKey);
+ ICache<Object> waitForResume = fRunControlCM.waitForContextResumed(processInfo.fThreadId, fWaitForResumeKey);
// Issue resume command.
- validate( fRunControlCM.resume(fThreadCtx, fWaitForResumeKey, IRunControl.RM_RESUME, 1) );
+ validate( fRunControlCM.resume(processInfo.fThreadCtx, fWaitForResumeKey, IRunControl.RM_RESUME, 1) );
// Wait until we receive the resume event.
validate(waitForResume);
fWaitForSuspendKey = new Object();
- fRunControlCM.waitForContextSuspended(fThreadId, fWaitForSuspendKey);
+ fRunControlCM.waitForContextSuspended(processInfo.fThreadId, fWaitForSuspendKey);
} else {
if (fWaitForResumeKey != null) {
// Validate resume command
- validate( fRunControlCM.resume(fThreadCtx, fWaitForResumeKey, IRunControl.RM_RESUME, 1) );
+ validate( fRunControlCM.resume(processInfo.fThreadCtx, fWaitForResumeKey, IRunControl.RM_RESUME, 1) );
fWaitForResumeKey = null;
}
// Wait until we suspend.
- validate( fRunControlCM.waitForContextSuspended(fThreadId, fWaitForSuspendKey) );
+ validate( fRunControlCM.waitForContextSuspended(processInfo.fThreadId, fWaitForSuspendKey) );
fWaitForSuspendKey = null;
}
}
@@ -609,37 +614,38 @@ public abstract class AbstractTcfUITest extends TcfTestCase implements IViewerUp
}.get();
}
- protected void initProcessModel(String testFunc) throws Exception {
+ protected TestProcessInfo initProcessModel(String testFunc) throws Exception {
String bpId = "entryPointBreakpoint";
createBreakpoint(bpId, testFunc);
fDebugViewListener.reset();
+ final TestProcessInfo processInfo = startProcess();
+
ITCFObject processTCFContext = new ITCFObject() {
- public String getID() { return fProcessId; }
+ public String getID() { return processInfo.fProcessId; }
public IChannel getChannel() { return channels[0]; }
};
ITCFObject threadTCFContext = new ITCFObject() {
- public String getID() { return fThreadId; }
+ public String getID() { return processInfo.fThreadId; }
public IChannel getChannel() { return channels[0]; }
};
fDebugViewListener.addLabelUpdate(new TreePath(new Object[] { fLaunch, processTCFContext }));
fDebugViewListener.addLabelUpdate(new TreePath(new Object[] { fLaunch, processTCFContext, threadTCFContext }));
- startProcess();
// Make sure that delta is posted after launching process so that it doesn't interfere
// with the waiting for the whole viewer to update after breakpoint hit (below).
fDebugViewListener.waitTillFinished(MODEL_CHANGED_COMPLETE);
fDebugViewListener.resetModelChanged();
- runToTestEntry(testFunc);
+ runToTestEntry(processInfo, testFunc);
removeBreakpoint(bpId);
final String topFrameId = new Transaction<String>() {
@Override
protected String process() throws InvalidCacheException, ExecutionException {
- String[] frameIds = validate( fStackTraceCM.getChildren(fThreadId) );
+ String[] frameIds = validate( fStackTraceCM.getChildren(processInfo.fThreadId) );
Assert.assertTrue("No stack frames" , frameIds.length != 0);
return frameIds[frameIds.length - 1];
}
@@ -652,6 +658,14 @@ public abstract class AbstractTcfUITest extends TcfTestCase implements IViewerUp
fDebugViewListener.addLabelUpdate(new TreePath(new Object[] { fLaunch, processTCFContext, threadTCFContext, frameTCFContext }));
fDebugViewListener.waitTillFinished(MODEL_CHANGED_COMPLETE | CONTENT_SEQUENCE_COMPLETE | LABEL_SEQUENCE_COMPLETE | LABEL_UPDATES);
+
+ VirtualItem topFrameItem = fDebugViewListener.findElement(
+ new Pattern[] { Pattern.compile(".*"), Pattern.compile(".*"), Pattern.compile(".*" + processInfo.fProcessId + ".*\\(Breakpoint.*"), Pattern.compile(".*")});
+ if (topFrameItem == null) {
+ Assert.fail("Top stack frame not found. \n\nDebug view dump: \n:" + fDebugViewViewer.toString());
+ }
+
+ return processInfo;
}
protected ContextState resumeAndWaitForSuspend(final RunControlContext context, final int mode) throws InterruptedException, ExecutionException {
@@ -666,7 +680,9 @@ public abstract class AbstractTcfUITest extends TcfTestCase implements IViewerUp
}.get();
}
- protected void createBreakpoint(final String bpId, final String testFunc) throws InterruptedException, ExecutionException {
+ protected void createBreakpoint(final String bpId, final String testFunc)
+ throws InterruptedException, ExecutionException
+ {
new Transaction<Object>() {
private Map<String,Object> fBp;
{
@@ -691,13 +707,14 @@ public abstract class AbstractTcfUITest extends TcfTestCase implements IViewerUp
Assert.fail("Invalid BP status: " + s);
}
@SuppressWarnings("unchecked")
- Collection<Map<String,Object>> list = (Collection<Map<String,Object>>)status.get(IBreakpoints.STATUS_INSTANCES);
+ Collection<Map<String,Object>> list =
+ (Collection<Map<String,Object>>)status.get(IBreakpoints.STATUS_INSTANCES);
if (list != null) {
String err = null;
for (Map<String,Object> map : list) {
- String ctx = (String)map.get(IBreakpoints.INSTANCE_CONTEXT);
- if (fProcessId.equals(ctx) && map.get(IBreakpoints.INSTANCE_ERROR) != null)
+ if (map.get(IBreakpoints.INSTANCE_ERROR) != null) {
err = (String)map.get(IBreakpoints.INSTANCE_ERROR);
+ }
}
if (err != null) {
Assert.fail("Invalid BP status: " + s);
diff --git a/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/BreakpointDetailPaneTest.java b/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/BreakpointDetailPaneTest.java
index b27dd9658..6c66101d2 100644
--- a/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/BreakpointDetailPaneTest.java
+++ b/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/BreakpointDetailPaneTest.java
@@ -9,8 +9,12 @@
*******************************************************************************/
package org.eclipse.tcf.debug.test;
+import java.util.Set;
+import java.util.TreeSet;
import java.util.regex.Pattern;
+import junit.framework.AssertionFailedError;
+
import org.eclipse.debug.internal.ui.viewers.model.provisional.PresentationContext;
import org.eclipse.debug.internal.ui.viewers.model.provisional.VirtualItem;
import org.eclipse.debug.internal.ui.viewers.model.provisional.VirtualTreeModelViewer;
@@ -68,23 +72,160 @@ public class BreakpointDetailPaneTest extends AbstractTcfUITest
super.tearDown();
}
- public void testContextAddedOnLineBrakpointCreate() throws Exception {
- initProcessModel("tcf_test_func0");
+ public void testContextQueryFilter() throws Exception {
+ final TestProcessInfo processInfo1 = initProcessModel("tcf_test_func0");
+ final TestProcessInfo processInfo2 = initProcessModel("tcf_test_func0");
- final String query = "pid="+fProcessId;
-
- fContextQueryViewListener.reset();
- Display.getDefault().syncExec(new Runnable() { public void run() {
- fContextQueryViewViewer.setAutoExpandLevel(-1);
- fContextQueryViewViewer.setInput(new ScopeDetailInputObject(new ContextQueryElement(query, null)));
- }});
- fContextQueryViewListener.waitTillFinished(CONTENT_SEQUENCE_COMPLETE | LABEL_UPDATES_RUNNING);
-
- VirtualItem scopeItem = fContextQueryViewListener.findElement(new Pattern[] { Pattern.compile(".*pid\\="+fProcessId+"*.") });
- if (scopeItem == null) {
- Assert.fail("Scope item not found. \n\nContext query view dump: \n:" + fContextQueryViewViewer.toString());
+ // Note: run control prefixes process ID with a "P", but the
+ // filter expects the ID without the "P".
+ String processId1 = processInfo1.fProcessId;
+ if (processId1.startsWith("P")) processId1 = processId1.substring(1);
+ final String queryPid1 = "pid=" + processId1;
+
+ try {
+ fContextQueryViewListener.reset();
+ Display.getDefault().syncExec(new Runnable() { public void run() {
+ fContextQueryViewViewer.setAutoExpandLevel(-1);
+ fContextQueryViewViewer.setInput(new ScopeDetailInputObject(new ContextQueryElement(queryPid1, null)));
+ fContextQueryViewViewer.getPresentationContext().setProperty(ITCFDebugUIConstants.PROP_CONTEXT_QUERY, queryPid1);
+ }});
+ fContextQueryViewListener.waitTillFinished(CONTENT_SEQUENCE_COMPLETE | LABEL_UPDATES_RUNNING);
+
+ VirtualItem scopeItem = fContextQueryViewListener.findElement(new Pattern[] { Pattern.compile(".*pid\\="+processInfo1.fProcessId+".*") });
+ scopeItem = fContextQueryViewListener.findElement(new Pattern[] {
+ Pattern.compile(escapeBrackets("(2) Filter: " + queryPid1)), // filter name
+ Pattern.compile(escapeBrackets("(2) test.*")), // launch
+ Pattern.compile(escapeBrackets("(1).*agent.*")), // process name
+ Pattern.compile(".*" + processInfo1.fThreadId+".*") }); // thread
+
+ Assert.assertTrue(scopeItem != null);
+
+ fContextQueryViewListener.reset();
+ //fContextQueryViewListener.waitTillFinished(MODEL_CHANGED_COMPLETE | CONTENT_SEQUENCE_COMPLETE | LABEL_UPDATES_RUNNING);
+
+ // Check that second process is filtered out.
+ scopeItem = fContextQueryViewListener.findElement(new Pattern[] {
+ Pattern.compile("\\([0-9]+\\) Filter: " + queryPid1), // filter name
+ Pattern.compile("\\([0-9]+\\) test.*"), // launch
+ Pattern.compile("\\([0-9]+\\) .*agent.*"), // process name
+ Pattern.compile(".*"+processInfo2.fThreadId+".*") }); // thread
+ Assert.assertTrue(scopeItem == null);
+ scopeItem = fContextQueryViewListener.findElement(new Pattern[] { Pattern.compile(".*pid\\="+processInfo2.fProcessId+".*") });
+ Assert.assertTrue(scopeItem == null);
+
+ // Allprocesses in query
+
+// TODO: need a filter that will match all
+
+// fContextQueryViewListener.reset();
+// final String queryPidAll = "KernelName=Linux";
+// Display.getDefault().syncExec(new Runnable() { public void run() {
+// fContextQueryViewViewer.setInput(new ScopeDetailInputObject(new ContextQueryElement(queryPidAll, null)));
+// fContextQueryViewViewer.getPresentationContext().setProperty(ITCFDebugUIConstants.PROP_CONTEXT_QUERY, queryPidAll);
+// }});
+// fContextQueryViewListener.waitTillFinished(CONTENT_SEQUENCE_COMPLETE | LABEL_UPDATES_RUNNING);
+//
+// scopeItem = fContextQueryViewListener.findElement(new Pattern[] {
+// Pattern.compile(escapeBrackets("(4) Filter: " + queryPidAll)), // filter name
+// Pattern.compile(escapeBrackets("(4) test.*")), // launch
+// Pattern.compile(escapeBrackets("(1).*agent.*")), // process name
+// Pattern.compile(".*" + processInfo1.fThreadId+".*") }); // thread
+// Assert.assertTrue(scopeItem != null);
+//
+// scopeItem = fContextQueryViewListener.findElement(new Pattern[] {
+// Pattern.compile(escapeBrackets("(4) Filter: " + queryPidAll)), // filter name
+// Pattern.compile(escapeBrackets("(4) test.*")), // launch
+// Pattern.compile(escapeBrackets("(1).*agent.*")), // process name
+// Pattern.compile(".*" + processInfo2.fThreadId+".*") }); // thread
+// Assert.assertTrue(scopeItem != null);
+//
+ } catch (AssertionFailedError e) {
+ System.out.print("Context query view dump: \n:" + fContextQueryViewViewer.toString());
+ throw e;
}
+ }
+
+ public void testContextsFilter() throws Exception {
+ final TestProcessInfo processInfo1 = initProcessModel("tcf_test_func0");
+ final TestProcessInfo processInfo2 = initProcessModel("tcf_test_func0");
+ // Note: run control prefixes process ID with a "P", but the
+ // filter expects the ID without the "P".
+ final Set<String> processContexts1 = new TreeSet<String>();
+ processContexts1.add( fLaunch.getLaunchConfiguration().getName() + "/" + processInfo1.fThreadId );
+
+ try {
+ fContextQueryViewListener.reset();
+ Display.getDefault().syncExec(new Runnable() { public void run() {
+ fContextQueryViewViewer.setAutoExpandLevel(-1);
+ fContextQueryViewViewer.setInput(new ScopeDetailInputObject(new ContextQueryElement(null, processContexts1)));
+ fContextQueryViewViewer.getPresentationContext().setProperty(ITCFDebugUIConstants.PROP_FILTER_CONTEXTS, processContexts1);
+ }});
+ fContextQueryViewListener.waitTillFinished(CONTENT_SEQUENCE_COMPLETE | LABEL_UPDATES_RUNNING);
+
+ VirtualItem scopeItem = fContextQueryViewListener.findElement(new Pattern[] { Pattern.compile(".*pid\\="+processInfo1.fProcessId+".*") });
+ scopeItem = fContextQueryViewListener.findElement(new Pattern[] {
+ Pattern.compile(escapeBrackets("(1) Contexts: " + processContexts1)), // filter name
+ Pattern.compile(escapeBrackets("(1) test.*")), // launch
+ Pattern.compile(escapeBrackets("(1).*agent.*")), // process name
+ Pattern.compile(".*" + processInfo1.fThreadId+".*") }); // thread
+
+ Assert.assertTrue(scopeItem != null);
+
+ fContextQueryViewListener.reset();
+
+ // Check that second process is filtered out.
+ scopeItem = fContextQueryViewListener.findElement(new Pattern[] {
+ Pattern.compile("\\([0-9]+\\) Contexts: " + escapeBrackets(processContexts1.toString())), // filter name
+ Pattern.compile("\\([0-9]+\\) test.*"), // launch
+ Pattern.compile("\\([0-9]+\\) .*agent.*"), // process name
+ Pattern.compile(".*"+processInfo2.fThreadId+".*") }); // thread
+ Assert.assertTrue(scopeItem == null);
+ scopeItem = fContextQueryViewListener.findElement(new Pattern[] { Pattern.compile(".*pid\\="+processInfo2.fProcessId+".*") });
+ Assert.assertTrue(scopeItem == null);
+
+ // Allprocesses in query
+
+
+ fContextQueryViewListener.reset();
+ final Set<String> processContextsAll = new TreeSet<String>();
+ processContextsAll.add( fLaunch.getLaunchConfiguration().getName() + "/" + processInfo1.fThreadId );
+ processContextsAll.add( fLaunch.getLaunchConfiguration().getName() + "/" + processInfo2.fThreadId );
+ Display.getDefault().syncExec(new Runnable() { public void run() {
+ fContextQueryViewViewer.setInput(new ScopeDetailInputObject(new ContextQueryElement(null, processContextsAll)));
+ fContextQueryViewViewer.getPresentationContext().setProperty(ITCFDebugUIConstants.PROP_FILTER_CONTEXTS, processContextsAll);
+ }});
+ fContextQueryViewListener.waitTillFinished(CONTENT_SEQUENCE_COMPLETE | LABEL_UPDATES_RUNNING);
+
+ scopeItem = fContextQueryViewListener.findElement(new Pattern[] {
+ Pattern.compile(escapeBrackets("(2) Contexts: " + processContextsAll)), // filter name
+ Pattern.compile(escapeBrackets("(2) test.*")), // launch
+ Pattern.compile(escapeBrackets("(1).*agent.*")), // process name
+ Pattern.compile(".*" + processInfo1.fThreadId+".*") }); // thread
+ Assert.assertTrue(scopeItem != null);
+
+ scopeItem = fContextQueryViewListener.findElement(new Pattern[] {
+ Pattern.compile(escapeBrackets("(2) Contexts: " + processContextsAll)), // filter name
+ Pattern.compile(escapeBrackets("(2) test.*")), // launch
+ Pattern.compile(escapeBrackets("(1).*agent.*")), // process name
+ Pattern.compile(".*" + processInfo2.fThreadId+".*") }); // thread
+ Assert.assertTrue(scopeItem != null);
+
+ } catch (AssertionFailedError e) {
+ System.out.print("Context query view dump: \n:" + fContextQueryViewViewer.toString());
+ throw e;
+ }
}
+ private String escapeBrackets(String s) {
+ StringBuffer escaped = new StringBuffer();
+ for (int i = 0; i < s.length(); i++) {
+ char c = s.charAt(i);
+ if (c == '[' || c == ']' || c == '(' || c == ')') {
+ escaped.append('\\');
+ }
+ escaped.append(c);
+ }
+ return escaped.toString();
+ }
}
diff --git a/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/BreakpointsTest.java b/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/BreakpointsTest.java
index 105a9db8d..4df334e0b 100644
--- a/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/BreakpointsTest.java
+++ b/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/BreakpointsTest.java
@@ -55,15 +55,15 @@ public class BreakpointsTest extends AbstractTcfUITest
super.tearDown();
}
- private CodeArea getFunctionCodeArea(String functionName) throws Exception {
+ private CodeArea getFunctionCodeArea(final TestProcessInfo processInfo, String functionName) throws Exception {
return new Transaction<CodeArea>() {
@Override
protected CodeArea process() throws InvalidCacheException, ExecutionException {
- ContextState state = validate ( fRunControlCM.getState(fThreadId) );
- String symId = validate ( fSymbolsCM.find(fProcessId, new BigInteger(state.pc), "tcf_test_func0") );
+ ContextState state = validate ( fRunControlCM.getState(processInfo.fThreadId) );
+ String symId = validate ( fSymbolsCM.find(processInfo.fProcessId, new BigInteger(state.pc), "tcf_test_func0") );
Symbol sym = validate ( fSymbolsCM.getContext(symId) );
CodeArea[] area = validate ( fLineNumbersCM.mapToSource(
- fProcessId,
+ processInfo.fProcessId,
sym.getAddress(),
new BigInteger(sym.getAddress().toString()).add(BigInteger.valueOf(1))) );
return area[0];
@@ -103,9 +103,9 @@ public class BreakpointsTest extends AbstractTcfUITest
}
public void testContextAddedOnLineBrakpointCreate() throws Exception {
- initProcessModel("tcf_test_func0");
+ TestProcessInfo processInfo = initProcessModel("tcf_test_func0");
- CodeArea bpCodeArea = getFunctionCodeArea("tcf_test_func0");
+ CodeArea bpCodeArea = getFunctionCodeArea(processInfo, "tcf_test_func0");
ICLineBreakpoint bp = createLineBreakpoint(bpCodeArea.file, bpCodeArea.start_line);
}
diff --git a/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/SampleTest.java b/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/SampleTest.java
index 0e5932da3..347d7ed38 100644
--- a/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/SampleTest.java
+++ b/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/SampleTest.java
@@ -38,7 +38,7 @@ public class SampleTest extends AbstractTcfUITest {
public void testDebugViewContent() throws Exception {
- initProcessModel("tcf_test_func0");
+ TestProcessInfo processInfo = initProcessModel("tcf_test_func0");
VirtualItem launchItem = fDebugViewListener.findElement(new Pattern[] { Pattern.compile(".*" + fLaunch.getLaunchConfiguration().getName() + ".*") } );
Assert.assertTrue(launchItem != null);
@@ -50,25 +50,25 @@ public class SampleTest extends AbstractTcfUITest {
}
Assert.assertTrue(processItem != null);
- VirtualItem threadItem = fDebugViewListener.findElement(processItem, new Pattern[] { Pattern.compile(".*" + fThreadId + ".*") } );
+ VirtualItem threadItem = fDebugViewListener.findElement(processItem, new Pattern[] { Pattern.compile(".*" + processInfo.fThreadId + ".*") } );
Assert.assertTrue(threadItem != null);
VirtualItem frameItem = fDebugViewListener.findElement(threadItem, new Pattern[] { Pattern.compile(".*tcf_test_func0.*")});
Assert.assertTrue(frameItem != null);
}
public void testSteppingDebugViewOnly() throws Exception {
- initProcessModel("tcf_test_func0");
+ final TestProcessInfo processInfo = initProcessModel("tcf_test_func0");
// Execute step loop
String previousThreadLabel = null;
for (int stepNum = 0; stepNum < 100; stepNum++) {
fDebugViewListener.reset();
- resumeAndWaitForSuspend(fThreadCtx, IRunControl.RM_STEP_INTO_LINE);
+ resumeAndWaitForSuspend(processInfo.fThreadCtx, IRunControl.RM_STEP_INTO_LINE);
fDebugViewListener.waitTillFinished(MODEL_CHANGED_COMPLETE | CONTENT_SEQUENCE_COMPLETE | LABEL_UPDATES_RUNNING);
VirtualItem topFrameItem = fDebugViewListener.findElement(
- new Pattern[] { Pattern.compile(".*"), Pattern.compile(".*"), Pattern.compile(".*" + fProcessId + ".*\\(Step.*"), Pattern.compile(".*")});
+ new Pattern[] { Pattern.compile(".*"), Pattern.compile(".*"), Pattern.compile(".*" + processInfo.fProcessId + ".*\\(Step.*"), Pattern.compile(".*")});
if (topFrameItem == null) {
Assert.fail("Top stack frame not found. \n\nDebug view dump: \n:" + fDebugViewViewer.toString());
}
@@ -82,7 +82,7 @@ public class SampleTest extends AbstractTcfUITest {
fVariablesViewViewer.setActive(true);
fRegistersViewViewer.setActive(true);
- initProcessModel("tcf_test_func0");
+ TestProcessInfo processInfo = initProcessModel("tcf_test_func0");
// Execute step loop
String previousThreadLabel = null;
@@ -91,13 +91,13 @@ public class SampleTest extends AbstractTcfUITest {
fVariablesViewListener.reset();
fRegistersViewListener.reset();
- resumeAndWaitForSuspend(fThreadCtx, IRunControl.RM_STEP_INTO_LINE);
+ resumeAndWaitForSuspend(processInfo.fThreadCtx, IRunControl.RM_STEP_INTO_LINE);
fDebugViewListener.waitTillFinished(MODEL_CHANGED_COMPLETE | CONTENT_SEQUENCE_COMPLETE | LABEL_UPDATES_RUNNING);
fVariablesViewListener.waitTillFinished(CONTENT_SEQUENCE_COMPLETE | LABEL_UPDATES_RUNNING);
fRegistersViewListener.waitTillFinished(CONTENT_SEQUENCE_COMPLETE | LABEL_UPDATES_RUNNING);
VirtualItem topFrameItem = fDebugViewListener.findElement(
- new Pattern[] { Pattern.compile(".*"), Pattern.compile(".*"), Pattern.compile(".*" + fProcessId + ".*\\(Step.*"), Pattern.compile(".*")});
+ new Pattern[] { Pattern.compile(".*"), Pattern.compile(".*"), Pattern.compile(".*" + processInfo.fProcessId + ".*\\(Step.*"), Pattern.compile(".*")});
Assert.assertTrue(topFrameItem != null);
String topFrameLabel = ((String[])topFrameItem.getData(VirtualItem.LABEL_KEY))[0];
Assert.assertTrue(!topFrameLabel.equals(previousThreadLabel));
@@ -106,19 +106,19 @@ public class SampleTest extends AbstractTcfUITest {
}
public void testSteppingPerformanceWithSourceDisplay() throws Exception {
- initProcessModel("tcf_test_func0");
+ final TestProcessInfo processInfo = initProcessModel("tcf_test_func0");
final Number sym_func0_address = new Transaction<Number>() {
@Override
protected Number process() throws Transaction.InvalidCacheException ,ExecutionException {
- return validate( fDiagnosticsCM.getSymbol(fProcessId, "tcf_test_func0") ).getValue();
+ return validate( fDiagnosticsCM.getSymbol(processInfo.fProcessId, "tcf_test_func0") ).getValue();
};
}.get();
final Number sym_func3_address = new Transaction<Number>() {
@Override
protected Number process() throws Transaction.InvalidCacheException ,ExecutionException {
- return validate( fDiagnosticsCM.getSymbol(fProcessId, "tcf_test_func3") ).getValue();
+ return validate( fDiagnosticsCM.getSymbol(processInfo.fProcessId, "tcf_test_func3") ).getValue();
};
}.get();
@@ -133,11 +133,11 @@ public class SampleTest extends AbstractTcfUITest {
meter.start();
- ContextState state = resumeAndWaitForSuspend(fThreadCtx, IRunControl.RM_STEP_INTO_LINE);
+ ContextState state = resumeAndWaitForSuspend(processInfo.fThreadCtx, IRunControl.RM_STEP_INTO_LINE);
- CodeArea area = calcPCCodeArea();
+ CodeArea area = calcPCCodeArea(processInfo);
if (area != null) {
- fSourceDisplayListener.setCodeArea(calcPCCodeArea());
+ fSourceDisplayListener.setCodeArea(calcPCCodeArea(processInfo));
}
fDebugViewListener.waitTillFinished(MODEL_CHANGED_COMPLETE | CONTENT_SEQUENCE_COMPLETE | LABEL_UPDATES_RUNNING);
@@ -148,7 +148,7 @@ public class SampleTest extends AbstractTcfUITest {
meter.stop();
if (new BigInteger(state.pc).equals(new BigInteger(sym_func3_address.toString()))) {
- moveToLocation(fThreadId, sym_func0_address);
+ moveToLocation(processInfo.fThreadId, sym_func0_address);
}
}
@@ -162,14 +162,14 @@ public class SampleTest extends AbstractTcfUITest {
}
- private CodeArea calcPCCodeArea() throws ExecutionException, InterruptedException {
+ private CodeArea calcPCCodeArea(final TestProcessInfo processInfo) throws ExecutionException, InterruptedException {
return new Transaction<CodeArea>() {
@Override
protected CodeArea process() throws Transaction.InvalidCacheException ,ExecutionException {
- String pc = validate(fRunControlCM.getState(fThreadId)).pc;
+ String pc = validate(fRunControlCM.getState(processInfo.fThreadId)).pc;
BigInteger pcNumber = new BigInteger(pc);
BigInteger pcNumberPlusOne = pcNumber.add(BigInteger.valueOf(1));
- CodeArea[] areas = validate(fLineNumbersCM.mapToSource(fThreadId, pcNumber, pcNumberPlusOne));
+ CodeArea[] areas = validate(fLineNumbersCM.mapToSource(processInfo.fThreadId, pcNumber, pcNumberPlusOne));
if (areas.length >= 1) {
return areas[0];
}
@@ -179,13 +179,13 @@ public class SampleTest extends AbstractTcfUITest {
}
public void testSymbolsCMResetOnContextRemove() throws Exception {
- initProcessModel("tcf_test_func0");
+ final TestProcessInfo processInfo = initProcessModel("tcf_test_func0");
// Retrieve the current PC for use later
final String pc = new Transaction<String>() {
@Override
protected String process() throws InvalidCacheException, ExecutionException {
- return validate(fRunControlCM.getState(fThreadId)).pc;
+ return validate(fRunControlCM.getState(processInfo.fThreadId)).pc;
}
}.get();
@@ -193,7 +193,7 @@ public class SampleTest extends AbstractTcfUITest {
final String symbolId = new Transaction<String>() {
@Override
protected String process() throws InvalidCacheException, ExecutionException {
- String symId = validate( fSymbolsCM.find(fProcessId, new BigInteger(pc), "tcf_test_func0") );
+ String symId = validate( fSymbolsCM.find(processInfo.fProcessId, new BigInteger(pc), "tcf_test_func0") );
Symbol sym = validate( fSymbolsCM.getContext(symId) );
Assert.assertEquals(ISymbols.UPDATE_ON_MEMORY_MAP_CHANGES, sym.getUpdatePolicy());
return symId;
@@ -205,7 +205,7 @@ public class SampleTest extends AbstractTcfUITest {
@Override
protected Number process() throws InvalidCacheException, ExecutionException {
Symbol sym = validate( fSymbolsCM.getContext(symbolId) );
- String symId2 = validate( fSymbolsCM.findByAddr(fProcessId, sym.getAddress()) );
+ String symId2 = validate( fSymbolsCM.findByAddr(processInfo.fProcessId, sym.getAddress()) );
Symbol sym2 = validate( fSymbolsCM.getContext(symId2) );
Assert.assertEquals(sym.getAddress(), sym2.getAddress());
return sym.getAddress();
@@ -216,18 +216,18 @@ public class SampleTest extends AbstractTcfUITest {
new Transaction<String>() {
@Override
protected String process() throws InvalidCacheException, ExecutionException {
- validate( fDiagnosticsCM.cancelTest(fTestId, this) );
- validate( fRunControlCM.waitForContextRemoved(fProcessId, this) );
+ validate( fDiagnosticsCM.cancelTest(processInfo.fTestId, this) );
+ validate( fRunControlCM.waitForContextRemoved(processInfo.fProcessId, this) );
try {
validate( fSymbolsCM.getContext(symbolId) );
Assert.fail("Expected error");
} catch (ExecutionException e) {}
try {
- validate( fSymbolsCM.find(fProcessId, new BigInteger(pc), "tcf_test_func0") );
+ validate( fSymbolsCM.find(processInfo.fProcessId, new BigInteger(pc), "tcf_test_func0") );
Assert.fail("Expected error");
} catch (ExecutionException e) {}
try {
- validate( fSymbolsCM.findByAddr(fProcessId, symAddr) );
+ validate( fSymbolsCM.findByAddr(processInfo.fProcessId, symAddr) );
Assert.fail("Expected error");
} catch (ExecutionException e) {}
@@ -237,13 +237,13 @@ public class SampleTest extends AbstractTcfUITest {
}
public void testLineNumbersCMResetOnContextRemove() throws Exception {
- initProcessModel("tcf_test_func0");
+ final TestProcessInfo processInfo = initProcessModel("tcf_test_func0");
// Retrieve the current PC for use later
final String pc = new Transaction<String>() {
@Override
protected String process() throws InvalidCacheException, ExecutionException {
- return validate(fRunControlCM.getState(fThreadId)).pc;
+ return validate(fRunControlCM.getState(processInfo.fThreadId)).pc;
}
}.get();
@@ -254,19 +254,19 @@ public class SampleTest extends AbstractTcfUITest {
final CodeArea[] pcCodeAreas = new Transaction<CodeArea[]>() {
@Override
protected CodeArea[] process() throws InvalidCacheException, ExecutionException {
- CodeArea[] areas = validate(fLineNumbersCM.mapToSource(fProcessId, pcNumber, pcNumberPlusOne));
+ CodeArea[] areas = validate(fLineNumbersCM.mapToSource(processInfo.fProcessId, pcNumber, pcNumberPlusOne));
Assert.assertNotNull(areas);
Assert.assertTrue(areas.length != 0);
- areas = validate(fLineNumbersCM.mapToSource(fThreadId, pcNumber, pcNumberPlusOne));
+ areas = validate(fLineNumbersCM.mapToSource(processInfo.fThreadId, pcNumber, pcNumberPlusOne));
Assert.assertNotNull(areas);
Assert.assertTrue(areas.length != 0);
- CodeArea[] areas2 = validate(fLineNumbersCM.mapToMemory(fProcessId, areas[0].file, areas[0].start_line, areas[0].start_column));
+ CodeArea[] areas2 = validate(fLineNumbersCM.mapToMemory(processInfo.fProcessId, areas[0].file, areas[0].start_line, areas[0].start_column));
Assert.assertNotNull(areas2);
Assert.assertTrue(areas2.length != 0);
- areas2 = validate(fLineNumbersCM.mapToMemory(fThreadId, areas[0].file, areas[0].start_line, areas[0].start_column));
+ areas2 = validate(fLineNumbersCM.mapToMemory(processInfo.fThreadId, areas[0].file, areas[0].start_line, areas[0].start_column));
Assert.assertNotNull(areas2);
Assert.assertTrue(areas2.length != 0);
@@ -278,22 +278,22 @@ public class SampleTest extends AbstractTcfUITest {
new Transaction<String>() {
@Override
protected String process() throws InvalidCacheException, ExecutionException {
- validate( fDiagnosticsCM.cancelTest(fTestId, this) );
- validate( fRunControlCM.waitForContextRemoved(fProcessId, this) );
+ validate( fDiagnosticsCM.cancelTest(processInfo.fTestId, this) );
+ validate( fRunControlCM.waitForContextRemoved(processInfo.fProcessId, this) );
try {
- validate(fLineNumbersCM.mapToSource(fProcessId, pcNumber, pcNumberPlusOne));
+ validate(fLineNumbersCM.mapToSource(processInfo.fProcessId, pcNumber, pcNumberPlusOne));
Assert.fail("Expected error");
} catch (ExecutionException e) {}
try {
- validate(fLineNumbersCM.mapToSource(fThreadId, pcNumber, pcNumberPlusOne));
+ validate(fLineNumbersCM.mapToSource(processInfo.fThreadId, pcNumber, pcNumberPlusOne));
Assert.fail("Expected error");
} catch (ExecutionException e) {}
try {
- CodeArea[] areas3 = validate(fLineNumbersCM.mapToMemory(fProcessId, pcCodeAreas[0].file, pcCodeAreas[0].start_line, pcCodeAreas[0].start_column));
+ CodeArea[] areas3 = validate(fLineNumbersCM.mapToMemory(processInfo.fProcessId, pcCodeAreas[0].file, pcCodeAreas[0].start_line, pcCodeAreas[0].start_column));
Assert.fail("Expected error");
} catch (ExecutionException e) {}
try {
- validate(fLineNumbersCM.mapToMemory(fThreadId, pcCodeAreas[0].file, pcCodeAreas[0].start_line, pcCodeAreas[0].start_column));
+ validate(fLineNumbersCM.mapToMemory(processInfo.fThreadId, pcCodeAreas[0].file, pcCodeAreas[0].start_line, pcCodeAreas[0].start_column));
Assert.fail("Expected error");
} catch (ExecutionException e) {}
@@ -304,19 +304,19 @@ public class SampleTest extends AbstractTcfUITest {
public void testSymbolsCMResetOnContextStateChange() throws Exception {
- initProcessModel("tcf_test_func2");
+ final TestProcessInfo processInfo = initProcessModel("tcf_test_func2");
// Retrieve the current PC and top frame for use later
final String pc = new Transaction<String>() {
@Override
protected String process() throws InvalidCacheException, ExecutionException {
- return validate(fRunControlCM.getState(fThreadId)).pc;
+ return validate(fRunControlCM.getState(processInfo.fThreadId)).pc;
}
}.get();
final String topFrameId = new Transaction<String>() {
@Override
protected String process() throws InvalidCacheException, ExecutionException {
- String[] frameIds = validate( fStackTraceCM.getChildren(fThreadId) );
+ String[] frameIds = validate( fStackTraceCM.getChildren(processInfo.fThreadId) );
return frameIds[frameIds.length - 1];
}
}.get();
@@ -346,7 +346,7 @@ public class SampleTest extends AbstractTcfUITest {
// }.get();
// Execute a step.
- resumeAndWaitForSuspend(fThreadCtx, IRunControl.RM_STEP_OUT);
+ resumeAndWaitForSuspend(processInfo.fThreadCtx, IRunControl.RM_STEP_OUT);
// End test, check that all caches were reset and now return an error.
new Transaction<Object>() {
@@ -364,13 +364,13 @@ public class SampleTest extends AbstractTcfUITest {
}
public void testStackTraceCMResetOnContextStateChange() throws Exception {
- initProcessModel("tcf_test_func2");
+ final TestProcessInfo processInfo = initProcessModel("tcf_test_func2");
// Retrieve the current PC and top frame for use later
final String pc = new Transaction<String>() {
@Override
protected String process() throws InvalidCacheException, ExecutionException {
- return validate(fRunControlCM.getState(fThreadId)).pc;
+ return validate(fRunControlCM.getState(processInfo.fThreadId)).pc;
}
}.get();
@@ -378,9 +378,9 @@ public class SampleTest extends AbstractTcfUITest {
new Transaction<Object>() {
@Override
protected String process() throws InvalidCacheException, ExecutionException {
- String[] frameIds = validate( fStackTraceCM.getChildren(fThreadId) );
+ String[] frameIds = validate( fStackTraceCM.getChildren(processInfo.fThreadId) );
validate (fStackTraceCM.getContexts(frameIds));
- RangeCache<StackTraceContext> framesRange = fStackTraceCM.getContextRange(fThreadId);
+ RangeCache<StackTraceContext> framesRange = fStackTraceCM.getContextRange(processInfo.fThreadId);
validate( framesRange.getRange(0, frameIds.length) );
return null;
}
@@ -388,13 +388,13 @@ public class SampleTest extends AbstractTcfUITest {
// Execute a step.
- resumeAndWaitForSuspend(fThreadCtx, IRunControl.RM_STEP_OUT);
+ resumeAndWaitForSuspend(processInfo.fThreadCtx, IRunControl.RM_STEP_OUT);
// End test, check that all caches were reset and now return an error.
new Transaction<Object>() {
@Override
protected Object process() throws InvalidCacheException, ExecutionException {
- ICache<String[]> frameIdsCache = fStackTraceCM.getChildren(fThreadId);
+ ICache<String[]> frameIdsCache = fStackTraceCM.getChildren(processInfo.fThreadId);
Assert.assertFalse("Expected cache to be reset", frameIdsCache.isValid());
return null;
}
@@ -403,11 +403,11 @@ public class SampleTest extends AbstractTcfUITest {
new Transaction<Object>() {
@Override
protected Object process() throws InvalidCacheException, ExecutionException {
- String[] frameIds = validate( fStackTraceCM.getChildren(fThreadId) );
+ String[] frameIds = validate( fStackTraceCM.getChildren(processInfo.fThreadId) );
ICache<StackTraceContext[]> cache = fStackTraceCM.getContexts(frameIds);
Assert.assertFalse("Expected cache to be reset", cache.isValid());
- RangeCache<StackTraceContext> framesRange = fStackTraceCM.getContextRange(fThreadId);
+ RangeCache<StackTraceContext> framesRange = fStackTraceCM.getContextRange(processInfo.fThreadId);
ICache<List<StackTraceContext>> framesRangeCache = framesRange.getRange(0, frameIds.length);
Assert.assertFalse("Expected cache to be reset", framesRangeCache.isValid());
@@ -417,7 +417,7 @@ public class SampleTest extends AbstractTcfUITest {
}
public void testRunControlCMChildrenInvalidation() throws Exception {
- initProcessModel("tcf_test_func0");
+ final TestProcessInfo processInfo = initProcessModel("tcf_test_func0");
createBreakpoint("testRunControlCMChildrenInvalidation", "tcf_test_func0");
@@ -426,8 +426,8 @@ public class SampleTest extends AbstractTcfUITest {
List<String> fThreads = new ArrayList<String>();
@Override
protected String[] process() throws InvalidCacheException, ExecutionException {
- IWaitForEventCache<RunControlContext[]> waitCache = fRunControlCM.waitForContextAdded(fProcessId, this);
- validate(fRunControlCM.resume(fTestCtx, this, IRunControl.RM_RESUME, 1));
+ IWaitForEventCache<RunControlContext[]> waitCache = fRunControlCM.waitForContextAdded(processInfo.fProcessId, this);
+ validate(fRunControlCM.resume(processInfo.fTestCtx, this, IRunControl.RM_RESUME, 1));
RunControlContext[] addedContexts = validate(waitCache);
for (RunControlContext addedContext : addedContexts) {
fThreads.add(addedContext.getID());
@@ -437,7 +437,7 @@ public class SampleTest extends AbstractTcfUITest {
validate(waitCache);
}
// Validate children cache
- String[] children = validate (fRunControlCM.getChildren(fProcessId));
+ String[] children = validate (fRunControlCM.getChildren(processInfo.fProcessId));
Assert.assertTrue(
"Expected children array to contain added ids",
Arrays.asList(children).containsAll(fThreads));
@@ -470,25 +470,25 @@ public class SampleTest extends AbstractTcfUITest {
@Override
protected String process() throws InvalidCacheException, ExecutionException {
// Create wait caches
- fRunControlCM.waitForContextRemoved(fProcessId, this);
+ fRunControlCM.waitForContextRemoved(processInfo.fProcessId, this);
IWaitForEventCache<?>[] waitCaches = new IWaitForEventCache<?>[threads.length];
for (int i = 0; i < threads.length; i++) {
waitCaches[i] = fRunControlCM.waitForContextRemoved(threads[i], this);
}
- validate( fDiagnosticsCM.cancelTest(fTestId, this) );
+ validate( fDiagnosticsCM.cancelTest(processInfo.fTestId, this) );
validate(waitCaches);
- validate(fRunControlCM.waitForContextRemoved(fProcessId, this));
+ validate(fRunControlCM.waitForContextRemoved(processInfo.fProcessId, this));
try {
- validate( fRunControlCM.getContext(fProcessId) );
+ validate( fRunControlCM.getContext(processInfo.fProcessId) );
Assert.fail("Expected error");
} catch (ExecutionException e) {}
try {
- validate( fRunControlCM.getState(fProcessId) );
+ validate( fRunControlCM.getState(processInfo.fProcessId) );
Assert.fail("Expected error");
} catch (ExecutionException e) {}
try {
- String children[] = validate( fRunControlCM.getChildren(fProcessId) );
+ String children[] = validate( fRunControlCM.getChildren(processInfo.fProcessId) );
Assert.assertEquals("Expected no children", 0, children.length);
} catch (ExecutionException e) {}
@@ -502,7 +502,7 @@ public class SampleTest extends AbstractTcfUITest {
Assert.fail("Expected error");
} catch (ExecutionException e) {}
try {
- String children[] = validate( fRunControlCM.getChildren(fProcessId) );
+ String children[] = validate( fRunControlCM.getChildren(processInfo.fProcessId) );
Assert.assertEquals("Expected no children", 0, children.length);
} catch (ExecutionException e) {}
}
diff --git a/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/TestProcessInfo.java b/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/TestProcessInfo.java
new file mode 100644
index 000000000..917681f03
--- /dev/null
+++ b/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/TestProcessInfo.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Wind River Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.debug.test;
+
+import org.eclipse.tcf.services.IRunControl.RunControlContext;
+
+/**
+ *
+ */
+public class TestProcessInfo {
+ public TestProcessInfo(String testId,
+ RunControlContext testCtx,
+ String processId,
+ String threadId,
+ RunControlContext threadCtx)
+ {
+ fTestId = testId;
+ fTestCtx = testCtx;
+ fProcessId = processId;
+ fThreadId = threadId;
+ fThreadCtx = threadCtx;
+ }
+
+ public String fTestId;
+ public RunControlContext fTestCtx;
+ public String fProcessId = "";
+ public String fThreadId = "";
+ public RunControlContext fThreadCtx;
+}
diff --git a/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/ViewerUpdatesListener.java b/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/ViewerUpdatesListener.java
index 0672b9d11..a93a5e1a0 100644
--- a/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/ViewerUpdatesListener.java
+++ b/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/ViewerUpdatesListener.java
@@ -121,15 +121,15 @@ public class ViewerUpdatesListener
}
- public void setFailOnRedundantUpdates(boolean failOnRedundantUpdates) {
+ public synchronized void setFailOnRedundantUpdates(boolean failOnRedundantUpdates) {
fFailOnRedundantUpdates = failOnRedundantUpdates;
}
- public void setFailOnMultipleModelUpdateSequences(boolean failOnMultipleLabelUpdateSequences) {
+ public synchronized void setFailOnMultipleModelUpdateSequences(boolean failOnMultipleLabelUpdateSequences) {
fFailOnMultipleModelUpdateSequences = failOnMultipleLabelUpdateSequences;
}
- public void setFailOnMultipleLabelUpdateSequences(boolean failOnMultipleLabelUpdateSequences) {
+ public synchronized void setFailOnMultipleLabelUpdateSequences(boolean failOnMultipleLabelUpdateSequences) {
fFailOnMultipleLabelUpdateSequences = failOnMultipleLabelUpdateSequences;
}
@@ -139,7 +139,7 @@ public class ViewerUpdatesListener
* every reset.
* @param delay If true, listener will delay.
*/
- public void setDelayContentUntilProxyInstall(boolean delay) {
+ public synchronized void setDelayContentUntilProxyInstall(boolean delay) {
fDelayContentUntilProxyInstall = delay;
}
@@ -147,7 +147,7 @@ public class ViewerUpdatesListener
* Sets the the maximum amount of time (in milliseconds) that the update listener
* is going to wait. If set to -1, the listener will wait indefinitely.
*/
- public void setTimeoutInterval(int milis) {
+ public synchronized void setTimeoutInterval(int milis) {
fTimeoutInterval = milis;
}
@@ -221,32 +221,40 @@ public class ViewerUpdatesListener
}
}
- public void addLabelUpdate(TreePath path) {
+ public synchronized void addLabelUpdate(TreePath path) {
+ for (IViewerUpdate update : fLabelUpdatesCompleted) {
+ if ( matchPath(path, update.getElementPath()) ) {
+ return;
+ }
+ }
fLabelUpdates.add(path);
}
- public void addPropertiesUpdate(TreePath path) {
+ public synchronized void addPropertiesUpdate(TreePath path) {
fPropertiesUpdates.add(path);
}
- public void removeLabelUpdate(TreePath path) {
+ public synchronized void removeLabelUpdate(TreePath path) {
fLabelUpdates.remove(path);
}
- public void addStateUpdate(TreePath path) {
+ public synchronized void addStateUpdate(TreePath path) {
fStateUpdates.add(path);
}
- public void removeStateUpdate(TreePath path) {
+ public synchronized void removeStateUpdate(TreePath path) {
fStateUpdates.remove(path);
}
+ protected boolean matchPath(TreePath patternPath, TreePath elementPath) {
+ return elementPath.equals(patternPath);
+ }
public boolean isFinished() {
return isFinished(ALL_UPDATES_COMPLETE);
}
- public boolean isTimedOut() {
+ public synchronized boolean isTimedOut() {
return fTimeoutInterval > 0 && fTimeoutTime < System.currentTimeMillis();
}
@@ -258,7 +266,7 @@ public class ViewerUpdatesListener
}
}
- public boolean isFinished(int flags) {
+ public synchronized boolean isFinished(int flags) {
if (isTimedOut()) {
throw new RuntimeException("Timed Out: " + toString(flags));
}
@@ -480,7 +488,7 @@ public class ViewerUpdatesListener
public void stateUpdateStarted(Object input, IViewerUpdate update) {
}
- private String toString(int flags) {
+ private synchronized String toString(int flags) {
StringBuffer buf = new StringBuffer("Viewer Update Listener");
if (fFailOnRedundantUpdates) {
diff --git a/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/VirtualViewerUpdatesListener.java b/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/VirtualViewerUpdatesListener.java
index 105e3a80d..e6881c246 100644
--- a/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/VirtualViewerUpdatesListener.java
+++ b/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/VirtualViewerUpdatesListener.java
@@ -41,18 +41,23 @@ public class VirtualViewerUpdatesListener extends ViewerUpdatesListener {
}
public VirtualItem findElement(VirtualItem parent, Pattern[] patterns) {
- VirtualItem item = parent;
- patterns: for (int i = 0; i < patterns.length; i++) {
- for (VirtualItem child : item.getItems()) {
- String[] label = (String[])child.getData(VirtualItem.LABEL_KEY);
- if (label != null && label.length >= 1 && label[0] != null && patterns[i].matcher(label[0]).matches()) {
- item = child;
- continue patterns;
+ return findElement(parent, patterns, 0);
+ }
+
+ private VirtualItem findElement(VirtualItem parent, Pattern[] patterns, int patternIdx) {
+ if (patternIdx >= patterns.length) return parent;
+ for (VirtualItem child : parent.getItems()) {
+ String[] label = (String[])child.getData(VirtualItem.LABEL_KEY);
+ if (label != null && label.length >= 1 && label[0] != null &&
+ patterns[patternIdx].matcher(label[0]).matches())
+ {
+ VirtualItem item = findElement(child, patterns, patternIdx+1);
+ if (item != null) {
+ return item;
}
}
- return null;
}
- return item;
+ return null;
}
@Override
@@ -60,6 +65,27 @@ public class VirtualViewerUpdatesListener extends ViewerUpdatesListener {
return new MatchingSet();
}
+ protected boolean matchPath(TreePath patternPath, TreePath elementPath) {
+ if (patternPath.getSegmentCount() != elementPath.getSegmentCount()) {
+ return false;
+ }
+
+ for (int i = 0; i < patternPath.getSegmentCount(); i++) {
+ Object patternSegment = patternPath.getSegment(i);
+ Object elementSegment = elementPath.getSegment(i);
+ if ( fPatternComparer.equals(elementSegment, patternSegment) ) {
+ continue;
+ } else if (fTCFContextComparer.equals(elementSegment, patternSegment) ) {
+ continue;
+ } else if (patternSegment.equals(elementSegment)) {
+ continue;
+ }
+ return false;
+ }
+ return true;
+ }
+
+
private final IElementComparer fPatternComparer = new IElementComparer() {
public boolean equals(Object a, Object b) {
Pattern pattern = null;
@@ -164,31 +190,12 @@ public class VirtualViewerUpdatesListener extends ViewerUpdatesListener {
private int find(TreePath path) {
for (int i = 0; i < fList.size(); i++) {
- if (matches(fList.get(i), path)) {
+ if (matchPath(fList.get(i), path)) {
return i;
}
}
return -1;
}
- private boolean matches(TreePath patternPath, TreePath elementPath) {
- if (patternPath.getSegmentCount() != elementPath.getSegmentCount()) {
- return false;
- }
-
- for (int i = 0; i < patternPath.getSegmentCount(); i++) {
- Object patternSegment = patternPath.getSegment(i);
- Object elementSegment = elementPath.getSegment(i);
- if ( fPatternComparer.equals(elementSegment, patternSegment) ) {
- continue;
- } else if (fTCFContextComparer.equals(elementSegment, patternSegment) ) {
- continue;
- } else if (patternSegment.equals(elementSegment)) {
- continue;
- }
- return false;
- }
- return true;
- }
}
}
diff --git a/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/ProcessesCM.java b/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/ProcessesCM.java
new file mode 100644
index 000000000..ff2db1ff6
--- /dev/null
+++ b/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/ProcessesCM.java
@@ -0,0 +1,99 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 Wind River Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.debug.test.services;
+
+import org.eclipse.tcf.debug.test.util.ICache;
+import org.eclipse.tcf.debug.test.util.TokenCache;
+import org.eclipse.tcf.protocol.IToken;
+import org.eclipse.tcf.services.IProcesses;
+import org.eclipse.tcf.services.IProcesses.ProcessContext;
+
+/**
+ *
+ */
+public class ProcessesCM extends AbstractCacheManager implements IProcesses.ProcessesListener {
+
+ private IProcesses fService;
+ private final ResetMap fResetMap = new ResetMap();
+
+ public ProcessesCM(IProcesses service) {
+ fService = service;
+ fService.addListener(this);
+ }
+
+ @Override
+ public void dispose() {
+ fService.removeListener(this);
+ super.dispose();
+ }
+
+ public ICache<String[]> getChildren(final String id, final boolean attached_only) {
+ class MyCache extends TokenCache<String[]> implements IProcesses.DoneGetChildren {
+ @Override
+ protected IToken retrieveToken() {
+ return fService.getChildren(id, attached_only, this);
+ }
+
+ public void doneGetChildren(IToken token, Exception error, String[] context_ids) {
+ fResetMap.addValid(id, this);
+ set(token, context_ids, error);
+ }
+ };
+
+ class MyIdKey extends IdKey<MyCache> {
+
+ private boolean fAttachedOnly = attached_only;
+
+ public MyIdKey() {
+ super(MyCache.class, id);
+ }
+
+ @Override MyCache createCache() { return new MyCache(); }
+
+ @Override
+ public boolean equals(Object obj) {
+ return super.equals(obj) && fAttachedOnly == ((MyIdKey)obj).fAttachedOnly;
+ }
+
+ @Override
+ public int hashCode() {
+ return super.hashCode() + (fAttachedOnly ? Integer.MAX_VALUE / 2 : 0);
+ }
+ }
+
+ return mapCache(new MyIdKey());
+ }
+
+ public ICache<ProcessContext> getContext(final String id) {
+ class MyCache extends TokenCache<ProcessContext> implements IProcesses.DoneGetContext {
+ @Override
+ protected IToken retrieveToken() {
+ return fService.getContext(id, this);
+ }
+
+ public void doneGetContext(IToken token, Exception error, ProcessContext context) {
+ fResetMap.addValid(id, this);
+ set(token, context, error);
+ }
+ };
+
+ return mapCache(new IdKey<MyCache>(MyCache.class, id) {
+ @Override MyCache createCache() { return new MyCache(); }
+ });
+ }
+
+
+ @Override
+ public void exited(String process_id, int exit_code) {
+ fResetMap.reset(process_id);
+ }
+
+}

Back to the top