diff options
author | aavit <qt-info@nokia.com> | 2010-12-08 14:35:54 (GMT) |
---|---|---|
committer | aavit <qt-info@nokia.com> | 2010-12-08 14:35:54 (GMT) |
commit | d21eee4fb39ee8378bb87187cec5e46275dc31ed (patch) | |
tree | baf380d2e6c34922e7c0e83527c42fe619f7839d /tests/arthur | |
parent | 993f9b23d72ec74453163413403d0cf06d9f08f4 (diff) | |
download | Qt-d21eee4fb39ee8378bb87187cec5e46275dc31ed.zip Qt-d21eee4fb39ee8378bb87187cec5e46275dc31ed.tar.gz Qt-d21eee4fb39ee8378bb87187cec5e46275dc31ed.tar.bz2 |
Make protocol less lancelot-specific, prepare use in other testcases
Diffstat (limited to 'tests/arthur')
-rw-r--r-- | tests/arthur/baselineserver/src/baselineserver.cpp | 30 | ||||
-rw-r--r-- | tests/arthur/baselineserver/src/htmlpage.cpp | 15 | ||||
-rw-r--r-- | tests/arthur/common/baselineprotocol.cpp | 28 | ||||
-rw-r--r-- | tests/arthur/common/baselineprotocol.h | 31 |
4 files changed, 49 insertions, 55 deletions
diff --git a/tests/arthur/baselineserver/src/baselineserver.cpp b/tests/arthur/baselineserver/src/baselineserver.cpp index 53e40b6..90eb594 100644 --- a/tests/arthur/baselineserver/src/baselineserver.cpp +++ b/tests/arthur/baselineserver/src/baselineserver.cpp @@ -208,8 +208,8 @@ void BaselineHandler::provideBaselineChecksums(const QByteArray &itemListBlock) ImageItemList itemList; QDataStream ds(itemListBlock); ds >> itemList; - qDebug() << runId << logtime() << "Received request for checksums for" << itemList.count() << "items, engine" - << itemList.at(0).engineAsString() << "pixel format" << itemList.at(0).formatAsString(); + qDebug() << runId << logtime() << "Received request for checksums for" << itemList.count() + << "items in test function" << itemList.at(0).testFunction; for (ImageItemList::iterator i = itemList.begin(); i != itemList.end(); ++i) { i->imageChecksums.clear(); @@ -232,10 +232,10 @@ void BaselineHandler::provideBaselineChecksums(const QByteArray &itemListBlock) if (file.open(QIODevice::ReadOnly)) { QTextStream in(&file); do { - QString scriptName = in.readLine(); - if (!scriptName.isNull()) { + QString itemName = in.readLine(); + if (!itemName.isNull()) { for (ImageItemList::iterator i = itemList.begin(); i != itemList.end(); ++i) { - if (i->scriptName == scriptName) + if (i->itemName == itemName) i->status = ImageItem::IgnoreItem; } } @@ -258,7 +258,7 @@ void BaselineHandler::storeImage(const QByteArray &itemBlock, bool isBaseline) ds >> item; QString prefix = pathForItem(item, isBaseline); - qDebug() << runId << logtime() << "Received" << (isBaseline ? "baseline" : "mismatched") << "image for:" << item.scriptName << "Storing in" << prefix; + qDebug() << runId << logtime() << "Received" << (isBaseline ? "baseline" : "mismatched") << "image for:" << item.itemName << "Storing in" << prefix; QString dir = prefix.section(QLC('/'), 0, -2); QDir cwd; @@ -333,17 +333,17 @@ QString BaselineHandler::pathForItem(const ImageItem &item, bool isBaseline, boo if (mapped.isEmpty()) mapPlatformInfo(); - QString itemName = item.scriptName; - if (itemName.contains(QLC('.'))) - itemName.replace(itemName.lastIndexOf(QLC('.')), 1, QLC('_')); + QString itemName = item.itemName; + itemName.replace(QLC('.'), QLC('_')); itemName.append(QLC('_')); - itemName.append(QString::number(item.scriptChecksum, 16).rightJustified(4, QLC('0'))); + itemName.append(QString::number(item.itemChecksum, 16).rightJustified(4, QLC('0'))); QStringList path; if (absolute) path += BaselineServer::storagePath(); + path += mapped.value(PI_TestCase); path += QLS(isBaseline ? "baselines" : "mismatches"); - path += item.engineAsString() + QLC('_') + item.formatAsString(); + path += item.testFunction; path += mapped.value(PI_QtVersion); path += mapped.value(PI_QMakeSpec); path += mapped.value(PI_HostName); @@ -397,6 +397,7 @@ QString BaselineHandler::updateSingleBaseline(const QString &oldBaseline, const return res; } + QString BaselineHandler::blacklistTest(const QString &context, const QString &itemId, bool removeFromBlacklist) { QFile file(BaselineServer::storagePath() + QLC('/') + context + QLS("/BLACKLIST")); @@ -439,11 +440,10 @@ void BaselineHandler::testPathMapping() << QLS("localhost"); ImageItem item; - item.scriptName = QLS("arcs.qps"); - item.engine = ImageItem::Raster; - item.renderFormat = QImage::Format_ARGB32_Premultiplied; + item.testFunction = QLS("testPathMapping"); + item.itemName = QLS("arcs.qps"); item.imageChecksums << 0x0123456789abcdefULL; - item.scriptChecksum = 0x0123; + item.itemChecksum = 0x0123; plat.insert(PI_QtVersion, QLS("4.8.0")); plat.insert(PI_BuildKey, QLS("(nobuildkey)")); diff --git a/tests/arthur/baselineserver/src/htmlpage.cpp b/tests/arthur/baselineserver/src/htmlpage.cpp index 11c2eac..2b16d25 100644 --- a/tests/arthur/baselineserver/src/htmlpage.cpp +++ b/tests/arthur/baselineserver/src/htmlpage.cpp @@ -69,7 +69,7 @@ void HTMLPage::start(const QString &storagepath, const QString &runId, const Pla ctx = context; root = storagepath + QLC('/'); imageItems = itemList; - reportDir = pinfo.value(PI_PulseGitBranch).isEmpty() ? QLS("reports/adhoc/") : QLS("reports/pulse/"); + reportDir = pinfo.value(PI_TestCase) + QLC('/') + (pinfo.value(PI_PulseGitBranch).isEmpty() ? QLS("reports/adhoc/") : QLS("reports/pulse/")); QString dir = root + reportDir; QDir cwd; if (!cwd.exists(dir)) @@ -79,8 +79,7 @@ void HTMLPage::start(const QString &storagepath, const QString &runId, const Pla void HTMLPage::writeHeader(const ImageItem &item) { - path = reportDir + id + QLC('_') + item.engineAsString() - + QLC('_') + item.formatAsString() + QLS(".html"); + path = reportDir + id + QLC('_') + item.testFunction + QLS(".html"); QString pageUrl = BaselineServer::baseUrl() + path; @@ -126,7 +125,7 @@ void HTMLPage::addItem(const QString &baseline, const QString &rendered, const I QString pageUrl = BaselineServer::baseUrl() + path; out << "<tr>\n"; - out << "<td>" << item.scriptName << "</td>\n"; + out << "<td>" << item.itemName << "</td>\n"; QStringList images = QStringList() << baseline << rendered << compared; foreach(const QString& img, images) out << "<td><a href=\"/" << img << "\"><img src=\"/" << generateThumbnail(img) << "\" width=240 height=240></a></td>\n"; @@ -135,7 +134,7 @@ void HTMLPage::addItem(const QString &baseline, const QString &rendered, const I << "<p><a href=\"/cgi-bin/server.cgi?cmd=updateSingleBaseline&oldBaseline=" << baseline << "&newBaseline=" << rendered << "&url=" << pageUrl << "\">Replace baseline with rendered</a></p>\n" << "<p><a href=\"/cgi-bin/server.cgi?cmd=blacklist&context=" << ctx - << "&itemId=" << item.scriptName << "&url=" << pageUrl << "\">Blacklist this item</a></p>\n" + << "&itemId=" << item.itemName << "&url=" << pageUrl << "\">Blacklist this item</a></p>\n" << "<p><a href=\"/cgi-bin/server.cgi?cmd=view&baseline=" << baseline << "&rendered=" << rendered << "&compared=" << compared << "&url=" << pageUrl << "\">View</a></p>\n" << "</td>\n"; @@ -144,7 +143,7 @@ void HTMLPage::addItem(const QString &baseline, const QString &rendered, const I QMutableVectorIterator<ImageItem> it(imageItems); while (it.hasNext()) { it.next(); - if (it.value().scriptName == item.scriptName) { + if (it.value().itemName == item.itemName) { it.remove(); break; } @@ -158,11 +157,11 @@ void HTMLPage::end() // Add the names of the scripts that passed the test, or were blacklisted QString pageUrl = BaselineServer::baseUrl() + path; for (int i=0; i<imageItems.count(); ++i) { - out << "<tr><td>" << imageItems.at(i).scriptName << "</td><td>N/A</td><td>N/A</td><td>N/A</td><td>"; + out << "<tr><td>" << imageItems.at(i).itemName << "</td><td>N/A</td><td>N/A</td><td>N/A</td><td>"; if (imageItems.at(i).status == ImageItem::IgnoreItem) { out << "<span style=\"background-color:yellow\">Blacklisted</span> " << "<a href=\"/cgi-bin/server.cgi?cmd=whitelist&context=" << ctx - << "&itemId=" << imageItems.at(i).scriptName << "&url=" << pageUrl + << "&itemId=" << imageItems.at(i).itemName << "&url=" << pageUrl << "\">Whitelist item</a>"; } else { out << "<span style=\"color:green\">Test passed</span>"; diff --git a/tests/arthur/common/baselineprotocol.cpp b/tests/arthur/common/baselineprotocol.cpp index 5ed58b4..c7e9e72 100644 --- a/tests/arthur/common/baselineprotocol.cpp +++ b/tests/arthur/common/baselineprotocol.cpp @@ -128,11 +128,10 @@ PlatformInfo::PlatformInfo(bool useLocal) ImageItem &ImageItem::operator=(const ImageItem &other) { - scriptName = other.scriptName; - scriptChecksum = other.scriptChecksum; + testFunction = other.testFunction; + itemName = other.itemName; + itemChecksum = other.itemChecksum; status = other.status; - renderFormat = other.renderFormat; - engine = other.engine; image = other.image; imageChecksums = other.imageChecksums; return *this; @@ -165,6 +164,7 @@ quint64 ImageItem::computeChecksum(const QImage &image) return (quint64(h1) << 32) | h2; } +#if 0 QString ImageItem::engineAsString() const { switch (engine) { @@ -205,6 +205,7 @@ QString ImageItem::formatAsString() const return QLS("UnknownFormat"); return QLS(formatNames[renderFormat]); } +#endif void ImageItem::writeImageToStream(QDataStream &out) const { @@ -249,20 +250,16 @@ void ImageItem::readImageFromStream(QDataStream &in) QDataStream & operator<< (QDataStream &stream, const ImageItem &ii) { - stream << ii.scriptName << ii.scriptChecksum << quint8(ii.status) << quint8(ii.renderFormat) - << quint8(ii.engine) << ii.imageChecksums; + stream << ii.testFunction << ii.itemName << ii.itemChecksum << quint8(ii.status) << ii.imageChecksums; ii.writeImageToStream(stream); return stream; } QDataStream & operator>> (QDataStream &stream, ImageItem &ii) { - quint8 encFormat, encStatus, encEngine; - stream >> ii.scriptName >> ii.scriptChecksum >> encStatus >> encFormat - >> encEngine >> ii.imageChecksums; - ii.renderFormat = QImage::Format(encFormat); + quint8 encStatus; + stream >> ii.testFunction >> ii.itemName >> ii.itemChecksum >> encStatus >> ii.imageChecksums; ii.status = ImageItem::ItemStatus(encStatus); - ii.engine = ImageItem::GraphicsEngine(encEngine); ii.readImageFromStream(stream); return stream; } @@ -275,7 +272,7 @@ BaselineProtocol::~BaselineProtocol() } -bool BaselineProtocol::connect(bool *dryrun) +bool BaselineProtocol::connect(const QString &testCase, bool *dryrun) { errMsg.clear(); QByteArray serverName(qgetenv("QT_LANCELOT_SERVER")); @@ -292,6 +289,7 @@ bool BaselineProtocol::connect(bool *dryrun) } PlatformInfo pi(true); + pi.insert(PI_TestCase, testCase); QByteArray block; QDataStream ds(&block, QIODevice::ReadWrite); ds << pi; @@ -342,11 +340,15 @@ bool BaselineProtocol::acceptConnection(PlatformInfo *pi) } -bool BaselineProtocol::requestBaselineChecksums(ImageItemList *itemList) +bool BaselineProtocol::requestBaselineChecksums(const QString &testFunction, ImageItemList *itemList) { errMsg.clear(); if (!itemList) return false; + + for(ImageItemList::iterator it = itemList->begin(); it != itemList->end(); it++) + it->testFunction = testFunction; + QByteArray block; QDataStream ds(&block, QIODevice::ReadWrite); ds << *itemList; diff --git a/tests/arthur/common/baselineprotocol.h b/tests/arthur/common/baselineprotocol.h index baffb4a..1f4d593 100644 --- a/tests/arthur/common/baselineprotocol.h +++ b/tests/arthur/common/baselineprotocol.h @@ -52,6 +52,7 @@ #define FileFormat "png" +const QString PI_TestCase(QLS("TestCase")); const QString PI_HostName(QLS("HostName")); const QString PI_HostAddress(QLS("HostAddress")); const QString PI_OSName(QLS("OSName")); @@ -73,19 +74,15 @@ struct ImageItem { public: ImageItem() - : status(Ok), renderFormat(QImage::Format_Invalid), engine(Raster), scriptChecksum(0) + : status(Ok), itemChecksum(0) {} ImageItem(const ImageItem &other) { *this = other; } ~ImageItem() {} ImageItem &operator=(const ImageItem &other); - static quint64 computeChecksum(const QImage& image); - QString engineAsString() const; - QString formatAsString() const; - void writeImageToStream(QDataStream &stream) const; - void readImageFromStream(QDataStream &stream); + static quint64 computeChecksum(const QImage& image); enum ItemStatus { Ok = 0, @@ -93,19 +90,15 @@ public: IgnoreItem = 2 }; - enum GraphicsEngine { - Raster = 0, - OpenGL = 1 - }; - - QString scriptName; + QString testFunction; + QString itemName; ItemStatus status; - QImage::Format renderFormat; - GraphicsEngine engine; QImage image; QList<quint64> imageChecksums; - // tbd: add diffscore - quint16 scriptChecksum; + quint16 itemChecksum; + + void writeImageToStream(QDataStream &stream) const; + void readImageFromStream(QDataStream &stream); }; QDataStream & operator<< (QDataStream &stream, const ImageItem &ii); QDataStream & operator>> (QDataStream &stream, ImageItem& ii); @@ -124,7 +117,7 @@ public: // Important constants here // **************************************************** enum Constant { - ProtocolVersion = 3, + ProtocolVersion = 4, ServerPort = 54129, Timeout = 5000 }; @@ -143,8 +136,8 @@ public: }; // For client: - bool connect(bool *dryrun = 0); - bool requestBaselineChecksums(ImageItemList *itemList); + bool connect(const QString &testCase, bool *dryrun = 0); + bool requestBaselineChecksums(const QString &testFunction, ImageItemList *itemList); bool submitNewBaseline(const ImageItem &item, QByteArray *serverMsg); bool submitMismatch(const ImageItem &item, QByteArray *serverMsg); |