diff options
author | aavit <qt-info@nokia.com> | 2010-11-19 12:22:02 (GMT) |
---|---|---|
committer | aavit <qt-info@nokia.com> | 2010-11-19 12:22:02 (GMT) |
commit | e614223831f2b3cc9051ae88586370a7d5b63db2 (patch) | |
tree | 09378bec6bcf791191ba2ee243bf27ff26fafed5 /tests | |
parent | eedfeabfba1bbbc26792966238463ca3d22665a9 (diff) | |
download | Qt-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')
-rw-r--r-- | tests/arthur/baselineserver/src/baselineserver.cpp | 3 | ||||
-rw-r--r-- | tests/arthur/common/baselineprotocol.cpp | 51 | ||||
-rw-r--r-- | tests/arthur/common/baselineprotocol.h | 8 | ||||
-rw-r--r-- | tests/auto/lancelot/tst_lancelot.cpp | 15 |
4 files changed, 53 insertions, 24 deletions
diff --git a/tests/arthur/baselineserver/src/baselineserver.cpp b/tests/arthur/baselineserver/src/baselineserver.cpp index 3f4ae95..7679f13 100644 --- a/tests/arthur/baselineserver/src/baselineserver.cpp +++ b/tests/arthur/baselineserver/src/baselineserver.cpp @@ -165,11 +165,12 @@ void BaselineHandler::receiveRequest() } else if (branch != QLS("master-integration") || !plat.value(PI_GitCommit).contains(QLS("Merge branch 'master' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into master-integration"))) { qDebug() << runId << logtime() << "Did not pass branch/staging repo filter, disconnecting."; - // TBD: Cleaner termination + proto.sendBlock(BaselineProtocol::Abort, QByteArray("This branch/staging repo is not assigned to be tested.")); proto.socket.disconnectFromHost(); return; } + proto.sendBlock(BaselineProtocol::Ack, QByteArray()); connectionEstablished = true; return; } 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; diff --git a/tests/auto/lancelot/tst_lancelot.cpp b/tests/auto/lancelot/tst_lancelot.cpp index a06a251..8467672 100644 --- a/tests/auto/lancelot/tst_lancelot.cpp +++ b/tests/auto/lancelot/tst_lancelot.cpp @@ -72,6 +72,7 @@ private: BaselineProtocol proto; ImageItemList baseList; QHash<QString, QStringList> scripts; + bool dryRunMode; private slots: void initTestCase(); @@ -103,13 +104,8 @@ void tst_Lancelot::initTestCase() #if defined(Q_OS_SOMEPLATFORM) QSKIP("This test is not supported on this platform.", SkipAll); #endif - if (!proto.connect()) { - QTest::qSleep(3000); // Wait a bit and try again, the server might just be restarting - if (!proto.connect()) { - QWARN(qPrintable(proto.errorMessage())); - QSKIP("Communication with baseline image server failed.", SkipAll); - } - } + if (!proto.connect(&dryRunMode)) + QSKIP(qPrintable(proto.errorMessage()), SkipAll); QDir qpsDir(scriptsDir); QStringList files = qpsDir.entryList(QStringList() << QLatin1String("*.qps"), QDir::Files | QDir::Readable); @@ -250,7 +246,10 @@ void tst_Lancelot::runTestSuite() QByteArray serverMsg; if (!proto.submitMismatch(rendered, &serverMsg)) serverMsg = "Failed to submit mismatching image to server."; - QFAIL("Rendered image differs from baseline.\n" + serverMsg); + if (dryRunMode) + qDebug() << "Dryrun mode, ignoring detected mismatch." << serverMsg; + else + QFAIL("Rendered image differs from baseline.\n" + serverMsg); } } |