diff options
author | aavit <qt-info@nokia.com> | 2010-11-05 14:33:41 (GMT) |
---|---|---|
committer | aavit <qt-info@nokia.com> | 2010-11-05 14:33:41 (GMT) |
commit | 111270e240320831038a47f7f0848a4f429d25d7 (patch) | |
tree | cde116e26d097072c7743949ffc2fd50bfb73bad | |
parent | a84181407f51cc855a6ddb2033a7aa6738354602 (diff) | |
download | Qt-111270e240320831038a47f7f0848a4f429d25d7.zip Qt-111270e240320831038a47f7f0848a4f429d25d7.tar.gz Qt-111270e240320831038a47f7f0848a4f429d25d7.tar.bz2 |
Add even more platform info, and make it expandable.
-rw-r--r-- | tests/arthur/baselineserver/src/baselineserver.cpp | 29 | ||||
-rw-r--r-- | tests/arthur/baselineserver/src/baselineserver.h | 2 | ||||
-rw-r--r-- | tests/arthur/baselineserver/src/htmlpage.cpp | 11 | ||||
-rw-r--r-- | tests/arthur/baselineserver/src/main.cpp | 3 | ||||
-rw-r--r-- | tests/arthur/common/baselineprotocol.cpp | 86 | ||||
-rw-r--r-- | tests/arthur/common/baselineprotocol.h | 26 | ||||
-rw-r--r-- | tests/auto/lancelot/lancelot.pro | 1 |
7 files changed, 89 insertions, 69 deletions
diff --git a/tests/arthur/baselineserver/src/baselineserver.cpp b/tests/arthur/baselineserver/src/baselineserver.cpp index dd26a85..03d6499 100644 --- a/tests/arthur/baselineserver/src/baselineserver.cpp +++ b/tests/arthur/baselineserver/src/baselineserver.cpp @@ -133,24 +133,29 @@ BaselineHandler::BaselineHandler(int socketDescriptor) proto.socket.setSocketDescriptor(socketDescriptor); } -QString BaselineHandler::logtime() +const char *BaselineHandler::logtime() { - return QTime::currentTime().toString(QLS("mm:ss.zzz")); + return 0; + //return QTime::currentTime().toString(QLS("mm:ss.zzz")); } void BaselineHandler::receiveRequest() { if (!connectionEstablished) { if (!proto.acceptConnection(&plat)) { - qWarning() << runId << logtime() << "Accepting new connection failed. " << proto.errorMessage(); - QThread::currentThread()->exit(1); + qWarning() << runId << logtime() << "Accepting new connection from" << proto.socket.peerAddress().toString() << "failed." << proto.errorMessage(); + proto.socket.disconnectFromHost(); return; } connectionEstablished = true; - qDebug() << runId << logtime() << "Connection established with" << plat.hostName << "[" << proto.socket.peerAddress().toString() << "]" - << "OS:" << plat.osName << "[" << plat.osVersion << "]" << "Qt version:" << plat.qtVersion << "[" << plat.buildKey << "]" - << "git commit:" << plat.gitCommit; - return; + QString logMsg; + foreach (QString key, plat.keys()) { + if (key != PI_HostName && key != PI_HostAddress) + logMsg += key + QLS(": '") + plat.value(key) + QLS("', "); + } + qDebug() << runId << logtime() << "Connection established with" << plat.value(PI_HostName) + << "[" << qPrintable(plat.value(PI_HostAddress)) << "]" << logMsg; + return; } QByteArray block; @@ -284,7 +289,7 @@ QString BaselineHandler::itemSubPath(const QString &engine, const QString &forma QString BaselineHandler::pathForItem(const ImageItem &item, bool isBaseline, bool absolute) { if (pathForRun.isNull()) { - QString host = plat.hostName.section(QLC('.'), 0, 0); // Filter away domain, if any + QString host = plat.value(PI_HostName).section(QLC('.'), 0, 0); // Filter away domain, if any if (host.isEmpty() || host == QLS("localhost")) { host = proto.socket.peerAddress().toString(); if (host.isEmpty()) @@ -438,11 +443,11 @@ void BaselineHandler::testPathMapping() item.imageChecksums << 0x0123456789abcdefULL; item.scriptChecksum = 0x0123; - plat.qtVersion = QLS("4.8.0"); - plat.buildKey = QLS("(nobuildkey)"); + plat.insert(PI_QtVersion, QLS("4.8.0")); + plat.insert(PI_BuildKey, QLS("(nobuildkey)")); foreach(const QString& host, hosts) { pathForRun = QString(); - plat.hostName = host; + plat.insert(PI_HostName, host); qDebug() << "Baseline from" << host << "->" << pathForItem(item, true).remove(BaselineServer::storagePath()); qDebug() << "Mismatch from" << host << "->" << pathForItem(item, false).remove(BaselineServer::storagePath()); } diff --git a/tests/arthur/baselineserver/src/baselineserver.h b/tests/arthur/baselineserver/src/baselineserver.h index bbebabb..e311527 100644 --- a/tests/arthur/baselineserver/src/baselineserver.h +++ b/tests/arthur/baselineserver/src/baselineserver.h @@ -116,7 +116,7 @@ private: void provideBaselineChecksums(const QByteArray &itemListBlock); void storeImage(const QByteArray &itemBlock, bool isBaseline); QString pathForItem(const ImageItem &item, bool isBaseline = true, bool absolute = true); - QString logtime(); + const char *logtime(); QString computeMismatchScore(const QImage& baseline, const QImage& rendered); QString engineForItem(const ImageItem &item); diff --git a/tests/arthur/baselineserver/src/htmlpage.cpp b/tests/arthur/baselineserver/src/htmlpage.cpp index 00d07f1..ad7f8b7 100644 --- a/tests/arthur/baselineserver/src/htmlpage.cpp +++ b/tests/arthur/baselineserver/src/htmlpage.cpp @@ -89,9 +89,12 @@ void HTMLPage::writeHeader(const ImageItem &item) out.setDevice(&file); out << "<html><body><h1>Lancelot results from run " << id << "</h1>\n\n"; - out << "<h3>Host: " << plat.hostName << " [" << address << "] OS: " << plat.osName << " [enum: " << plat.osVersion << "]</h3>\n"; - out << "<h3>Qt version: " << plat.qtVersion << " [commit: " << plat.gitCommit << "] Build key: \"" << plat.buildKey << "\"</h3>\n"; - out << "<h3>Engine: " << item.engineAsString() << " Format: " << item.formatAsString() << "</h3>\n\n"; + out << "<h3>Platform Info:</h3>\n"; + out << "<table>\n"; + foreach (QString key, plat.keys()) + out << "<tr><td>" << key << "</td><td>" << plat.value(key) << "</td></tr>\n"; + out << "</table>\n"; + #if 0 out << "<h3><a href=\"/cgi-bin/server.cgi?cmd=updateAllBaselines&id="<< id << "&host=" << plat.hostName << "&engine=" << item.engineAsString() << "&format=" << item.formatAsString() @@ -161,7 +164,7 @@ void HTMLPage::end() if (imageItems.at(i).status == ImageItem::IgnoreItem) { out << "<span style=\"background-color:yellow\">Blacklisted</span><br>" "<a href=\"/cgi-bin/server.cgi?cmd=whitelist&scriptName=" - << imageItems.at(i).scriptName << "&host=" << plat.hostName + << imageItems.at(i).scriptName << "&host=" << plat.value(PI_HostName) << "&engine=" << imageItems.at(i).engineAsString() << "&format=" << imageItems.at(i).formatAsString() << "&url=" << pageUrl diff --git a/tests/arthur/baselineserver/src/main.cpp b/tests/arthur/baselineserver/src/main.cpp index dcddfdf..a5ec4db 100644 --- a/tests/arthur/baselineserver/src/main.cpp +++ b/tests/arthur/baselineserver/src/main.cpp @@ -64,6 +64,7 @@ int main(int argc, char *argv[]) return 1; } - qDebug() << "Listening for connections"; + qDebug() << "\n*****" << argv[0] << "started, ready to serve on port" << BaselineProtocol::ServerPort + << "with baseline protocol version" << BaselineProtocol::ProtocolVersion << "*****\n"; return a.exec(); } diff --git a/tests/arthur/common/baselineprotocol.cpp b/tests/arthur/common/baselineprotocol.cpp index baa6f8b..3e60011 100644 --- a/tests/arthur/common/baselineprotocol.cpp +++ b/tests/arthur/common/baselineprotocol.cpp @@ -45,30 +45,40 @@ #include <QHostInfo> #include <QSysInfo> #include <QProcess> +#include <QFileInfo> + +#ifndef QMAKESPEC +#define QMAKESPEC "Unknown" +#endif PlatformInfo::PlatformInfo(bool useLocal) + : QMap<QString, QString>() { if (useLocal) { - buildKey = QLibraryInfo::buildKey(); - qtVersion = QLatin1String(qVersion()); - hostName = QHostInfo::localHostName(); - osVersion = -1; + insert(PI_HostName, QHostInfo::localHostName()); + insert(PI_QtVersion, QLS(qVersion())); + insert(PI_QMakeSpec, QFileInfo(QLS(QMAKESPEC)).fileName()); + insert(PI_BuildKey, QLibraryInfo::buildKey()); #if defined(Q_OS_LINUX) - osName = QLatin1String("Linux"); + insert(PI_OSName, QLS("Linux")); + QProcess uname; + uname.start(QLS("uname"), QStringList() << QLS("-r")); + if (uname.waitForFinished(3000)) + insert(PI_OSVersion, QString::fromLocal8Bit(uname.readAllStandardOutput().constData()).simplified()); #elif defined(Q_OS_WINCE) - osName = QLatin1String("WinCE"); - osVersion = QSysInfo::windowsVersion(); + insert(PI_OSName, QLS("WinCE")); + insert(PI_OSVersion, QString::number(QSysInfo::windowsVersion())); #elif defined(Q_OS_WIN) - osName = QLatin1String("Windows"); - osVersion = QSysInfo::windowsVersion(); + insert(PI_OSName, QLS("Windows")); + insert(PI_OSVersion, QString::number(QSysInfo::windowsVersion())); #elif defined(Q_OS_MAC) - osName = QLatin1String("MacOS"); - osVersion = qMacVersion(); + insert(PI_OSName, QLS("MacOS")); + insert(PI_OSVersion, QString::number(qMacVersion())); #elif defined(Q_OS_SYMBIAN) - osName = QLatin1String("Symbian"); - osVersion = QSysInfo::symbianVersion(); + insert(PI_OSName, QLS("Symbian")); + insert(PI_OSVersion, QString::number(QSysInfo::symbianVersion()); #else - osName = QLatin1String("Other"); + insert(PI_OSName, QLS("Other")); #endif QProcess git; @@ -80,27 +90,23 @@ PlatformInfo::PlatformInfo(bool useLocal) #else cmd = QLS("git"); #endif - args << QLS("log") << QLS("--max-count=1") << QLS("--pretty=%H"); + args << QLS("log") << QLS("--max-count=1") << QLS("--pretty=%H [%an] [%ad] %s"); git.start(cmd, args); git.waitForFinished(3000); if (!git.exitCode()) - gitCommit = QString::fromLocal8Bit(git.readAllStandardOutput().constData()).trimmed(); + insert(PI_GitCommit, QString::fromLocal8Bit(git.readAllStandardOutput().constData()).simplified()); else - gitCommit = QLS("Unknown"); + insert(PI_GitCommit, QLS("Unknown")); } -} -QDataStream & operator<< (QDataStream &stream, const PlatformInfo &p) -{ - stream << p.hostName << p.osName << p.osVersion << p.qtVersion << p.buildKey << p.gitCommit; - return stream; + QByteArray gb = qgetenv("PULSE_GIT_BRANCH"); + if (!gb.isEmpty()) + insert(PI_PulseGitBranch, QString::fromLatin1(gb)); + QByteArray tb = qgetenv("PULSE_TESTR_BRANCH"); + if (!tb.isEmpty()) + insert(PI_PulseTestrBranch, QString::fromLatin1(tb)); } -QDataStream & operator>> (QDataStream& stream, PlatformInfo& p) -{ - stream >> p.hostName >> p.osName >> p.osVersion >> p.qtVersion >> p.buildKey >> p.gitCommit; - return stream; -} ImageItem &ImageItem::operator=(const ImageItem &other) { @@ -151,15 +157,15 @@ QString ImageItem::engineAsString() const { switch (engine) { case Raster: - return QLatin1String("Raster"); + return QLS("Raster"); break; case OpenGL: - return QLatin1String("OpenGL"); + return QLS("OpenGL"); break; default: break; } - return QLatin1String("Unknown"); + return QLS("Unknown"); } QString ImageItem::formatAsString() const @@ -184,8 +190,8 @@ QString ImageItem::formatAsString() const "ARGB4444-Premult" }; if (renderFormat < 0 || renderFormat >= numFormats) - return QLatin1String("UnknownFormat"); - return QLatin1String(formatNames[renderFormat]); + return QLS("UnknownFormat"); + return QLS(formatNames[renderFormat]); } QDataStream & operator<< (QDataStream &stream, const ImageItem &ii) @@ -223,7 +229,7 @@ bool BaselineProtocol::connect() socket.connectToHost(serverName, ServerPort); if (!socket.waitForConnected(Timeout)) { - errMsg += QLatin1String("TCP connectToHost failed. Host:") + serverName + QLatin1String(" port:") + QString::number(ServerPort); + errMsg += QLS("TCP connectToHost failed. Host:") + serverName + QLS(" port:") + QString::number(ServerPort); return false; } @@ -232,13 +238,13 @@ bool BaselineProtocol::connect() QDataStream ds(&block, QIODevice::ReadWrite); ds << pi; if (!sendBlock(AcceptPlatformInfo, block)) { - errMsg += QLatin1String("Failed to send data to server."); + errMsg += QLS("Failed to send data to server."); return false; } Command cmd = Ack; if (!receiveBlock(&cmd, &block) || cmd != Ack) { - errMsg += QLatin1String("Failed to get response from server."); + errMsg += QLS("Failed to get response from server."); return false; } @@ -258,6 +264,7 @@ bool BaselineProtocol::acceptConnection(PlatformInfo *pi) if (pi) { QDataStream ds(block); ds >> *pi; + pi->insert(PI_HostAddress, socket.peerAddress().toString()); } if (!sendBlock(Ack, QByteArray())) @@ -307,7 +314,7 @@ bool BaselineProtocol::sendItem(Command cmd, const ImageItem &item) QDataStream ds(&buf); ds << item; if (!sendBlock(cmd, buf.data())) { - errMsg.prepend(QLatin1String("Failed to submit image to server. ")); + errMsg.prepend(QLS("Failed to submit image to server. ")); return false; } return true; @@ -334,9 +341,8 @@ bool BaselineProtocol::receiveBlock(Command *cmd, QByteArray *block) quint16 rcvProtocolVersion, rcvCmd; ds >> rcvProtocolVersion >> rcvCmd; if (rcvProtocolVersion != ProtocolVersion) { - // TBD: More resilient handling of this case; the server should accept client's version - errMsg = QLatin1String("Server protocol version mismatch, received:") + QString::number(rcvProtocolVersion); - + errMsg = QLS("Baseline protocol version mismatch, received:") + QString::number(rcvProtocolVersion) + + QLS(" expected:") + QString::number(ProtocolVersion); return false; } if (cmd) @@ -368,6 +374,6 @@ QString BaselineProtocol::errorMessage() { QString ret = errMsg; if (socket.error() >= 0) - ret += QLatin1String(" Socket state: ") + socket.errorString(); + ret += QLS(" Socket state: ") + socket.errorString(); return ret; } diff --git a/tests/arthur/common/baselineprotocol.h b/tests/arthur/common/baselineprotocol.h index a0ae028..162a19f 100644 --- a/tests/arthur/common/baselineprotocol.h +++ b/tests/arthur/common/baselineprotocol.h @@ -45,25 +45,29 @@ #include <QTcpSocket> #include <QImage> #include <QVector> +#include <QMap> #define QLS QLatin1String #define QLC QLatin1Char #define FileFormat "png" -struct PlatformInfo +const QString PI_HostName(QLS("HostName")); +const QString PI_HostAddress(QLS("HostAddress")); +const QString PI_OSName(QLS("OSName")); +const QString PI_OSVersion(QLS("OSVersion")); +const QString PI_QtVersion(QLS("QtVersion")); +const QString PI_BuildKey(QLS("BuildKey")); +const QString PI_GitCommit(QLS("GitCommit")); +const QString PI_QMakeSpec(QLS("QMakeSpec")); +const QString PI_PulseGitBranch(QLS("PulseGitBranch")); +const QString PI_PulseTestrBranch(QLS("PulseTestrBranch")); + +class PlatformInfo : public QMap<QString, QString> { +public: PlatformInfo(bool useLocal = false); - - QString hostName; - QString osName; - int osVersion; - QString qtVersion; - QString buildKey; - QString gitCommit; }; -QDataStream & operator<< (QDataStream &stream, const PlatformInfo &p); -QDataStream & operator>> (QDataStream& stream, PlatformInfo& p); struct ImageItem { @@ -117,7 +121,7 @@ public: // Important constants here // **************************************************** enum Constant { - ProtocolVersion = 1, + ProtocolVersion = 2, ServerPort = 54129, Timeout = 10000 }; diff --git a/tests/auto/lancelot/lancelot.pro b/tests/auto/lancelot/lancelot.pro index 3859a55..6498f6c 100644 --- a/tests/auto/lancelot/lancelot.pro +++ b/tests/auto/lancelot/lancelot.pro @@ -8,5 +8,6 @@ HEADERS += $$QT_SOURCE_TREE/tests/arthur/common/paintcommands.h RESOURCES += $$QT_SOURCE_TREE/tests/arthur/common/images.qrc include($$QT_SOURCE_TREE/tests/arthur/common/baselineprotocol.pri) +DEFINES += QMAKESPEC=\\\"$$QMAKESPEC\\\" !symbian:!wince*:DEFINES += SRCDIR=\\\"$$PWD\\\" |