summaryrefslogtreecommitdiffstats
path: root/tests/arthur/common
diff options
context:
space:
mode:
authoraavit <qt-info@nokia.com>2010-11-19 12:22:02 (GMT)
committeraavit <qt-info@nokia.com>2010-11-19 12:22:02 (GMT)
commite614223831f2b3cc9051ae88586370a7d5b63db2 (patch)
tree09378bec6bcf791191ba2ee243bf27ff26fafed5 /tests/arthur/common
parenteedfeabfba1bbbc26792966238463ca3d22665a9 (diff)
downloadQt-e614223831f2b3cc9051ae88586370a7d5b63db2.zip
Qt-e614223831f2b3cc9051ae88586370a7d5b63db2.tar.gz
Qt-e614223831f2b3cc9051ae88586370a7d5b63db2.tar.bz2
Added clean abort, dryrun mode. And stop ignoring the unused byte in RGB32
Diffstat (limited to 'tests/arthur/common')
-rw-r--r--tests/arthur/common/baselineprotocol.cpp51
-rw-r--r--tests/arthur/common/baselineprotocol.h8
2 files changed, 44 insertions, 15 deletions
diff --git a/tests/arthur/common/baselineprotocol.cpp b/tests/arthur/common/baselineprotocol.cpp
index 2a41104..6d26e9a 100644
--- a/tests/arthur/common/baselineprotocol.cpp
+++ b/tests/arthur/common/baselineprotocol.cpp
@@ -47,11 +47,28 @@
#include <QProcess>
#include <QFileInfo>
#include <QDir>
+#include <QTime>
#ifndef QMAKESPEC
#define QMAKESPEC "Unknown"
#endif
+#if defined(Q_OS_WIN)
+#include <QtCore/qt_windows.h>
+#endif
+#if defined(Q_OS_UNIX)
+#include <time.h>
+#endif
+void BaselineProtocol::sysSleep(int ms)
+{
+#if defined(Q_OS_WIN)
+ Sleep(DWORD(ms));
+#else
+ struct timespec ts = { ms / 1000, (ms % 1000) * 1000 * 1000 };
+ nanosleep(&ts, NULL);
+#endif
+}
+
PlatformInfo::PlatformInfo(bool useLocal)
: QMap<QString, QString>()
{
@@ -141,12 +158,6 @@ quint64 ImageItem::computeChecksum(const QImage &image)
p += bpl;
}
}
- if (img.format() == QImage::Format_RGB32) { // Thank you, Haavard
- quint32 *p = (quint32 *)img.bits();
- const quint32 *end = p + (img.byteCount()/4);
- while (p<end)
- *p++ &= RGB_MASK;
- }
quint32 h1 = 0xfeedbacc;
quint32 h2 = 0x21604894;
@@ -221,7 +232,7 @@ BaselineProtocol::~BaselineProtocol()
}
-bool BaselineProtocol::connect()
+bool BaselineProtocol::connect(bool *dryrun)
{
errMsg.clear();
QByteArray serverName(qgetenv("QT_LANCELOT_SERVER"));
@@ -230,8 +241,11 @@ bool BaselineProtocol::connect()
socket.connectToHost(serverName, ServerPort);
if (!socket.waitForConnected(Timeout)) {
- errMsg += QLS("TCP connectToHost failed. Host:") + serverName + QLS(" port:") + QString::number(ServerPort);
- return false;
+ sysSleep(Timeout); // Wait a bit and try again, the server might just be restarting
+ if (!socket.waitForConnected(Timeout)) {
+ errMsg += QLS("TCP connectToHost failed. Host:") + serverName + QLS(" port:") + QString::number(ServerPort);
+ return false;
+ }
}
PlatformInfo pi(true);
@@ -243,12 +257,25 @@ bool BaselineProtocol::connect()
return false;
}
- Command cmd = Ack;
- if (!receiveBlock(&cmd, &block) || cmd != Ack) {
+ Command cmd = UnknownError;
+ if (!receiveBlock(&cmd, &block)) {
errMsg += QLS("Failed to get response from server.");
return false;
}
+ if (cmd == Abort) {
+ errMsg += QLS("Server aborted connection. Reason: ") + QString::fromLatin1(block);
+ return false;
+ }
+
+ if (dryrun)
+ *dryrun = (cmd == DoDryRun);
+
+ if (cmd != Ack && cmd != DoDryRun) {
+ errMsg += QLS("Unexpected response from server.");
+ return false;
+ }
+
return true;
}
@@ -268,8 +295,6 @@ bool BaselineProtocol::acceptConnection(PlatformInfo *pi)
pi->insert(PI_HostAddress, socket.peerAddress().toString());
}
- if (!sendBlock(Ack, QByteArray()))
- return false;
return true;
}
diff --git a/tests/arthur/common/baselineprotocol.h b/tests/arthur/common/baselineprotocol.h
index 162a19f..9f59454 100644
--- a/tests/arthur/common/baselineprotocol.h
+++ b/tests/arthur/common/baselineprotocol.h
@@ -123,7 +123,7 @@ public:
enum Constant {
ProtocolVersion = 2,
ServerPort = 54129,
- Timeout = 10000
+ Timeout = 5000
};
enum Command {
@@ -135,10 +135,12 @@ public:
AcceptMismatch = 5,
// Responses
Ack = 128,
+ Abort = 129,
+ DoDryRun = 130
};
// For client:
- bool connect();
+ bool connect(bool *dryrun = 0);
bool requestBaselineChecksums(ImageItemList *itemList);
bool submitNewBaseline(const ImageItem &item, QByteArray *serverMsg);
bool submitMismatch(const ImageItem &item, QByteArray *serverMsg);
@@ -153,6 +155,8 @@ private:
bool sendBlock(Command cmd, const QByteArray &block);
bool receiveBlock(Command *cmd, QByteArray *block);
+ void sysSleep(int ms);
+
QString errMsg;
QTcpSocket socket;