From e614223831f2b3cc9051ae88586370a7d5b63db2 Mon Sep 17 00:00:00 2001 From: aavit Date: Fri, 19 Nov 2010 13:22:02 +0100 Subject: Added clean abort, dryrun mode. And stop ignoring the unused byte in RGB32 --- tests/arthur/baselineserver/src/baselineserver.cpp | 3 +- tests/arthur/common/baselineprotocol.cpp | 51 ++++++++++++++++------ tests/arthur/common/baselineprotocol.h | 8 +++- 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 #include #include +#include #ifndef QMAKESPEC #define QMAKESPEC "Unknown" #endif +#if defined(Q_OS_WIN) +#include +#endif +#if defined(Q_OS_UNIX) +#include +#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() { @@ -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 (pinsert(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 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); } } -- cgit v0.12