summaryrefslogtreecommitdiffstats
path: root/tests/baselineserver/src/baselineserver.cpp
diff options
context:
space:
mode:
authoraavit <qt-info@nokia.com>2011-09-01 14:50:59 +0200
committerQt by Nokia <qt-info@nokia.com>2011-09-01 16:14:18 +0200
commit74cadacdd5f571dfbab0e8b5f626bee79761c549 (patch)
tree23d7a6de0fa6b42ba3cc345d3fb94f33af333ede /tests/baselineserver/src/baselineserver.cpp
parent9bb0cc30ee8566e8c99865a657afd275d2d2f477 (diff)
Add option to compare to different platform in lancelot autotest
(cherry picked from commit b6b160d9ba1e0a5f1fbd67112f8c78ba48e7cad7) Conflicts: tests/baselineserver/src/baselineserver.cpp Change-Id: Ie8bdff26b8394bb6a5b6b48225b20833dbee0637 Reviewed-on: http://codereview.qt.nokia.com/4082 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Jiang Jiang <jiang.jiang@nokia.com>
Diffstat (limited to 'tests/baselineserver/src/baselineserver.cpp')
-rw-r--r--tests/baselineserver/src/baselineserver.cpp74
1 files changed, 47 insertions, 27 deletions
diff --git a/tests/baselineserver/src/baselineserver.cpp b/tests/baselineserver/src/baselineserver.cpp
index 6ff0a0c72d..5ac78d4b32 100644
--- a/tests/baselineserver/src/baselineserver.cpp
+++ b/tests/baselineserver/src/baselineserver.cpp
@@ -172,27 +172,31 @@ const char *BaselineHandler::logtime()
bool BaselineHandler::establishConnection()
{
- if (!proto.acceptConnection(&plat)) {
+ if (!proto.acceptConnection(&clientInfo)) {
qWarning() << runId << logtime() << "Accepting new connection from" << proto.socket.peerAddress().toString() << "failed." << proto.errorMessage();
proto.sendBlock(BaselineProtocol::Abort, proto.errorMessage().toLatin1()); // In case the client can hear us, tell it what's wrong.
proto.socket.disconnectFromHost();
return false;
}
QString logMsg;
- foreach (QString key, plat.keys()) {
+ foreach (QString key, clientInfo.keys()) {
if (key != PI_HostName && key != PI_HostAddress)
- logMsg += key + QLS(": '") + plat.value(key) + QLS("', ");
+ logMsg += key + QLS(": '") + clientInfo.value(key) + QLS("', ");
}
- qDebug() << runId << logtime() << "Connection established with" << plat.value(PI_HostName)
- << "[" << qPrintable(plat.value(PI_HostAddress)) << "]" << logMsg;
+ qDebug() << runId << logtime() << "Connection established with" << clientInfo.value(PI_HostName)
+ << "[" << qPrintable(clientInfo.value(PI_HostAddress)) << "]" << logMsg
+ << "Overrides:" << clientInfo.overrides() << "AdHoc-Run:" << clientInfo.isAdHocRun();
+
+ //### Temporarily override the client setting, for client compatibility:
+ if (!clientInfo.isAdHocRun())
+ clientInfo.setAdHocRun(clientInfo.value(PI_PulseGitBranch).isEmpty() && clientInfo.value(PI_PulseTestrBranch).isEmpty());
settings->beginGroup("ClientFilters");
- if (!settings->childKeys().isEmpty() && !plat.value(PI_PulseGitBranch).isEmpty()) { // i.e. not adhoc client
- // Abort if client does not match the filters
+ if (!clientInfo.isAdHocRun()) { // for CI runs, allow filtering of clients. TBD: different filters (settings file) per testCase
foreach (QString filterKey, settings->childKeys()) {
QString filter = settings->value(filterKey).toString();
- QString platVal = plat.value(filterKey);
- if (filter.isEmpty() || platVal.isEmpty())
+ QString platVal = clientInfo.value(filterKey);
+ if (filter.isEmpty())
continue; // tbd: add a syntax for specifying a "value-must-be-present" filter
if (!platVal.contains(filter)) {
qDebug() << runId << logtime() << "Did not pass client filter on" << filterKey << "; disconnecting.";
@@ -206,7 +210,7 @@ bool BaselineHandler::establishConnection()
proto.sendBlock(BaselineProtocol::Ack, QByteArray());
- report.init(this, runId, plat);
+ report.init(this, runId, clientInfo);
return true;
}
@@ -297,6 +301,12 @@ void BaselineHandler::storeImage(const QByteArray &itemBlock, bool isBaseline)
ImageItem item;
ds >> item;
+ if (isBaseline && !clientInfo.overrides().isEmpty()) {
+ qDebug() << runId << logtime() << "Received baseline from client with override info, ignoring. Item:" << item.itemName;
+ proto.sendBlock(BaselineProtocol::UnknownError, "New baselines not accepted from client with override info.");
+ return;
+ }
+
QString prefix = pathForItem(item, isBaseline);
qDebug() << runId << logtime() << "Received" << (isBaseline ? "baseline" : "mismatched") << "image for:" << item.itemName << "Storing in" << prefix;
@@ -313,7 +323,7 @@ void BaselineHandler::storeImage(const QByteArray &itemBlock, bool isBaseline)
cwd.mkpath(dir);
item.image.save(prefix + QLS(FileFormat), FileFormat);
- PlatformInfo itemData = plat;
+ PlatformInfo itemData = clientInfo;
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());
@@ -366,17 +376,16 @@ void BaselineHandler::receiveDisconnect()
}
-void BaselineHandler::mapPlatformInfo() const
+PlatformInfo BaselineHandler::mapPlatformInfo(const PlatformInfo& orig) const
{
- mapped = plat;
+ PlatformInfo mapped = orig;
// Map hostname
- QString host = plat.value(PI_HostName).section(QLC('.'), 0, 0); // Filter away domain, if any
+ QString host = orig.value(PI_HostName).section(QLC('.'), 0, 0); // Filter away domain, if any
if (host.isEmpty() || host == QLS("localhost")) {
- host = plat.value(PI_HostAddress);
+ host = orig.value(PI_HostAddress);
} else {
- if (!plat.value(PI_PulseGitBranch).isEmpty()) {
- // i.e. pulse run, so remove index postfix typical of vm hostnames
+ if (!orig.isAdHocRun()) { // i.e. CI system run, so remove index postfix typical of vm hostnames
host.remove(QRegExp(QLS("\\d+$")));
if (host.endsWith(QLC('-')))
host.chop(1);
@@ -387,18 +396,28 @@ void BaselineHandler::mapPlatformInfo() const
mapped.insert(PI_HostName, host);
// Map qmakespec
- QString mkspec = plat.value(PI_QMakeSpec);
+ QString mkspec = orig.value(PI_QMakeSpec);
mapped.insert(PI_QMakeSpec, mkspec.replace(QLC('/'), QLC('_')));
// Map Qt version
- QString ver = plat.value(PI_QtVersion);
+ QString ver = orig.value(PI_QtVersion);
mapped.insert(PI_QtVersion, ver.prepend(QLS("Qt-")));
+
+ return mapped;
}
+
QString BaselineHandler::pathForItem(const ImageItem &item, bool isBaseline, bool absolute) const
{
- if (mapped.isEmpty())
- mapPlatformInfo();
+ if (mappedClientInfo.isEmpty()) {
+ mappedClientInfo = mapPlatformInfo(clientInfo);
+ PlatformInfo oraw = clientInfo;
+ for (int i = 0; i < clientInfo.overrides().size()-1; i+=2)
+ oraw.insert(clientInfo.overrides().at(i), clientInfo.overrides().at(i+1));
+ overriddenMappedClientInfo = mapPlatformInfo(oraw);
+ }
+
+ const PlatformInfo& mapped = isBaseline ? overriddenMappedClientInfo : mappedClientInfo;
QString itemName = item.itemName.simplified();
itemName.replace(QLC(' '), QLC('_'));
@@ -512,13 +531,14 @@ void BaselineHandler::testPathMapping()
item.imageChecksums << 0x0123456789abcdefULL;
item.itemChecksum = 0x0123;
- plat.insert(PI_QtVersion, QLS("5.0.0"));
- plat.insert(PI_BuildKey, QLS("(nobuildkey)"));
- plat.insert(PI_QMakeSpec, QLS("linux-g++"));
- plat.insert(PI_PulseGitBranch, QLS("somebranch"));
+ clientInfo.insert(PI_QtVersion, QLS("5.0.0"));
+ clientInfo.insert(PI_BuildKey, QLS("(nobuildkey)"));
+ clientInfo.insert(PI_QMakeSpec, QLS("linux-g++"));
+ clientInfo.insert(PI_PulseGitBranch, QLS("somebranch"));
+
foreach(const QString& host, hosts) {
- mapped.clear();
- plat.insert(PI_HostName, host);
+ mappedClientInfo.clear();
+ clientInfo.insert(PI_HostName, host);
qDebug() << "Baseline from" << host << "->" << pathForItem(item, true);
qDebug() << "Mismatch from" << host << "->" << pathForItem(item, false);
}