diff options
author | aavit <qt-info@nokia.com> | 2010-11-18 11:44:27 (GMT) |
---|---|---|
committer | aavit <qt-info@nokia.com> | 2010-11-18 11:44:27 (GMT) |
commit | eedfeabfba1bbbc26792966238463ca3d22665a9 (patch) | |
tree | d2cf0893a1acb9e39e90bb8b77b402c1c2fa5153 /tests | |
parent | b9395570df56ae597514d294473ce0c6ba3bec06 (diff) | |
download | Qt-eedfeabfba1bbbc26792966238463ca3d22665a9.zip Qt-eedfeabfba1bbbc26792966238463ca3d22665a9.tar.gz Qt-eedfeabfba1bbbc26792966238463ca3d22665a9.tar.bz2 |
Fix black- and whitelisting of individual items
Diffstat (limited to 'tests')
-rw-r--r-- | tests/arthur/baselineserver/src/baselineserver.cpp | 75 | ||||
-rw-r--r-- | tests/arthur/baselineserver/src/baselineserver.h | 5 | ||||
-rw-r--r-- | tests/arthur/baselineserver/src/htmlpage.cpp | 42 | ||||
-rw-r--r-- | tests/arthur/baselineserver/src/htmlpage.h | 4 |
4 files changed, 41 insertions, 85 deletions
diff --git a/tests/arthur/baselineserver/src/baselineserver.cpp b/tests/arthur/baselineserver/src/baselineserver.cpp index eb756fc..3f4ae95 100644 --- a/tests/arthur/baselineserver/src/baselineserver.cpp +++ b/tests/arthur/baselineserver/src/baselineserver.cpp @@ -54,6 +54,7 @@ QString BaselineServer::storage; + BaselineServer::BaselineServer(QObject *parent) : QTcpServer(parent) { @@ -221,9 +222,9 @@ void BaselineHandler::provideBaselineChecksums(const QByteArray &itemListBlock) } // Find and mark blacklisted items + QString context = pathForItem(itemList.at(0), true, false).section(QLC('/'), 0, -2); if (itemList.count() > 0) { - QString prefix = pathForItem(itemList.at(0), true).section(QLC('/'), 0, -2); - QFile file(prefix + QLS("/.blacklist")); + QFile file(BaselineServer::storagePath() + QLC('/') + context + QLS("/BLACKLIST")); if (file.open(QIODevice::ReadOnly)) { QTextStream in(&file); do { @@ -242,7 +243,7 @@ void BaselineHandler::provideBaselineChecksums(const QByteArray &itemListBlock) QDataStream ods(&block, QIODevice::WriteOnly); ods << itemList; proto.sendBlock(BaselineProtocol::Ack, block); - report.start(BaselineServer::storagePath(), runId, plat, proto.socket.peerAddress().toString(), itemList); + report.start(BaselineServer::storagePath(), runId, plat, context, itemList); } @@ -406,61 +407,29 @@ QString BaselineHandler::updateSingleBaseline(const QString &oldBaseline, const return res; } -QString BaselineHandler::blacklistTest(const QString &scriptName, const QString &host, const QString &engine, - const QString &format) +QString BaselineHandler::blacklistTest(const QString &context, const QString &itemId, bool removeFromBlacklist) { -#if 0 - QString configFile(BaselineServer::storagePath() + host + QLC('/') - + itemSubPath(engine, format) + QLS(".blacklist")); - QFile file(configFile); - if (file.open(QIODevice::Append)) { - QTextStream out(&file); - out << scriptName << endl; - return QLS("Blacklisted ") + scriptName; + QFile file(BaselineServer::storagePath() + QLC('/') + context + QLS("/BLACKLIST")); + QStringList blackList; + if (file.open(QIODevice::ReadWrite)) { + while (!file.atEnd()) + blackList.append(file.readLine().trimmed()); + + if (removeFromBlacklist) + blackList.removeAll(itemId); + else if (!blackList.contains(itemId)) + blackList.append(itemId); + + file.resize(0); + foreach (QString id, blackList) + file.write(id.toLatin1() + '\n'); + file.close(); + return QLS(removeFromBlacklist ? "Whitelisted " : "Blacklisted ") + itemId + QLS(" in context ") + context; } else { - return QLS("Unable to update blacklisted tests."); + return QLS("Unable to update blacklisted tests, failed to open ") + file.fileName(); } -#else - return QString(); -#endif } -QString BaselineHandler::whitelistTest(const QString &scriptName, const QString &host, const QString &engine, - const QString &format) -{ -#if 0 - QString configFile(BaselineServer::storagePath() + host + QLC('/') - + itemSubPath(engine, format) + QLS(".blacklist")); - QFile file(configFile); - QStringList tests; - if (file.open(QIODevice::ReadOnly)) { - QTextStream in(&file); - do { - tests << in.readLine(); - } while (!in.atEnd()); - if (tests.count() != 0) { - QMutableStringListIterator it(tests); - while (it.hasNext()) { - it.next(); - if (it.value() == scriptName) - it.remove(); - } - } - file.close(); - if (file.open(QIODevice::WriteOnly | QIODevice::Truncate)) { - QTextStream out(&file); - for (int i=0; i<tests.count(); ++i) - out << tests.at(i); - return QLS("Whitelisted ") + scriptName; - } else { - QLS("Unable to whitelist ") + scriptName + QLS(". Unable to truncate blacklist file."); - } - } - return QLS("Unable to whitelist ") + scriptName + QLS(". Unable to open blacklist file."); -#else - return QString(); -#endif -} void BaselineHandler::testPathMapping() { diff --git a/tests/arthur/baselineserver/src/baselineserver.h b/tests/arthur/baselineserver/src/baselineserver.h index be65a9d..d49aedb 100644 --- a/tests/arthur/baselineserver/src/baselineserver.h +++ b/tests/arthur/baselineserver/src/baselineserver.h @@ -103,10 +103,7 @@ public: static QString updateAllBaselines(const QString &host, const QString &id, const QString &engine, const QString &format); static QString updateSingleBaseline(const QString &oldBaseline, const QString &newBaseline); - static QString blacklistTest(const QString &scriptName, const QString &host, - const QString &engine, const QString &format); - static QString whitelistTest(const QString &scriptName, const QString &host, - const QString &engine, const QString &format); + static QString blacklistTest(const QString &context, const QString &itemId, bool removeFromBlacklist = false); private slots: void receiveRequest(); diff --git a/tests/arthur/baselineserver/src/htmlpage.cpp b/tests/arthur/baselineserver/src/htmlpage.cpp index 29ce262..f75da88 100644 --- a/tests/arthur/baselineserver/src/htmlpage.cpp +++ b/tests/arthur/baselineserver/src/htmlpage.cpp @@ -60,13 +60,13 @@ QString HTMLPage::filePath() return path; } -void HTMLPage::start(const QString &storagepath, const QString &runId, const PlatformInfo pinfo, const QString &hostAddress, const ImageItemList &itemList) +void HTMLPage::start(const QString &storagepath, const QString &runId, const PlatformInfo pinfo, const QString &context, const ImageItemList &itemList) { end(); id = runId; plat = pinfo; - address = hostAddress; + ctx = context; root = storagepath + QLC('/'); imageItems = itemList; QString dir = root + QLS("reports/"); @@ -132,16 +132,13 @@ void HTMLPage::addItem(const QString &baseline, const QString &rendered, const I QStringList images = QStringList() << baseline << rendered << compared; foreach(const QString& img, images) out << "<td><a href=\"/" << img << "\"><img src=\"/" << img << "\" width=240 height=240></a></td>\n"; - out << "<td><a href=\"/cgi-bin/server.cgi?cmd=updateSingleBaseline&oldBaseline=" << baseline - << "&newBaseline=" << rendered << "&url=" << pageUrl << "\">Update baseline</a><br>" -#if 0 - "<a href=\"/cgi-bin/server.cgi?cmd=blacklist&scriptName=" << item.scriptName - << "&host=" << plat.hostName << "&engine=" << item.engineAsString() - << "&format=" << item.formatAsString() - << "&url=" << pageUrl << "\">Blacklist test</a>" -#endif + + out << "<td><p><a href=\"/cgi-bin/server.cgi?cmd=updateSingleBaseline&oldBaseline=" << baseline + << "&newBaseline=" << rendered << "&url=" << pageUrl << "\">Replace baseline with rendered</a></p>" + << "<p><a href=\"/cgi-bin/server.cgi?cmd=blacklist&context=" << ctx + << "&itemId=" << item.scriptName << "&url=" << pageUrl << "\">Blacklist this item</a></p>" << "</td>\n"; - out << "</tr>\n\n"; + out << "</tr>\n\n"; QMutableVectorIterator<ImageItem> it(imageItems); while (it.hasNext()) { @@ -162,13 +159,10 @@ void HTMLPage::end() 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>"; 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.value(PI_HostName) - << "&engine=" << imageItems.at(i).engineAsString() - << "&format=" << imageItems.at(i).formatAsString() - << "&url=" << pageUrl - << "\">Whitelist test</a>"; + 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 + << "\">Whitelist item</a>"; } else { out << "<span style=\"color:green\">Test passed</span>"; } @@ -220,16 +214,12 @@ void HTMLPage::handleCGIQuery(const QString &query) cgiUrl.queryItemValue(QLS("format"))); } else if (command == QLS("blacklist")) { // blacklist a test - s << BaselineHandler::blacklistTest(cgiUrl.queryItemValue(QLS("scriptName")), - cgiUrl.queryItemValue(QLS("host")), - cgiUrl.queryItemValue(QLS("engine")), - cgiUrl.queryItemValue(QLS("format"))); + s << BaselineHandler::blacklistTest(cgiUrl.queryItemValue(QLS("context")), + cgiUrl.queryItemValue(QLS("itemId"))); } else if (command == QLS("whitelist")) { // whitelist a test - s << BaselineHandler::whitelistTest(cgiUrl.queryItemValue(QLS("scriptName")), - cgiUrl.queryItemValue(QLS("host")), - cgiUrl.queryItemValue(QLS("engine")), - cgiUrl.queryItemValue(QLS("format"))); + s << BaselineHandler::blacklistTest(cgiUrl.queryItemValue(QLS("context")), + cgiUrl.queryItemValue(QLS("itemId")), true); } else { s << "Unknown query:<br>" << query << "<br>"; } diff --git a/tests/arthur/baselineserver/src/htmlpage.h b/tests/arthur/baselineserver/src/htmlpage.h index bef6b55..fa4d1ed 100644 --- a/tests/arthur/baselineserver/src/htmlpage.h +++ b/tests/arthur/baselineserver/src/htmlpage.h @@ -51,7 +51,7 @@ public: HTMLPage(); ~HTMLPage(); - void start(const QString &storagePath, const QString &runId, const PlatformInfo pinfo, const QString &hostAddress, const ImageItemList &itemList); + void start(const QString &storagePath, const QString &runId, const PlatformInfo pinfo, const QString &context, const ImageItemList &itemList); void addItem(const QString &baseline, const QString &rendered, const ImageItem &item); void end(); QString filePath(); @@ -69,7 +69,7 @@ private: QTextStream out; QString id; PlatformInfo plat; - QString address; + QString ctx; ImageItemList imageItems; bool headerWritten; }; |