diff options
author | eutarass | 2010-02-22 18:19:02 +0000 |
---|---|---|
committer | eutarass | 2010-02-22 18:19:02 +0000 |
commit | 4964b236049b5d07a21c1cf2ce1b20a0c624d567 (patch) | |
tree | af60be954c90030d73c4bf1cb703d064824d11aa /plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug | |
parent | e85adcdb0929eebd3adc3a75795acc850034325f (diff) | |
download | org.eclipse.tcf-4964b236049b5d07a21c1cf2ce1b20a0c624d567.tar.gz org.eclipse.tcf-4964b236049b5d07a21c1cf2ce1b20a0c624d567.tar.xz org.eclipse.tcf-4964b236049b5d07a21c1cf2ce1b20a0c624d567.zip |
Work in progress: more TCF value-add support - all tests have passed when connecting to a target through TCF symbols server value-add.
Diffstat (limited to 'plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug')
7 files changed, 196 insertions, 126 deletions
diff --git a/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/model/TCFLaunch.java b/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/model/TCFLaunch.java index 6ee7d861a..abfd4f531 100644 --- a/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/model/TCFLaunch.java +++ b/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/model/TCFLaunch.java @@ -530,8 +530,8 @@ public class TCFLaunch extends Launch { listeners.remove(listener); } + /** Thread safe method */ public IChannel getChannel() { - assert Protocol.isDispatchThread(); return channel; } diff --git a/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/tests/Main.java b/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/tests/Main.java index 8724c35ca..9b9d80dfc 100644 --- a/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/tests/Main.java +++ b/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/tests/Main.java @@ -110,7 +110,7 @@ public class Main { } private static void runTestSuite(IPeer peer) { - TCFTestSuite.TestListener listenr = new TCFTestSuite.TestListener() { + TCFTestSuite.TestListener listener = new TCFTestSuite.TestListener() { public void done(Collection<Throwable> errors) { if (errors == null || errors.isEmpty()) { @@ -129,7 +129,7 @@ public class Main { }; try { - new TCFTestSuite(peer, listenr); + new TCFTestSuite(peer, listener, null); } catch (Throwable x) { System.err.println("Cannot start test suite:"); diff --git a/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/tests/TCFTestSuite.java b/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/tests/TCFTestSuite.java index 6c9c6cc63..21fb3b639 100644 --- a/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/tests/TCFTestSuite.java +++ b/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/tests/TCFTestSuite.java @@ -16,11 +16,13 @@ import java.util.Collection; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; +import java.util.List; import java.util.Map; import org.eclipse.tm.tcf.protocol.IChannel; import org.eclipse.tm.tcf.protocol.IPeer; import org.eclipse.tm.tcf.protocol.Protocol; +import org.eclipse.tm.tcf.services.IPathMap.PathMapRule; /** * TCF Test Suite implements stress testing of communication channels and capabilities of remote peer. @@ -49,7 +51,7 @@ public class TCFTestSuite { public void done(Collection<Throwable> errors); } - public TCFTestSuite(final IPeer peer, final TestListener listener) throws IOException { + public TCFTestSuite(final IPeer peer, final TestListener listener, final List<PathMapRule> path_map) throws IOException { this.listener = listener; pending_tests.add(new Runnable() { public void run() { @@ -77,6 +79,14 @@ public class TCFTestSuite { }); pending_tests.add(new Runnable() { public void run() { + listener.progress("Running Path Map Test...", ++count_done, count_total); + for (IChannel channel : channels) { + active_tests.put(new TestPathMap(TCFTestSuite.this, channel, path_map), channel); + } + } + }); + pending_tests.add(new Runnable() { + public void run() { listener.progress("Running Expressions Test...", ++count_done, count_total); for (IChannel channel : channels) { active_tests.put(new TestExpressions(TCFTestSuite.this, channel), channel); @@ -119,14 +129,6 @@ public class TCFTestSuite { }); pending_tests.add(new Runnable() { public void run() { - listener.progress("Running Path Map Test...", ++count_done, count_total); - for (IChannel channel : channels) { - active_tests.put(new TestPathMap(TCFTestSuite.this, channel), channel); - } - } - }); - pending_tests.add(new Runnable() { - public void run() { listener.progress("Running Interability Test...", ++count_done, count_total); for (int i = 0; i < channels.length; i++) { ITCFTest test = null; diff --git a/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/tests/TestAttachTerminate.java b/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/tests/TestAttachTerminate.java index 35ea71bba..a2211c774 100644 --- a/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/tests/TestAttachTerminate.java +++ b/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/tests/TestAttachTerminate.java @@ -15,6 +15,7 @@ import java.util.HashSet; import java.util.Map; import org.eclipse.tm.tcf.protocol.IChannel; +import org.eclipse.tm.tcf.protocol.IErrorReport; import org.eclipse.tm.tcf.protocol.IToken; import org.eclipse.tm.tcf.protocol.Protocol; import org.eclipse.tm.tcf.services.IDiagnostics; @@ -27,13 +28,12 @@ class TestAttachTerminate implements ITCFTest, IRunControl.RunControlListener { private final IDiagnostics diag; private final IRunControl rc; - private final HashMap<String,IRunControl.RunControlContext> map = + private int cnt = 0; + + private final HashMap<String,IRunControl.RunControlContext> ctx_map = new HashMap<String,IRunControl.RunControlContext>(); private final HashSet<String> process_ids = new HashSet<String>(); - private int cnt; - private int wait_cnt; - TestAttachTerminate(TCFTestSuite test_suite, IChannel channel) { this.test_suite = test_suite; diag = channel.getRemoteService(IDiagnostics.class); @@ -41,11 +41,11 @@ class TestAttachTerminate implements ITCFTest, IRunControl.RunControlListener { } public void start() { - if (diag == null) { + if (diag == null || rc == null) { test_suite.done(this, null); } else { - if (rc != null) rc.addListener(this); + rc.addListener(this); diag.getTestList(new IDiagnostics.DoneGetTestList() { public void doneGetTestList(IToken token, Throwable error, String[] list) { assert test_suite.isActive(TestAttachTerminate.this); @@ -56,6 +56,25 @@ class TestAttachTerminate implements ITCFTest, IRunControl.RunControlListener { for (int i = 0; i < list.length; i++) { if (list[i].equals("RCBP1")) { startProcess(); + Protocol.invokeLater(1000, new Runnable() { + int cnt = 0; + public void run() { + if (!test_suite.isActive(TestAttachTerminate.this)) return; + cnt++; + if (cnt < 10) { + Protocol.invokeLater(1000, this); + } + else if (test_suite.cancel) { + exit(null); + } + else if (process_ids.isEmpty()) { + exit(new Error("Missing 'contextAdded' event")); + } + else { + exit(new Error("Missing 'contextRemoved' event for " + process_ids)); + } + } + }); return; } } @@ -67,70 +86,34 @@ class TestAttachTerminate implements ITCFTest, IRunControl.RunControlListener { } private void startProcess() { - if (test_suite.cancel || cnt == 4) { - if (!process_ids.isEmpty()) { - new Thread() { - public void run() { - try { - sleep(100); - Protocol.invokeLater(new Runnable() { - public void run() { - wait_cnt++; - if (test_suite.cancel) exit(null); - if (process_ids.isEmpty()) { - exit(null); - } - else if (wait_cnt < 300) { - startProcess(); - } - else { - exit(new Error("Missing 'contextRemoved' event for " + process_ids)); - } - } - }); - } - catch (IllegalStateException x) { - } - catch (InterruptedException x) { - } - } - }.start(); - } - else { - exit(null); - } - return; - } - cnt++; - diag.runTest("RCBP1", new IDiagnostics.DoneRunTest() { - public void doneRunTest(IToken token, Throwable error, String context_id) { - if (error != null) { - exit(error); - } - else { - assert context_id != null; - if (rc != null && map.get(context_id) == null) { - exit(new Error("Missing 'contextAdded' event for context " + context_id)); + for (int i = 0; i < 4; i++) { + diag.runTest("RCBP1", new IDiagnostics.DoneRunTest() { + public void doneRunTest(IToken token, Throwable error, String context_id) { + cnt--; + if (error != null) { + exit(error); } - process_ids.add(context_id); - diag.cancelTest(context_id, new IDiagnostics.DoneCancelTest() { - public void doneCancelTest(IToken token, Throwable error) { - if (error != null) { - exit(error); - } - else { - startProcess(); - } + else { + assert context_id != null; + if (ctx_map.get(context_id) == null) { + exit(new Error("Missing 'contextAdded' event for context " + context_id)); } - }); + process_ids.add(context_id); + diag.cancelTest(context_id, new IDiagnostics.DoneCancelTest() { + public void doneCancelTest(IToken token, Throwable error) { + if (error != null) exit(error); + } + }); + } } - } - }); + }); + cnt++; + } } private void exit(Throwable x) { if (!test_suite.isActive(this)) return; - if (rc != null) rc.removeListener(this); + rc.removeListener(this); test_suite.done(this, x); } @@ -148,23 +131,23 @@ class TestAttachTerminate implements ITCFTest, IRunControl.RunControlListener { public void contextAdded(RunControlContext[] contexts) { for (RunControlContext ctx : contexts) { - if (map.get(ctx.getID()) != null) exit(new Error("Invalid 'contextAdded' event")); - map.put(ctx.getID(), ctx); + if (ctx_map.get(ctx.getID()) != null) exit(new Error("Invalid 'contextAdded' event")); + ctx_map.put(ctx.getID(), ctx); } } public void contextChanged(RunControlContext[] contexts) { for (RunControlContext ctx : contexts) { - if (map.get(ctx.getID()) == null) return; - map.put(ctx.getID(), ctx); + if (ctx_map.get(ctx.getID()) == null) return; + ctx_map.put(ctx.getID(), ctx); } } public void contextException(String context, String msg) { - IRunControl.RunControlContext ctx = map.get(context); + IRunControl.RunControlContext ctx = ctx_map.get(context); if (ctx == null) return; if (process_ids.contains(ctx.getParentID())) { - /* TODO: FIXME: Linux-64 PTrace sometimes intercepts SIGKILL instead of delivering it to the process + /* exit(new Error("Unexpected 'contextException' event for " + context + ": " + msg)); */ } @@ -172,22 +155,27 @@ class TestAttachTerminate implements ITCFTest, IRunControl.RunControlListener { public void contextRemoved(String[] context_ids) { for (String id : context_ids) { - map.remove(id); + ctx_map.remove(id); process_ids.remove(id); } + if (cnt == 0 && process_ids.isEmpty()) exit(null); } public void contextResumed(String context) { } - public void contextSuspended(String context, String pc, String reason, - Map<String, Object> params) { + public void contextSuspended(String context, String pc, String reason, Map<String,Object> params) { assert context != null; - IRunControl.RunControlContext ctx = map.get(context); - if (ctx == null) return; - if (process_ids.contains(ctx.getParentID())) { + IRunControl.RunControlContext ctx = ctx_map.get(context); + if (ctx != null && process_ids.contains(ctx.getParentID())) { ctx.resume(IRunControl.RM_RESUME, 1, new IRunControl.DoneCommand() { public void doneCommand(IToken token, Exception error) { + if (error instanceof IErrorReport) { + int code = ((IErrorReport)error).getErrorCode(); + if (code == IErrorReport.TCF_ERROR_ALREADY_RUNNING) return; + if (code == IErrorReport.TCF_ERROR_INV_CONTEXT) return; + } + if (error != null) exit(error); } }); } diff --git a/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/tests/TestExpressions.java b/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/tests/TestExpressions.java index d36f51caf..9975b5773 100644 --- a/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/tests/TestExpressions.java +++ b/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/tests/TestExpressions.java @@ -16,13 +16,16 @@ import java.util.HashMap; import java.util.Map; import org.eclipse.tm.tcf.protocol.IChannel; +import org.eclipse.tm.tcf.protocol.IErrorReport; import org.eclipse.tm.tcf.protocol.IToken; +import org.eclipse.tm.tcf.protocol.Protocol; import org.eclipse.tm.tcf.services.IBreakpoints; import org.eclipse.tm.tcf.services.IDiagnostics; import org.eclipse.tm.tcf.services.IExpressions; import org.eclipse.tm.tcf.services.IRunControl; import org.eclipse.tm.tcf.services.IStackTrace; import org.eclipse.tm.tcf.services.ISymbols; +import org.eclipse.tm.tcf.services.IRunControl.RunControlContext; class TestExpressions implements ITCFTest, IRunControl.RunControlListener, IExpressions.ExpressionsListener, IBreakpoints.BreakpointsListener { @@ -40,13 +43,13 @@ class TestExpressions implements ITCFTest, private IDiagnostics.ISymbol sym_func3; private String process_id; private String thread_id; - private boolean process_exited; private boolean test_done; private IRunControl.RunControlContext thread_ctx; private String suspended_pc; private boolean waiting_suspend; private String[] stack_trace; private String[] local_vars; + private final HashMap<String,IRunControl.RunControlContext> ctx_map = new HashMap<String,IRunControl.RunControlContext>(); private final Map<String,IExpressions.Expression> expr_ctx = new HashMap<String,IExpressions.Expression>(); private final Map<String,IExpressions.Value> expr_val = new HashMap<String,IExpressions.Value>(); private final Map<String,ISymbols.Symbol> expr_sym = new HashMap<String,ISymbols.Symbol>(); @@ -85,6 +88,7 @@ class TestExpressions implements ITCFTest, "(func2_local2 >> 1) == 1", "+func2_local2 == 2", "-func2_local2 == -2", + "(short)(int)(long)((char *)func2_local2 + 1) == 3", "((func2_local1 + func2_local2) * 2 - 2) / 2 == 2", "func2_local3.f_struct->f_struct->f_struct == &func2_local3" }; @@ -117,6 +121,22 @@ class TestExpressions implements ITCFTest, for (int i = 0; i < list.length; i++) { if (list[i].equals("RCBP1")) { runTest(); + Protocol.invokeLater(1000, new Runnable() { + int cnt = 0; + public void run() { + if (!test_suite.isActive(TestExpressions.this)) return; + cnt++; + if (cnt < 10) { + Protocol.invokeLater(1000, this); + } + else if (test_suite.cancel) { + exit(null); + } + else { + exit(new Error("Missing 'contextRemoved' event for " + process_id)); + } + } + }); return; } } @@ -407,7 +427,7 @@ class TestExpressions implements ITCFTest, test_done = true; diag.cancelTest(process_id, new IDiagnostics.DoneCancelTest() { public void doneCancelTest(IToken token, Throwable error) { - exit(error); + if (error != null) exit(error); } }); } @@ -434,9 +454,17 @@ class TestExpressions implements ITCFTest, } public void contextAdded(IRunControl.RunControlContext[] contexts) { + for (RunControlContext ctx : contexts) { + if (ctx_map.get(ctx.getID()) != null) exit(new Error("Invalid 'contextAdded' event")); + ctx_map.put(ctx.getID(), ctx); + } } public void contextChanged(IRunControl.RunControlContext[] contexts) { + for (RunControlContext ctx : contexts) { + if (ctx_map.get(ctx.getID()) == null) return; + ctx_map.put(ctx.getID(), ctx); + } } public void contextException(String context, String msg) { @@ -444,9 +472,11 @@ class TestExpressions implements ITCFTest, public void contextRemoved(String[] context_ids) { for (String id : context_ids) { + ctx_map.remove(id); if (id.equals(process_id)) { - process_exited = true; - if (!test_done) exit(new Exception("Test process exited too soon")); + if (test_done) exit(null); + else exit(new Exception("Test process exited too soon")); + return; } } } @@ -462,6 +492,21 @@ class TestExpressions implements ITCFTest, runTest(); } } + if (test_done) { + IRunControl.RunControlContext ctx = ctx_map.get(context); + if (ctx != null && process_id != null && process_id.equals(ctx.getParentID())) { + ctx.resume(IRunControl.RM_RESUME, 1, new IRunControl.DoneCommand() { + public void doneCommand(IToken token, Exception error) { + if (error instanceof IErrorReport) { + int code = ((IErrorReport)error).getErrorCode(); + if (code == IErrorReport.TCF_ERROR_ALREADY_RUNNING) return; + if (code == IErrorReport.TCF_ERROR_INV_CONTEXT) return; + } + if (error != null) exit(error); + } + }); + } + } } //--------------------------- Expressions listener ---------------------------// @@ -473,7 +518,7 @@ class TestExpressions implements ITCFTest, @SuppressWarnings("unchecked") public void breakpointStatusChanged(String id, Map<String,Object> status) { - if (id.equals(bp_id) && process_id != null && !process_exited) { + if (id.equals(bp_id) && process_id != null) { String s = (String)status.get(IBreakpoints.STATUS_ERROR); if (s != null) exit(new Exception("Invalid BP status: " + s)); Collection<Map<String,Object>> list = (Collection<Map<String,Object>>)status.get(IBreakpoints.STATUS_INSTANCES); diff --git a/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/tests/TestPathMap.java b/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/tests/TestPathMap.java index 1b75e020f..998f07a02 100644 --- a/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/tests/TestPathMap.java +++ b/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/tests/TestPathMap.java @@ -1,6 +1,7 @@ package org.eclipse.tm.internal.tcf.debug.tests; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Random; @@ -12,6 +13,7 @@ import org.eclipse.tm.tcf.services.IPathMap.PathMapRule; class TestPathMap implements ITCFTest { private final TCFTestSuite test_suite; + private final List<PathMapRule> map; private final IPathMap service; private final Random rnd = new Random(); @@ -62,8 +64,9 @@ class TestPathMap implements ITCFTest { } } - TestPathMap(TCFTestSuite test_suite, IChannel channel) { + TestPathMap(TCFTestSuite test_suite, IChannel channel, List<PathMapRule> map) { this.test_suite = test_suite; + this.map = map; service = channel.getRemoteService(IPathMap.class); } @@ -78,7 +81,16 @@ class TestPathMap implements ITCFTest { private void test_map() { if (cnt >= 40) { - exit(null); + if (map == null) { + exit(null); + } + else { + service.set(map.toArray(new PathMapRule[map.size()]), new IPathMap.DoneSet() { + public void doneSet(IToken token, Exception error) { + exit(error); + } + }); + } } else { cnt++; diff --git a/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/tests/TestRCBP1.java b/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/tests/TestRCBP1.java index b86b20d55..b47a39155 100644 --- a/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/tests/TestRCBP1.java +++ b/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/tests/TestRCBP1.java @@ -78,7 +78,6 @@ class TestRCBP1 implements ITCFTest, final String pc; final String reason; final Map<String,Object> params; - boolean resumed; SuspendedContext(String id, String pc, String reason, Map<String,Object> params) { this.id = id; @@ -338,7 +337,7 @@ class TestRCBP1 implements ITCFTest, exit(new Exception("Invalid result of getState command")); } else { - resume(sc); + resume(id); } } else { @@ -458,7 +457,7 @@ class TestRCBP1 implements ITCFTest, if (error != null) exit(error); } }); - for (SuspendedContext s : suspended.values()) resume(s); + for (SuspendedContext s : suspended.values()) resume(s.id); } }); } @@ -538,7 +537,12 @@ class TestRCBP1 implements ITCFTest, } public void contextResumed(String id) { - if (threads.get(id) == null) return; + IRunControl.RunControlContext ctx = threads.get(id); + if (ctx == null) return; + if (!ctx.hasState()) { + exit(new Exception("Resumed event for context that HasState = false")); + return; + } SuspendedContext sc = suspended.remove(id); if (isMyBreakpoint(sc)) suspended_prev.put(id, sc); running.add(id); @@ -569,8 +573,13 @@ class TestRCBP1 implements ITCFTest, return false; } - public void contextSuspended(String id, String pc, String reason, Map<String, Object> params) { - if (threads.get(id) == null) return; + public void contextSuspended(final String id, String pc, String reason, Map<String, Object> params) { + IRunControl.RunControlContext ctx = threads.get(id); + if (ctx == null) return; + if (!ctx.hasState()) { + exit(new Exception("Suspended event for context that HasState = false")); + return; + } running.remove(id); SuspendedContext sc = suspended.get(id); if (sc != null) { @@ -591,7 +600,7 @@ class TestRCBP1 implements ITCFTest, main_thread_id = id; } if (main_thread_id == null) { - resume(sc); + resume(id); return; } if (isMyBreakpoint(sc)) { @@ -619,10 +628,19 @@ class TestRCBP1 implements ITCFTest, final SuspendedContext sc0 = sc; ILineNumbers.DoneMapToSource ln_done = new ILineNumbers.DoneMapToSource() { public void doneMapToSource(IToken token, Exception error, CodeArea[] areas) { - if (error != null) exit(error); - else if (mm != null) runMemoryTest(sc0); - else if (rg != null) runRegistersTest(sc0); - else resume(sc0); + if (error != null) { + exit(error); + return; + } + runMemoryTest(sc0, new Runnable() { + public void run() { + runRegistersTest(sc0, new Runnable() { + public void run() { + resume(id); + } + }); + } + }); } }; if (ln != null) { @@ -635,27 +653,27 @@ class TestRCBP1 implements ITCFTest, } } - private void resume(final SuspendedContext sc) { + private void resume(final String id) { assert done_starting_test_process || resume_cnt == 0; if (!done_starting_test_process) return; resume_cnt++; - IRunControl.RunControlContext ctx = threads.get(sc.id); - if (ctx != null && !sc.resumed) { - sc.resumed = true; + SuspendedContext sc = suspended.get(id); + IRunControl.RunControlContext ctx = threads.get(id); + if (ctx != null && sc != null) { ctx.resume(IRunControl.RM_RESUME, 1, new HashMap<String,Object>(), new IRunControl.DoneCommand() { public void doneCommand(IToken token, Exception error) { if (test_suite.cancel) return; if (!test_suite.isActive(TestRCBP1.this)) return; - if (threads.get(sc.id) == null) return; + if (threads.get(id) == null) return; if (error != null) exit(error); } }); } } - private void runMemoryTest(final SuspendedContext sc) { - if (test_suite.target_lock) { - resume(sc); + private void runMemoryTest(final SuspendedContext sc, final Runnable done) { + if (mm == null || test_suite.target_lock) { + Protocol.invokeLater(done); return; } test_suite.target_lock = true; @@ -703,7 +721,7 @@ class TestRCBP1 implements ITCFTest, if (mem_address.longValue() == 0) { exit(new Exception("Bad value of 'tcf_test_array': " + mem_address)); } - testSetMemoryCommand(sc, mem_ctx, mem_address, buf); + testSetMemoryCommand(sc, mem_ctx, mem_address, buf, done); } }); } @@ -712,7 +730,8 @@ class TestRCBP1 implements ITCFTest, private void testSetMemoryCommand(final SuspendedContext sc, final IMemory.MemoryContext mem_ctx, - final Number addr, final byte[] buf) { + final Number addr, final byte[] buf, + final Runnable done) { final byte[] data = new byte[buf.length]; new Random().nextBytes(data); mem_ctx.set(addr, 1, data, 0, data.length, 0, new IMemory.DoneMemory() { @@ -743,7 +762,7 @@ class TestRCBP1 implements ITCFTest, return; } } - testFillMemoryCommand(sc, mem_ctx, addr, buf); + testFillMemoryCommand(sc, mem_ctx, addr, buf, done); } }); } @@ -752,7 +771,8 @@ class TestRCBP1 implements ITCFTest, private void testFillMemoryCommand(final SuspendedContext sc, final IMemory.MemoryContext mem_ctx, - final Number addr, final byte[] buf) { + final Number addr, final byte[] buf, + final Runnable done) { final byte[] data = new byte[buf.length / 7]; new Random().nextBytes(data); mem_ctx.fill(addr, 1, data, buf.length, 0, new IMemory.DoneMemory() { @@ -784,15 +804,18 @@ class TestRCBP1 implements ITCFTest, } } test_suite.target_lock = false; - if (rg != null) runRegistersTest(sc); - else resume(sc); + done.run(); } }); } }); } - private void runRegistersTest(final SuspendedContext sc) { + private void runRegistersTest(final SuspendedContext sc, final Runnable done) { + if (rg == null) { + Protocol.invokeLater(done); + return; + } if (regs.get(sc.id) == null) { final Map<String,IRegisters.RegistersContext> reg_map = new HashMap<String,IRegisters.RegistersContext>(); @@ -828,7 +851,7 @@ class TestRCBP1 implements ITCFTest, } reg_map.put(id, context); if (cmds.isEmpty()) { - testGetSetRegisterCommands(sc); + testGetSetRegisterCommands(sc, done); } } })); @@ -837,11 +860,11 @@ class TestRCBP1 implements ITCFTest, })); } else { - testGetSetRegisterCommands(sc); + testGetSetRegisterCommands(sc, done); } } - private void testGetSetRegisterCommands(final SuspendedContext sc) { + private void testGetSetRegisterCommands(final SuspendedContext sc, final Runnable done) { final Set<IToken> cmds = new HashSet<IToken>(); Map<String,IRegisters.RegistersContext> reg_map = regs.get(sc.id); for (final IRegisters.RegistersContext ctx : reg_map.values()) { @@ -866,7 +889,7 @@ class TestRCBP1 implements ITCFTest, return; } if (cmds.isEmpty()) { - resume(sc); + done.run(); } } })); @@ -906,7 +929,7 @@ class TestRCBP1 implements ITCFTest, return; } if (cmds.isEmpty()) { - resume(sc); + done.run(); } } })); @@ -914,7 +937,7 @@ class TestRCBP1 implements ITCFTest, })); } if (cmds.isEmpty()) { - resume(sc); + done.run(); } } |