Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugene Tarassov2016-03-11 20:34:17 +0000
committerEugene Tarassov2016-03-11 20:35:46 +0000
commit82e5a0e04629bb413608ef6757b53b94f3cb2bbf (patch)
tree6b60602d9e601ff60e9f429f3063863fdc2cb88d /plugins/org.eclipse.tcf.debug
parentd1a7ae6b18ef7f1b56c5f00175da27d1d5787e56 (diff)
downloadorg.eclipse.tcf-82e5a0e04629bb413608ef6757b53b94f3cb2bbf.tar.gz
org.eclipse.tcf-82e5a0e04629bb413608ef6757b53b94f3cb2bbf.tar.xz
org.eclipse.tcf-82e5a0e04629bb413608ef6757b53b94f3cb2bbf.zip
TCF Tests: added tests for sending integer numbers over TCF channel
Diffstat (limited to 'plugins/org.eclipse.tcf.debug')
-rw-r--r--plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/tests/TCFTestSuite.java10
-rw-r--r--plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/tests/TestEchoERR.java34
-rw-r--r--plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/tests/TestEchoFP.java4
-rw-r--r--plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/tests/TestEchoINT.java116
4 files changed, 144 insertions, 20 deletions
diff --git a/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/tests/TCFTestSuite.java b/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/tests/TCFTestSuite.java
index b5db69bc4..eebcf9ccf 100644
--- a/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/tests/TCFTestSuite.java
+++ b/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/tests/TCFTestSuite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2014 Wind River Systems, Inc. and others.
+ * Copyright (c) 2007, 2016 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 v1.0
* which accompanies this distribution, and is available at
@@ -76,6 +76,14 @@ public class TCFTestSuite {
});
pending_tests.add(new Runnable() {
public void run() {
+ listener.progress("Running Echo INT Test...", count_done++, count_total);
+ for (IChannel channel : channels) {
+ active_tests.put(new TestEchoINT(TCFTestSuite.this, channel), channel);
+ }
+ }
+ });
+ pending_tests.add(new Runnable() {
+ public void run() {
listener.progress("Running Echo ERR Test...", count_done++, count_total);
for (IChannel channel : channels) {
active_tests.put(new TestEchoERR(TCFTestSuite.this, channel), channel);
diff --git a/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/tests/TestEchoERR.java b/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/tests/TestEchoERR.java
index 8662ab4dc..43f06e019 100644
--- a/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/tests/TestEchoERR.java
+++ b/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/tests/TestEchoERR.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2014 Wind River Systems, Inc. and others.
+ * Copyright (c) 2010, 2016 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 v1.0
* which accompanies this distribution, and is available at
@@ -28,28 +28,28 @@ class TestEchoERR implements ITCFTest, IDiagnostics.DoneEchoERR {
private final IDiagnostics diag;
private final Number[] numbers = {
- 1,
- 4,
- // new BigDecimal("0.5") - fails, representation depends on locale
+ 1,
+ 4,
+ // new BigDecimal("0.5") - fails, representation depends on locale
};
private final String[] strings = {
- "",
- "abc",
- "a\u1134c",
- "a\u0003c",
+ "",
+ "abc",
+ "a\u1134c",
+ "a\u0003c",
};
private final String[] formats = {
- "",
- "{0}",
- "{0,number}",
- "{0,number,integer}",
- "{0,number,percent}",
- "{1}",
- "{0} abcde {1}",
- "{1} '' {0}",
- "{1} 'abcde{}' {1}",
+ "",
+ "{0}",
+ "{0,number}",
+ "{0,number,integer}",
+ "{0,number,percent}",
+ "{1}",
+ "{0} abcde {1}",
+ "{1} '' {0}",
+ "{1} 'abcde{}' {1}",
};
private final LinkedList<ErrorReport> list = new LinkedList<ErrorReport>();
diff --git a/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/tests/TestEchoFP.java b/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/tests/TestEchoFP.java
index 40847a718..d4d31dfa5 100644
--- a/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/tests/TestEchoFP.java
+++ b/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/tests/TestEchoFP.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2014 Wind River Systems, Inc. and others.
+ * Copyright (c) 2010, 2016 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 v1.0
* which accompanies this distribution, and is available at
@@ -25,7 +25,7 @@ class TestEchoFP implements ITCFTest, IDiagnostics.DoneEchoFP {
private final LinkedList<BigDecimal> msgs = new LinkedList<BigDecimal>();
private final Random rnd = new Random();
- private static final int MAX_COUNT = 0x800;
+ private static final int MAX_COUNT = 0x1000;
private static final int MAX_TIME_MS = 4000;
private int count = 0;
diff --git a/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/tests/TestEchoINT.java b/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/tests/TestEchoINT.java
new file mode 100644
index 000000000..03777b6e3
--- /dev/null
+++ b/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/tests/TestEchoINT.java
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2016 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 v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Xilinx - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.internal.debug.tests;
+
+import java.math.BigInteger;
+import java.util.LinkedList;
+import java.util.Random;
+
+import org.eclipse.tcf.protocol.IChannel;
+import org.eclipse.tcf.protocol.IErrorReport;
+import org.eclipse.tcf.protocol.IToken;
+import org.eclipse.tcf.services.IDiagnostics;
+
+class TestEchoINT implements ITCFTest, IDiagnostics.DoneEchoINT {
+
+ private final TCFTestSuite test_suite;
+ private final IDiagnostics diag;
+ private final LinkedList<BigInteger> msgs = new LinkedList<BigInteger>();
+ private final Random rnd = new Random();
+
+ private static final int MAX_COUNT = 0x1000;
+ private static final int MAX_TIME_MS = 4000;
+
+ private int count = 0;
+ private long start_time;
+
+ TestEchoINT(TCFTestSuite test_suite, IChannel channel) {
+ this.test_suite = test_suite;
+ diag = channel.getRemoteService(IDiagnostics.class);
+ }
+
+ public void start() {
+ if (diag == null) {
+ test_suite.done(this, null);
+ }
+ else {
+ start_time = System.currentTimeMillis();
+ for (int i = 0; i < 100; i++) sendMessage();
+ }
+ }
+
+ private void sendMessage() {
+ int t = 0;
+ BigInteger n = null;
+ switch (count) {
+ case 0: n = new BigInteger("-2147483648"); break;
+ case 1: n = new BigInteger("2147483647"); break;
+ case 2: t = 2; n = new BigInteger("-9223372036854775808"); break;
+ case 3: t = 2; n = new BigInteger("9223372036854775807"); break;
+ }
+ if (n == null) {
+ byte[] buf = null;
+ t = rnd.nextInt() & 3;
+ switch (t) {
+ case 0:
+ n = BigInteger.valueOf(rnd.nextInt());
+ break;
+ case 1:
+ buf = new byte[4];
+ rnd.nextBytes(buf);
+ n = new BigInteger(1, buf);
+ break;
+ case 2:
+ buf = new byte[8];
+ rnd.nextBytes(buf);
+ buf[0] = (byte)(buf[0] & 0x7f);
+ n = new BigInteger(rnd.nextBoolean() ? 1 : -1, buf);
+ break;
+ case 3:
+ buf = new byte[8];
+ rnd.nextBytes(buf);
+ n = new BigInteger(1, buf);
+ break;
+ }
+ }
+ msgs.add(n);
+ diag.echoINT(t, n, this);
+ count++;
+ }
+
+ public void doneEchoINT(IToken token, Throwable error, BigInteger b) {
+ BigInteger s = msgs.removeFirst();
+ if (!test_suite.isActive(this)) return;
+ if (error instanceof IErrorReport && ((IErrorReport)error).getErrorCode() == IErrorReport.TCF_ERROR_INV_COMMAND) {
+ test_suite.done(this, null);
+ }
+ else if (error != null) {
+ test_suite.done(this, error);
+ }
+ else if (!s.equals(b)) {
+ test_suite.done(this, new Exception("EchoINT test failed: " + s + " != " + b));
+ }
+ else if (count < MAX_COUNT) {
+ sendMessage();
+ // Don't run the test longer then MAX_TIME_MS ms
+ if (count % 0x40 == 0 && System.currentTimeMillis() - start_time >= MAX_TIME_MS) {
+ count = MAX_COUNT;
+ }
+ }
+ else if (msgs.isEmpty()) {
+ test_suite.done(this, null);
+ }
+ }
+
+ public boolean canResume(String id) {
+ return true;
+ }
+}

Back to the top