Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugene Tarassov2011-11-09 12:30:32 -0500
committerEugene Tarassov2011-11-09 12:30:32 -0500
commit955ce49554a4f84a458a6754d1ba0c0862e43331 (patch)
tree724434a20c0e81f787ddd536f6d55e658af22090
parentb831d144a0f0bc6ed91fe2a603cd142f000862bb (diff)
downloadorg.eclipse.tcf-955ce49554a4f84a458a6754d1ba0c0862e43331.tar.gz
org.eclipse.tcf-955ce49554a4f84a458a6754d1ba0c0862e43331.tar.xz
org.eclipse.tcf-955ce49554a4f84a458a6754d1ba0c0862e43331.zip
TCF Tests: improved FileSystem tests.
-rw-r--r--plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/tests/TestFileSystem.java83
-rwxr-xr-xtests/test-all6
2 files changed, 70 insertions, 19 deletions
diff --git a/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/tests/TestFileSystem.java b/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/tests/TestFileSystem.java
index e86c8b8c3..7c601e7e2 100644
--- a/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/tests/TestFileSystem.java
+++ b/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/tests/TestFileSystem.java
@@ -12,6 +12,7 @@ package org.eclipse.tm.internal.tcf.debug.tests;
import java.io.InputStream;
import java.io.OutputStream;
+import java.util.HashMap;
import java.util.LinkedList;
import java.util.Random;
@@ -47,13 +48,20 @@ class TestFileSystem implements ITCFTest, IFileSystem.DoneStat,
private final IFileSystem files;
private final Random rnd = new Random();
- private final byte[] data = new byte[0x1000];
private final LinkedList<String> tmp_files = new LinkedList<String>();
+ private final HashMap<IToken,Object> cmds = new HashMap<IToken,Object>();
+ private byte[] data;
private String root;
private String tmp_path;
private String file_name;
private IFileHandle handle;
private int state = STATE_PRE;
+ private boolean async_close;
+
+ private static class ReadCmd {
+ int offs;
+ int size;
+ }
TestFileSystem(TCFTestSuite test_suite, IChannel channel, int channel_id) {
this.test_suite = test_suite;
@@ -184,11 +192,48 @@ class TestFileSystem implements ITCFTest, IFileSystem.DoneStat,
else {
this.handle = handle;
if (state == STATE_READ) {
- files.read(handle, 0, data.length + 1, this);
+ for (int i = 0; i < rnd.nextInt(8); i++) {
+ ReadCmd cmd = new ReadCmd();
+ cmd.offs = rnd.nextInt(data.length);
+ cmd.size = rnd.nextInt(data.length - cmd.offs) + 2;
+ cmds.put(files.read(handle, cmd.offs, cmd.size, this), cmd);
+ }
+ if (rnd.nextBoolean()) {
+ ReadCmd cmd = new ReadCmd();
+ cmd.offs = 0;
+ cmd.size = data.length + 1;
+ cmds.put(files.read(handle, cmd.offs, cmd.size, this), cmd);
+ }
+ else {
+ int pos = 0;
+ while (pos < data.length) {
+ int size = rnd.nextInt(data.length - pos) + 1;
+ ReadCmd cmd = new ReadCmd();
+ cmd.offs = pos;
+ cmd.size = size + 1;
+ cmds.put(files.read(handle, cmd.offs, cmd.size, this), cmd);
+ pos += size;
+ }
+ }
+ async_close = rnd.nextBoolean();
+ if (async_close) files.close(handle, this);
}
else if (state == STATE_WRITE) {
+ data = new byte[rnd.nextInt(0x1000) + 1];
rnd.nextBytes(data);
- files.write(handle, 0, data, 0, data.length, this);
+ if (rnd.nextBoolean()) {
+ cmds.put(files.write(handle, 0, data, 0, data.length, this), null);
+ }
+ else {
+ int pos = 0;
+ while (pos < data.length) {
+ int size = rnd.nextInt(data.length - pos) + 1;
+ cmds.put(files.write(handle, pos, data, pos, size, this), null);
+ pos += size;
+ }
+ }
+ async_close = rnd.nextBoolean();
+ if (async_close) files.close(handle, this);
}
else if (state == STATE_INP) {
Thread thread = new Thread() {
@@ -311,33 +356,39 @@ class TestFileSystem implements ITCFTest, IFileSystem.DoneStat,
}
public void doneWrite(IToken token, FileSystemException error) {
+ assert cmds.containsKey(token);
+ cmds.remove(token);
if (error != null) {
exit(error);
}
- else {
+ else if (cmds.size() == 0 && !async_close) {
files.close(handle, this);
}
}
public void doneRead(IToken token, FileSystemException error, byte[] data, boolean eof) {
+ assert cmds.containsKey(token);
+ ReadCmd cmd = (ReadCmd)cmds.remove(token);
if (error != null) {
exit(error);
}
- else if (!eof) {
- exit(new Exception("Invalid FileSysrem.read responce: EOF expected"));
- }
- else if (data.length != this.data.length) {
- exit(new Exception("Invalid FileSysrem.read responce: wrong data array size"));
- }
else {
- for (int i = 0; i < data.length; i++) {
- if (data[i] != this.data[i]) {
- exit(new Exception("Invalid FileSysrem.read responce: wrong data at offset " + i +
- ", expected " + this.data[i] + ", actual " + data[i]));
- return;
+ if (cmd.offs + cmd.size > this.data.length && !eof) {
+ exit(new Exception("Invalid FileSysrem.read responce: EOF expected"));
+ }
+ else if (data.length != (eof ? cmd.size - 1 : cmd.size)) {
+ exit(new Exception("Invalid FileSysrem.read responce: wrong data array size"));
+ }
+ else {
+ for (int i = 0; i < data.length; i++) {
+ if (data[i] != this.data[i + cmd.offs]) {
+ exit(new Exception("Invalid FileSysrem.read responce: wrong data at offset " + i +
+ ", expected " + this.data[i + cmd.offs] + ", actual " + data[i]));
+ return;
+ }
}
+ if (cmds.size() == 0 && !async_close) files.fstat(handle, this);
}
- files.fstat(handle, this);
}
}
diff --git a/tests/test-all b/tests/test-all
index 3305a916b..01c29f09d 100755
--- a/tests/test-all
+++ b/tests/test-all
@@ -209,7 +209,7 @@ function build_and_start_server()
if [ $OPSYS = Windows ] ; then
local SERVER_LFILE=`$SSH "cygpath -m $SERVER_LFILE"`
fi
- $SSH "$AGENT/server/obj/$OPSYS/$MACHINE/$CONF/server -s TCP::1535 -L$SERVER_LFILE -l0x800" >>logs/$LOGFILE 2>&1 &
+ $SSH -f "$AGENT/server/obj/$OPSYS/$MACHINE/$CONF/server -s TCP::1535 -L$SERVER_LFILE -l0x800" >>logs/$LOGFILE 2>&1
else
echo "<img src=\"../icons/cross.png\" title=\"Server build failed\"/>" >>$HTML
fi
@@ -250,7 +250,7 @@ function build_and_test_agent()
else
local AGENT_L_OPT=-L$VMBUILD/logs/agent-$HOST.txt
fi
- $SSH "$AGENT/obj/$OPSYS/$MACHINE/$CONF/agent -s TCP::1534 $AGENT_L_OPT -l0" >>logs/$LOGFILE 2>&1 &
+ $SSH -f "$AGENT/obj/$OPSYS/$MACHINE/$CONF/agent -s TCP::1534 $AGENT_L_OPT -l0" >>logs/$LOGFILE 2>&1
sleep 15
TESTURL1=TransportName=TCP:Host=$HOST:Port=1534
TESTURL2=TransportName=TCP:Host=$HOST:Port=1535
@@ -312,7 +312,7 @@ function build_and_test_agent()
TESTURL1=TransportName=TCP:Host=localhost:Port=1534
;;
esac
- $SSH "$AGENT/obj/$OPSYS/$MACHINE/$CONF/agent -s $AGENT_S_OPT $AGENT_L_OPT -l0" >>logs/$LOGFILE 2>&1 &
+ $SSH -f "$AGENT/obj/$OPSYS/$MACHINE/$CONF/agent -s $AGENT_S_OPT $AGENT_L_OPT -l0" >>logs/$LOGFILE 2>&1
sleep 25
echo >>logs/$LOGFILE
echo "Starting tests, target: $TESTURL2 $TESTURL1" >>logs/$LOGFILE

Back to the top