summaryrefslogtreecommitdiffstats
path: root/tests/auto/qlocalsocket/lackey/scripts
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@nokia.com>2009-03-23 09:18:55 (GMT)
committerSimon Hausmann <simon.hausmann@nokia.com>2009-03-23 09:18:55 (GMT)
commite5fcad302d86d316390c6b0f62759a067313e8a9 (patch)
treec2afbf6f1066b6ce261f14341cf6d310e5595bc1 /tests/auto/qlocalsocket/lackey/scripts
downloadQt-e5fcad302d86d316390c6b0f62759a067313e8a9.zip
Qt-e5fcad302d86d316390c6b0f62759a067313e8a9.tar.gz
Qt-e5fcad302d86d316390c6b0f62759a067313e8a9.tar.bz2
Long live Qt 4.5!
Diffstat (limited to 'tests/auto/qlocalsocket/lackey/scripts')
-rwxr-xr-xtests/auto/qlocalsocket/lackey/scripts/client.js35
-rw-r--r--tests/auto/qlocalsocket/lackey/scripts/server.js19
2 files changed, 54 insertions, 0 deletions
diff --git a/tests/auto/qlocalsocket/lackey/scripts/client.js b/tests/auto/qlocalsocket/lackey/scripts/client.js
new file mode 100755
index 0000000..76cc0b9
--- /dev/null
+++ b/tests/auto/qlocalsocket/lackey/scripts/client.js
@@ -0,0 +1,35 @@
+#/bin/qscript
+function QVERIFY(x, socket) {
+ if (!(x)) {
+ throw(socket.errorString());
+ }
+}
+
+var socket = new QScriptLocalSocket;
+var tries = 0;
+do {
+ socket.serverName = "qlocalsocket_autotest";
+ if ((socket.errorString() != "QLocalSocket::connectToServer: Invalid name")
+ && (socket.errorString() != "QLocalSocket::connectToServer: Connection refused"))
+ break;
+ socket.sleep(1);
+ ++tries;
+ print("isConnected:", socket.isConnected());
+} while ((socket.errorString() == "QLocalSocket::connectToServer: Invalid name"
+ || (socket.errorString() == "QlocalSocket::connectToServer: Connection refused"))
+ && tries < 5000);
+if (tries == 5000) {
+ print("too many tries, exiting");
+} else {
+socket.waitForConnected();
+//print("isConnected:", socket.isConnected());
+if (!socket.isConnected())
+ print("Not Connected:", socket.errorString());
+socket.waitForReadyRead();
+var text = socket.readLine();
+var testLine = "test";
+QVERIFY((text == testLine), socket);
+QVERIFY((socket.errorString() == "Unknown error"), socket);
+socket.close();
+//print("client: exiting", text);
+}
diff --git a/tests/auto/qlocalsocket/lackey/scripts/server.js b/tests/auto/qlocalsocket/lackey/scripts/server.js
new file mode 100644
index 0000000..98a83bc
--- /dev/null
+++ b/tests/auto/qlocalsocket/lackey/scripts/server.js
@@ -0,0 +1,19 @@
+#/bin/qscript
+function QVERIFY(x, server) {
+ if (!(x)) {
+ throw(server.errorString());
+ }
+}
+var server = new QScriptLocalServer;
+QVERIFY(server.listen("qlocalsocket_autotest"), server);
+var done = args[1];
+var testLine = "test";
+while (done > 0) {
+ QVERIFY(server.waitForNewConnection(), server);
+ var serverSocket = server.nextConnection();
+ serverSocket.write(testLine);
+ QVERIFY(serverSocket.waitForBytesWritten(), serverSocket);
+ QVERIFY(serverSocket.errorString() == ""
+ ||serverSocket.errorString() == "Unknown error", serverSocket);
+ --done;
+}