1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
package org.eclipse.tcf.debug.test;
import java.util.Collection;
import java.util.Map;
import java.util.TreeMap;
import java.util.concurrent.ExecutionException;
import org.eclipse.cdt.debug.core.CDIDebugModel;
import org.eclipse.tcf.debug.test.util.Transaction;
import org.eclipse.tcf.services.IBreakpoints;
import org.eclipse.tcf.services.IRunControl.RunControlContext;
import org.junit.Assert;
@SuppressWarnings("restriction")
public class BreakpointsTest extends AbstractTcfUITest
{
private String fTestId;
private RunControlContext fTestCtx;
private String fProcessId = "";
private String fThreadId = "";
private RunControlContext fThreadCtx;
private void createBreakpoint(final String bpId, final String testFunc) throws InterruptedException, ExecutionException {
new Transaction<Object>() {
private Map<String,Object> fBp;
{
fBp = new TreeMap<String,Object>();
fBp.put(IBreakpoints.PROP_ID, bpId);
fBp.put(IBreakpoints.PROP_ENABLED, Boolean.TRUE);
fBp.put(IBreakpoints.PROP_LOCATION, testFunc);
}
@Override
protected Object process() throws InvalidCacheException, ExecutionException {
@SuppressWarnings("unchecked")
Map<String, Object>[] bps = (Map<String, Object>[])new Map[] { fBp };
validate( fBreakpointsCM.set(bps, this) );
return null;
}
}.get();
}
private void checkBreakpointForErrors(final String bpId, final String processId) throws InterruptedException, ExecutionException {
new Transaction<Object>() {
@Override
protected Object process() throws InvalidCacheException, ExecutionException {
// Wait for breakpoint status event and validate it.
Map<String, Object> status = validate( fBreakpointsCM.getStatus(bpId) );
String s = (String)status.get(IBreakpoints.STATUS_ERROR);
if (s != null) {
Assert.fail("Invalid BP status: " + s);
}
@SuppressWarnings("unchecked")
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 (processId.equals(ctx) && map.get(IBreakpoints.INSTANCE_ERROR) != null)
err = (String)map.get(IBreakpoints.INSTANCE_ERROR);
}
if (err != null) {
Assert.fail("Invalid BP status: " + s);
}
}
return null;
}
}.get();
}
private void startProcess() throws InterruptedException, ExecutionException {
new Transaction<Object>() {
protected Object process() throws Transaction.InvalidCacheException ,ExecutionException {
fTestId = validate( fDiagnosticsCM.runTest(getDiagnosticsTestName(), this) );
fTestCtx = validate( fRunControlCM.getContext(fTestId) );
fProcessId = fTestCtx.getProcessID();
// Create the cache to listen for exceptions.
fRunControlCM.waitForContextException(fTestId, fTestRunKey);
if (!fProcessId.equals(fTestId)) {
fThreadId = fTestId;
} else {
String[] threads = validate( fRunControlCM.getChildren(fProcessId) );
fThreadId = threads[0];
}
fThreadCtx = validate( fRunControlCM.getContext(fThreadId) );
Assert.assertTrue("Invalid thread context", fThreadCtx.hasState());
return new Object();
};
}.get();
}
private void initProcessModel(String bpId, String testFunc) throws Exception {
createBreakpoint(bpId, testFunc);
fDebugViewListener.reset();
startProcess();
fDebugViewListener.waitTillFinished(MODEL_CHANGED_COMPLETE | CONTENT_SEQUENCE_COMPLETE | LABEL_SEQUENCE_COMPLETE | LABEL_UPDATES);
}
public void testCreateBreakpoint() throws Exception {
String bpId = "TestStepBP";
initProcessModel(bpId, "tcf_test_func0");
//CDIDebugModel.createFunctionBreakpoint();
checkBreakpointForErrors(bpId, fProcessId);
}
}
|