diff options
author | Eugene Tarassov | 2020-02-20 18:29:39 +0000 |
---|---|---|
committer | Eugene Tarassov | 2020-02-20 18:29:39 +0000 |
commit | eac51819eaf5341f24704187b69a60f3fd41ac27 (patch) | |
tree | 90a2736302500e4a7bd60d85def352b025b1d424 /plugins/org.eclipse.tcf.debug | |
parent | 7b4454d567fb53b29812d26fdd7c8f4bf2c8b574 (diff) | |
download | org.eclipse.tcf-eac51819eaf5341f24704187b69a60f3fd41ac27.tar.gz org.eclipse.tcf-eac51819eaf5341f24704187b69a60f3fd41ac27.tar.xz org.eclipse.tcf-eac51819eaf5341f24704187b69a60f3fd41ac27.zip |
TCF Tests: more of MemoryMap tests, longer timeouts
Diffstat (limited to 'plugins/org.eclipse.tcf.debug')
3 files changed, 72 insertions, 17 deletions
diff --git a/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/tests/TestExpressions.java b/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/tests/TestExpressions.java index 406821dd9..f3c7d29a3 100644 --- a/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/tests/TestExpressions.java +++ b/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/tests/TestExpressions.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008-2019 Wind River Systems, Inc. and others. + * Copyright (c) 2008-2020 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -258,7 +258,7 @@ class TestExpressions implements ITCFTest, RunControl.DiagnosticTestDone, if (list.length > 0) { test_id = list[rnd.nextInt(list.length)]; runTest(); - Protocol.invokeLater(100, new Runnable() { + Protocol.invokeLater(1000, new Runnable() { public void run() { if (!test_suite.isActive(TestExpressions.this)) return; timer++; @@ -270,7 +270,7 @@ class TestExpressions implements ITCFTest, RunControl.DiagnosticTestDone, test_rc.cancel(test_ctx_id); cancel_test_sent = true; } - Protocol.invokeLater(100, this); + Protocol.invokeLater(1000, this); } else if (test_ctx_id == null) { exit(new Error("Timeout waiting for reply of Diagnostics.runTest command")); @@ -300,6 +300,7 @@ class TestExpressions implements ITCFTest, RunControl.DiagnosticTestDone, if (run_to_bp_done) return false; if (sym_func3 == null) return false; if (suspended_pc == null) return false; + if (!waiting_suspend) return false; BigInteger pc0 = JSON.toBigInteger(sym_func3.getValue()); BigInteger pc1 = new BigInteger(suspended_pc); if (pc0.equals(pc1)) return false; @@ -1019,6 +1020,7 @@ class TestExpressions implements ITCFTest, RunControl.DiagnosticTestDone, if (run_to_bp_done && !test_done) { assert thread_ctx != null; assert !canResume(thread_id); + assert !test_suite.canResume(thread_id); exit(new Exception("Unexpected contextResumed event: " + id)); } suspended_pc = null; @@ -1030,7 +1032,16 @@ class TestExpressions implements ITCFTest, RunControl.DiagnosticTestDone, if (id.equals(thread_id) && waiting_suspend) { suspended_pc = pc; waiting_suspend = false; - runTest(); + assert !test_done; + assert !canResume(thread_id); + assert !test_suite.canResume(thread_id); + Protocol.invokeLater(new Runnable() { + @Override + public void run() { + assert !canResume(thread_id); + runTest(); + } + }); } } diff --git a/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/tests/TestRCBP1.java b/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/tests/TestRCBP1.java index ca31f5929..93464f046 100644 --- a/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/tests/TestRCBP1.java +++ b/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/tests/TestRCBP1.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2008-2020 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -1674,7 +1674,7 @@ class TestRCBP1 implements ITCFTest, RunControl.DiagnosticTestDone, IRunControl. } for (int i = 0; i < value.length; i++) { if (value[i] != value1[i]) { - exit(new Exception("Invalid register value")); + exit(new Exception("Invalid register value in " + ctx.getName())); return; } } @@ -1695,7 +1695,8 @@ class TestRCBP1 implements ITCFTest, RunControl.DiagnosticTestDone, IRunControl. else { int data_size = 0; int l = rnd.nextInt(32); - List<IRegisters.Location> locs = new ArrayList<IRegisters.Location>(); + final List<IRegisters.Location> locs = new ArrayList<IRegisters.Location>(); + final List<String> names = new ArrayList<String>(); for (int i = 0; i < l; i++) { String id = ids[rnd.nextInt(ids.length)]; IRegisters.RegistersContext ctx = reg_map.get(id); @@ -1708,6 +1709,7 @@ class TestRCBP1 implements ITCFTest, RunControl.DiagnosticTestDone, IRunControl. int offs = rnd.nextInt(ctx.getSize()); int size = rnd.nextInt(ctx.getSize() - offs) + 1; locs.add(new IRegisters.Location(id, offs, size)); + names.add(ctx.getName()); data_size += size; } final int total_size = data_size; @@ -1720,6 +1722,7 @@ class TestRCBP1 implements ITCFTest, RunControl.DiagnosticTestDone, IRunControl. error = new Exception("Invalid data size in Registers.getm reply"); } if (error != null) { + error = new Exception("Cannot read regs " + names, error); exit(error); return; } @@ -1838,6 +1841,29 @@ class TestRCBP1 implements ITCFTest, RunControl.DiagnosticTestDone, IRunControl. return bf.toString(); } + private JSON.Binary getRandomBinary() { + int l = rnd.nextInt(512) + 1; + byte[] bf = new byte[l]; + for (int i = 0; i < l; i++) { + bf[i] = (byte)rnd.nextInt(0x100); + } + return new JSON.Binary(bf, 0, bf.length); + } + + private Map<String,Object> getRandomObject(int level) { + Map<String,Object> m = new HashMap<String,Object>(); + if (level < 4) { + if (rnd.nextBoolean()) m.put("True", true); + if (rnd.nextBoolean()) m.put("False", false); + if (rnd.nextBoolean()) m.put("Null", null); + if (rnd.nextBoolean()) m.put("Integer", rnd.nextInt()); + if (rnd.nextBoolean()) m.put("String", getRandomString()); + if (rnd.nextBoolean()) m.put("Object", getRandomObject(level + 1)); + if (rnd.nextBoolean()) m.put("Array", new ArrayList<Object>(getRandomObject(level + 1).values())); + } + return m; + } + private void runMemoryMapTest() { assert !mem_map_test_running; if (srv_memory_map == null || test_context == null || test_context.getProcessID() == null) { @@ -1865,6 +1891,9 @@ class TestRCBP1 implements ITCFTest, RunControl.DiagnosticTestDone, IRunControl. else if (rnd.nextBoolean()) props.put(IMemoryMap.PROP_OFFSET, rnd.nextInt(0x10000000)); if (rnd.nextBoolean()) props.put(IMemoryMap.PROP_BSS, true); } + if (rnd.nextBoolean()) props.put("TestRCBP-String", getRandomString()); + if (rnd.nextBoolean()) props.put("TestRCBP-Binary", getRandomBinary()); + if (rnd.nextBoolean()) props.put("TestRCBP-Object", getRandomObject(0)); List<MemoryRegion> list = new ArrayList<MemoryRegion>(); for (MemoryRegion r : map) { String id = (String)r.getProperties().get(IMemoryMap.PROP_ID); @@ -1889,7 +1918,16 @@ class TestRCBP1 implements ITCFTest, RunControl.DiagnosticTestDone, IRunControl. String id = (String)r.getProperties().get(IMemoryMap.PROP_ID); if (!test_id.equals(id)) continue; for (String p : props.keySet()) { - if (!props.get(p).equals(r.getProperties().get(p))) { + Object o = props.get(p); + if (o instanceof JSON.Binary) { + byte[] x = ((JSON.Binary)o).bytes; + byte[] y = JSON.toByteArray(r.getProperties().get(p)); + if (!Arrays.equals(x, y)) { + exit(new Error("Invalid value returned for Memory Map region property " + p)); + return; + } + } + else if (!o.equals(r.getProperties().get(p))) { exit(new Error("Invalid value returned for Memory Map region property " + p)); return; } diff --git a/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/tests/TestTerminals.java b/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/tests/TestTerminals.java index 8fa8efcde..31aa6ff24 100644 --- a/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/tests/TestTerminals.java +++ b/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/tests/TestTerminals.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011-2018 Wind River Systems, Inc. and others. + * Copyright (c) 2011-2020 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -59,7 +59,7 @@ class TestTerminals implements ITCFTest { private boolean unsubscribe_done; private boolean exited; private boolean stdout_eos; - private int time_out = 0; + private int timer = 0; private final ITerminals.TerminalsListener listener = new ITerminals.TerminalsListener() { @@ -199,15 +199,15 @@ class TestTerminals implements ITCFTest { disconnect_cmds.add(streams.disconnect(stream_id, disconnect_done)); } } - Protocol.invokeLater(100, new Runnable() { + Protocol.invokeLater(1000, new Runnable() { public void run() { if (!test_suite.isActive(TestTerminals.this)) return; - time_out++; + timer++; if (test_suite.cancel) { exit(null); } - else if (time_out < 200) { - Protocol.invokeLater(100, this); + else if (timer < 600) { + Protocol.invokeLater(1000, this); } else if (!signal_sent) { if (signal_cmd == null) { @@ -316,6 +316,7 @@ class TestTerminals implements ITCFTest { try { boolean run = false; if (data != null) { + // System.out.println(new String(data, encoding)); stdout_buf.append(new String(data, encoding)); if (echo_tx.size() > echo_rx.size()) { String s = echo_tx.get(echo_rx.size()); @@ -324,7 +325,7 @@ class TestTerminals implements ITCFTest { if (echo_rx.size() > 0) n = echo_rx.get(echo_rx.size() - 1); int i = stdout_buf.indexOf(p, n); if (i >= 0 && stdout_buf.length() >= i + s.length() + 4) { - time_out = 0; + timer = 0; echo_rx.add(i + 1); run = true; } @@ -359,7 +360,10 @@ class TestTerminals implements ITCFTest { } else { try { - if (data != null) stderr_buf.append(new String(data, encoding)); + if (data != null) { + // System.err.println(new String(data, encoding)); + stderr_buf.append(new String(data, encoding)); + } if (!eos) streams.read(id, 0x1000, this); } catch (Exception x) { @@ -444,6 +448,7 @@ class TestTerminals implements ITCFTest { exit(error); } else { + timer = 0; signal_sent = true; run(); } @@ -459,13 +464,14 @@ class TestTerminals implements ITCFTest { exit(error); } else { + timer = 0; signal_sent = true; run(); } } }); } - time_out = 0; + timer = 0; } return; } |