diff options
author | Eckhart Koppen <eckhart.koppen@nokia.com> | 2011-01-19 12:17:10 (GMT) |
---|---|---|
committer | Eckhart Koppen <eckhart.koppen@nokia.com> | 2011-01-19 12:17:10 (GMT) |
commit | fe2f9c5df0352044c1e9fc5ab36240917d5735b2 (patch) | |
tree | 3b1e32e92e5a2ae89b75e847eb99c728319a480c | |
parent | c7e539c80fe4df93479970f03838a97d53f66460 (diff) | |
parent | c9be4ccfbd63323a2d70d341c9bc490a95195148 (diff) | |
download | Qt-fe2f9c5df0352044c1e9fc5ab36240917d5735b2.zip Qt-fe2f9c5df0352044c1e9fc5ab36240917d5735b2.tar.gz Qt-fe2f9c5df0352044c1e9fc5ab36240917d5735b2.tar.bz2 |
Merge remote branch 'qt-master/master'
-rw-r--r-- | tests/arthur/baselineserver/src/baselineserver.cpp | 124 | ||||
-rw-r--r-- | tests/arthur/baselineserver/src/baselineserver.h | 13 | ||||
-rw-r--r-- | tests/arthur/baselineserver/src/main.cpp | 2 | ||||
-rw-r--r-- | tests/arthur/baselineserver/src/report.cpp | 16 | ||||
-rw-r--r-- | tests/arthur/baselineserver/src/report.h | 2 | ||||
-rw-r--r-- | tests/benchmarks/script/qscriptvalueiterator/qscriptvalueiterator.pro | 2 | ||||
-rw-r--r-- | tests/benchmarks/script/script.pro | 2 |
7 files changed, 111 insertions, 50 deletions
diff --git a/tests/arthur/baselineserver/src/baselineserver.cpp b/tests/arthur/baselineserver/src/baselineserver.cpp index f59600f..8aaa8ff 100644 --- a/tests/arthur/baselineserver/src/baselineserver.cpp +++ b/tests/arthur/baselineserver/src/baselineserver.cpp @@ -53,11 +53,16 @@ #include <QProcess> #include <QDirIterator> -QString BaselineServer::storage; +// extra fields, for use in image metadata storage +const QString PI_ImageChecksum(QLS("ImageChecksum")); +const QString PI_RunId(QLS("RunId")); +const QString PI_CreationDate(QLS("CreationDate")); +QString BaselineServer::storage; +QString BaselineServer::url; BaselineServer::BaselineServer(QObject *parent) - : QTcpServer(parent) + : QTcpServer(parent), lastRunIdIdx(0) { QFileInfo me(QCoreApplication::applicationFilePath()); meLastMod = me.lastModified(); @@ -71,22 +76,32 @@ QString BaselineServer::storagePath() if (storage.isEmpty()) { storage = QLS(qgetenv("QT_LANCELOT_DIR")); if (storage.isEmpty()) - storage = QLS("/var/www"); + storage = QLS("/var/www"); } return storage; } QString BaselineServer::baseUrl() { - return QLS("http://") - + QHostInfo::localHostName().toLatin1() + '.' - + QHostInfo::localDomainName().toLatin1() + '/'; + if (url.isEmpty()) { + url = QLS("http://") + + QHostInfo::localHostName().toLatin1() + '.' + + QHostInfo::localDomainName().toLatin1() + '/'; + } + return url; } void BaselineServer::incomingConnection(int socketDescriptor) { - qDebug() << "Server: New connection!"; - BaselineThread *thread = new BaselineThread(socketDescriptor, this); + QString runId = QDateTime::currentDateTime().toString(QLS("MMMdd-hhmmss")); + if (runId == lastRunId) { + runId += QLC('-') + QString::number(++lastRunIdIdx); + } else { + lastRunId = runId; + lastRunIdIdx = 0; + } + qDebug() << "Server: New connection! RunId:" << runId; + BaselineThread *thread = new BaselineThread(runId, socketDescriptor, this); connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater())); thread->start(); } @@ -114,23 +129,21 @@ void BaselineServer::heartbeat() QCoreApplication::exit(); } -BaselineThread::BaselineThread(int socketDescriptor, QObject *parent) - : QThread(parent), socketDescriptor(socketDescriptor) +BaselineThread::BaselineThread(const QString &runId, int socketDescriptor, QObject *parent) + : QThread(parent), runId(runId), socketDescriptor(socketDescriptor) { } void BaselineThread::run() { - BaselineHandler handler(socketDescriptor); + BaselineHandler handler(runId, socketDescriptor); exec(); } -BaselineHandler::BaselineHandler(int socketDescriptor) - : QObject(), connectionEstablished(false) +BaselineHandler::BaselineHandler(const QString &runId, int socketDescriptor) + : QObject(), runId(runId), connectionEstablished(false) { - runId = QDateTime::currentDateTime().toString(QLS("MMMdd-hhmmss")); - if (socketDescriptor == -1) return; @@ -220,16 +233,17 @@ void BaselineHandler::provideBaselineChecksums(const QByteArray &itemListBlock) for (ImageItemList::iterator i = itemList.begin(); i != itemList.end(); ++i) { i->imageChecksums.clear(); + i->status = ImageItem::BaselineNotFound; QString prefix = pathForItem(*i, true); - QFile file(prefix + QLS("metadata")); - if (file.open(QIODevice::ReadOnly)) { - QDataStream checkSums(&file); - checkSums >> i->imageChecksums; - file.close(); - i->status = ImageItem::Ok; + PlatformInfo itemData = fetchItemMetadata(prefix); + if (itemData.contains(PI_ImageChecksum)) { + bool ok = false; + quint64 checksum = itemData.value(PI_ImageChecksum).toULongLong(&ok, 16); + if (ok) { + i->imageChecksums.prepend(checksum); + i->status = ImageItem::Ok; + } } - if (!i->imageChecksums.count()) - i->status = ImageItem::BaselineNotFound; } // Find and mark blacklisted items @@ -280,18 +294,51 @@ void BaselineHandler::storeImage(const QByteArray &itemBlock, bool isBaseline) cwd.mkpath(dir); item.image.save(prefix + QLS(FileFormat), FileFormat); - //# Could use QSettings or XML or even DB, could use common file for whole dir or even whole storage - but for now, keep it simple - QFile file(prefix + QLS("metadata")); - file.open(QIODevice::WriteOnly | QIODevice::Truncate); - QDataStream checkSums(&file); - checkSums << item.imageChecksums; - file.close(); + PlatformInfo itemData = plat; + itemData.insert(PI_ImageChecksum, QString::number(item.imageChecksums.at(0), 16)); //# Only the first is stored. TBD: get rid of list + itemData.insert(PI_RunId, runId); + itemData.insert(PI_CreationDate, QDateTime::currentDateTime().toString()); + storeItemMetadata(itemData, prefix); if (!isBaseline) report.addMismatch(item); } +void BaselineHandler::storeItemMetadata(const PlatformInfo &metadata, const QString &path) +{ + QFile file(path + QLS(MetadataFileExt)); + if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate)) { + qWarning() << runId << logtime() << "ERROR: could not write to file" << file.fileName(); + return; + } + QTextStream out(&file); + PlatformInfo::const_iterator it = metadata.constBegin(); + while (it != metadata.constEnd()) { + out << it.key() << ": " << it.value() << endl; + ++it; + } + file.close(); +} + + +PlatformInfo BaselineHandler::fetchItemMetadata(const QString &path) +{ + PlatformInfo res; + QFile file(path + QLS(MetadataFileExt)); + if (!file.open(QIODevice::ReadOnly)) + return res; + QTextStream in(&file); + do { + QString line = in.readLine(); + int idx = line.indexOf(QLS(": ")); + if (idx > 0) + res.insert(line.left(idx), line.mid(idx+2)); + } while (!in.atEnd()); + return res; +} + + void BaselineHandler::receiveDisconnect() { qDebug() << runId << logtime() << "Client disconnected."; @@ -309,9 +356,8 @@ void BaselineHandler::mapPlatformInfo() const if (host.isEmpty() || host == QLS("localhost")) { host = plat.value(PI_HostAddress); } else { - //# Site specific, should be in a config file - if (!host.startsWith(QLS("oldhcp"))) { - // remove index postfix typical of vm hostnames + if (!plat.value(PI_PulseGitBranch).isEmpty()) { + // i.e. pulse run, so remove index postfix typical of vm hostnames host.remove(QRegExp(QLS("\\d+$"))); if (host.endsWith(QLC('-'))) host.chop(1); @@ -327,7 +373,7 @@ void BaselineHandler::mapPlatformInfo() const // Map Qt version QString ver = plat.value(PI_QtVersion); - mapped.insert(PI_QtVersion, ver.prepend(QLS("Qt-"))); //### TBD: remove patch version + mapped.insert(PI_QtVersion, ver.prepend(QLS("Qt-"))); } QString BaselineHandler::pathForItem(const ImageItem &item, bool isBaseline, bool absolute) const @@ -371,7 +417,7 @@ QString BaselineHandler::clearAllBaselines(const QString &context) int tot = 0; int failed = 0; QDirIterator it(BaselineServer::storagePath() + QLC('/') + context, - QStringList() << QLS("*.png") << QLS("*.metadata")); + QStringList() << QLS("*.") + QLS(FileFormat) << QLS("*.") + QLS(MetadataFileExt)); while (it.hasNext()) { tot++; if (!QFile::remove(it.next())) @@ -389,10 +435,10 @@ QString BaselineHandler::updateSingleBaseline(const QString &oldBaseline, const QProcess proc; proc.setProcessChannelMode(QProcess::MergedChannels); - proc.start(QLS("cp"), QStringList() << QLS("-f") << srcBase + QLS("png") << srcBase + QLS("metadata") << dstDir); + proc.start(QLS("cp"), QStringList() << QLS("-f") << srcBase + QLS(FileFormat) << srcBase + QLS(MetadataFileExt) << dstDir); proc.waitForFinished(); if (proc.exitCode() == 0) - res = QString("Successfully updated '%1'").arg(oldBaseline + QLS("/metadata")); + res = QString("Successfully updated '%1'").arg(oldBaseline); else res = QString("Error updating baseline: %1<br>" "Command output: <pre>%2</pre>").arg(proc.errorString(), proc.readAll().constData()); @@ -440,7 +486,8 @@ void BaselineHandler::testPathMapping() << QLS("macbuilder-02.test.troll.no") << QLS("bqvm1164") << QLS("chimera") - << QLS("localhost"); + << QLS("localhost") + << QLS(""); ImageItem item; item.testFunction = QLS("testPathMapping"); @@ -450,7 +497,8 @@ void BaselineHandler::testPathMapping() plat.insert(PI_QtVersion, QLS("4.8.0")); plat.insert(PI_BuildKey, QLS("(nobuildkey)")); - plat.insert(PI_QMakeSpec, "linux-g++"); + plat.insert(PI_QMakeSpec, QLS("linux-g++")); + plat.insert(PI_PulseGitBranch, QLS("somebranch")); foreach(const QString& host, hosts) { mapped.clear(); plat.insert(PI_HostName, host); diff --git a/tests/arthur/baselineserver/src/baselineserver.h b/tests/arthur/baselineserver/src/baselineserver.h index e09a9d0..a5683b2 100644 --- a/tests/arthur/baselineserver/src/baselineserver.h +++ b/tests/arthur/baselineserver/src/baselineserver.h @@ -54,6 +54,7 @@ // #seconds between update checks #define HEARTBEAT 10 +#define MetadataFileExt "metadata" class BaselineServer : public QTcpServer { @@ -74,7 +75,10 @@ private slots: private: QTimer *heartbeatTimer; QDateTime meLastMod; + QString lastRunId; + int lastRunIdIdx; static QString storage; + static QString url; }; @@ -84,10 +88,11 @@ class BaselineThread : public QThread Q_OBJECT public: - BaselineThread(int socketDescriptor, QObject *parent); + BaselineThread(const QString &runId, int socketDescriptor, QObject *parent); void run(); private: + QString runId; int socketDescriptor; }; @@ -97,7 +102,7 @@ class BaselineHandler : public QObject Q_OBJECT public: - BaselineHandler(int socketDescriptor = -1); + BaselineHandler(const QString &runId, int socketDescriptor = -1); void testPathMapping(); QString pathForItem(const ImageItem &item, bool isBaseline = true, bool absolute = true) const; @@ -115,6 +120,8 @@ private: bool establishConnection(); void provideBaselineChecksums(const QByteArray &itemListBlock); void storeImage(const QByteArray &itemBlock, bool isBaseline); + void storeItemMetadata(const PlatformInfo &metadata, const QString &path); + PlatformInfo fetchItemMetadata(const QString &path); void mapPlatformInfo() const; const char *logtime(); QString computeMismatchScore(const QImage& baseline, const QImage& rendered); @@ -122,8 +129,8 @@ private: BaselineProtocol proto; PlatformInfo plat; mutable PlatformInfo mapped; - bool connectionEstablished; QString runId; + bool connectionEstablished; Report report; }; diff --git a/tests/arthur/baselineserver/src/main.cpp b/tests/arthur/baselineserver/src/main.cpp index bf41f41..02fc2fa 100644 --- a/tests/arthur/baselineserver/src/main.cpp +++ b/tests/arthur/baselineserver/src/main.cpp @@ -53,7 +53,7 @@ int main(int argc, char *argv[]) } if (a.arguments().contains(QLatin1String("-testmapping"))) { - BaselineHandler h; + BaselineHandler h(QLS("SomeRunId")); h.testPathMapping(); return 0; } diff --git a/tests/arthur/baselineserver/src/report.cpp b/tests/arthur/baselineserver/src/report.cpp index f5bb418..c85f144 100644 --- a/tests/arthur/baselineserver/src/report.cpp +++ b/tests/arthur/baselineserver/src/report.cpp @@ -138,8 +138,9 @@ void Report::writeHeader() QString title = plat.value(PI_TestCase) + QLS(" Qt Baseline Test Report"); out << "<head><title>" << title << "</title></head>\n" << "<html><body><h1>" << title << "</h1>\n" - << "<p>Run Id: <b>" << runId << "</b></p>\n" - << "<p>Summary: <b>" << numMismatches << " of " << numItems << "</b> items reported mismatching</p>\n\n"; + << "<p>Note: This is a <i>static</i> page, generated at " << QDateTime::currentDateTime().toString() + << " for the test run with id " << runId << "</p>\n" + << "<p>Summary: <b><span style=\"color:red\">" << numMismatches << " of " << numItems << "</b></span> items reported mismatching</p>\n\n"; out << "<h3>Platform Info:</h3>\n" << "<table>\n"; foreach (QString key, plat.keys()) @@ -170,13 +171,15 @@ void Report::writeFunctionResults(const ImageItemList &list) foreach (const ImageItem &item, list) { out << "<tr>\n"; out << "<td>" << item.itemName << "</td>\n"; - QString baseline = handler->pathForItem(item, true, false) + QLS(FileFormat); + QString prefix = handler->pathForItem(item, true, false); + QString baseline = prefix + QLS(FileFormat); + QString metadata = prefix + QLS(MetadataFileExt); if (item.status == ImageItem::Mismatch) { QString rendered = handler->pathForItem(item, false, false) + QLS(FileFormat); - writeItem(baseline, rendered, item, ctx); + writeItem(baseline, rendered, item, ctx, metadata); } else { - out << "<td align=center><a href=\"/" << baseline << "\">view</a></td>\n" + out << "<td align=center><a href=\"/" << baseline << "\">image</a> <a href=\"/" << metadata << "\">info</a></td>\n" << "<td align=center colspan=2><small>n/a</small></td>\n" << "<td align=center>"; switch (item.status) { @@ -204,7 +207,7 @@ void Report::writeFunctionResults(const ImageItemList &list) out << "</table>\n"; } -void Report::writeItem(const QString &baseline, const QString &rendered, const ImageItem &item, const QString &ctx) +void Report::writeItem(const QString &baseline, const QString &rendered, const ImageItem &item, const QString &ctx, const QString &metadata) { QString compared = generateCompared(baseline, rendered); QString pageUrl = BaselineServer::baseUrl() + path; @@ -215,6 +218,7 @@ void Report::writeItem(const QString &baseline, const QString &rendered, const I out << "<td align=center>\n" << "<p><span style=\"color:red\">Mismatch reported</span></p>\n" + << "<p><a href=\"/" << metadata << "\">Baseline Info</a>\n" << "<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 diff --git a/tests/arthur/baselineserver/src/report.h b/tests/arthur/baselineserver/src/report.h index 0df613a..a56aafb 100644 --- a/tests/arthur/baselineserver/src/report.h +++ b/tests/arthur/baselineserver/src/report.h @@ -67,7 +67,7 @@ public: private: void write(); void writeFunctionResults(const ImageItemList &list); - void writeItem(const QString &baseline, const QString &rendered, const ImageItem &item, const QString &ctx); + void writeItem(const QString &baseline, const QString &rendered, const ImageItem &item, const QString &ctx, const QString &metadata); void writeHeader(); void writeFooter(); QString generateCompared(const QString &baseline, const QString &rendered, bool fuzzy = false); diff --git a/tests/benchmarks/script/qscriptvalueiterator/qscriptvalueiterator.pro b/tests/benchmarks/script/qscriptvalueiterator/qscriptvalueiterator.pro index ecd48f0..0bff039 100644 --- a/tests/benchmarks/script/qscriptvalueiterator/qscriptvalueiterator.pro +++ b/tests/benchmarks/script/qscriptvalueiterator/qscriptvalueiterator.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qscriptvalueiterator +TARGET = tst_bench_qscriptvalueiterator SOURCES += tst_qscriptvalueiterator.cpp diff --git a/tests/benchmarks/script/script.pro b/tests/benchmarks/script/script.pro index dd17012..b0770ca 100644 --- a/tests/benchmarks/script/script.pro +++ b/tests/benchmarks/script/script.pro @@ -4,6 +4,8 @@ SUBDIRS = \ qscriptengine \ qscriptvalue \ sunspider \ + qscriptqobject \ + qscriptvalueiterator \ v8 TRUSTED_BENCHMARKS += \ |