From 1ac37675969d31fb508d9f46f2e39b0e2b68dc20 Mon Sep 17 00:00:00 2001 From: aavit Date: Mon, 13 Sep 2010 14:05:31 +0200 Subject: Checksumming of the script files added. If the scripts themselves are modfied, it will not cause mismatch. --- tests/arthur/baselineserver/src/baselineserver.cpp | 4 +++- tests/auto/lancelot/tst_lancelot.cpp | 28 ++++++++-------------- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/tests/arthur/baselineserver/src/baselineserver.cpp b/tests/arthur/baselineserver/src/baselineserver.cpp index 63b79ca..d58313f 100644 --- a/tests/arthur/baselineserver/src/baselineserver.cpp +++ b/tests/arthur/baselineserver/src/baselineserver.cpp @@ -225,6 +225,8 @@ QString BaselineHandler::pathForItem(const ImageItem &item, bool isBaseline) QString itemName = item.scriptName; if (itemName.contains(QLC('.'))) itemName.replace(itemName.lastIndexOf(QLC('.')), 1, QLC('_')); + itemName.append(QLC('_')); + itemName.append(QString::number(item.scriptChecksum, 16).rightJustified(4, QLC('0'))); return storePath + itemName + QLC('.'); } @@ -232,7 +234,7 @@ QString BaselineHandler::pathForItem(const ImageItem &item, bool isBaseline) void BaselineHandler::testPathMapping() { - qDebug() << "Storeage prefix:" << BaselineServer::storagePath(); + qDebug() << "Storage prefix:" << BaselineServer::storagePath(); QStringList hosts; hosts << QLS("bq-ubuntu910-x86-01") diff --git a/tests/auto/lancelot/tst_lancelot.cpp b/tests/auto/lancelot/tst_lancelot.cpp index 2b1329f..5ec1667 100644 --- a/tests/auto/lancelot/tst_lancelot.cpp +++ b/tests/auto/lancelot/tst_lancelot.cpp @@ -49,6 +49,7 @@ #include #include #include +#include #include @@ -68,12 +69,12 @@ public: private: ImageItem render(const ImageItem &item); void paint(QPaintDevice *device, const QStringList &script, const QString &filePath); - QStringList loadScriptFile(const QString &filePath); void runTestSuite(); bool setupTestSuite(ImageItem::GraphicsEngine engine, QImage::Format format, const QStringList& blacklist); BaselineProtocol proto; ImageItemList baseList; + QHash scripts; private slots: void initTestCase(); @@ -120,9 +121,13 @@ void tst_Lancelot::initTestCase() baseList.resize(files.count()); ImageItemList::iterator it = baseList.begin(); - foreach(const QString& file, files) { - it->scriptName = file; - // tbd: also load, split and generate checksums for scripts + foreach(const QString& fileName, files) { + QFile file(scriptsDir + fileName); + file.open(QFile::ReadOnly); + QByteArray cont = file.readAll(); + scripts.insert(fileName, QString::fromLatin1(cont).split(QLatin1Char('\n'), QString::SkipEmptyParts)); + it->scriptName = fileName; + it->scriptChecksum = qChecksum(cont.constData(), cont.size()); it++; } } @@ -255,9 +260,7 @@ ImageItem tst_Lancelot::render(const ImageItem &item) res.imageChecksums.clear(); res.image = QImage(); QString filePath = scriptsDir + item.scriptName; - QStringList script = loadScriptFile(filePath); - if (script.isEmpty()) - return res; + QStringList script = scripts.value(item.scriptName); if (item.engine == ImageItem::Raster) { QImage img(800, 800, item.renderFormat); @@ -291,16 +294,5 @@ void tst_Lancelot::paint(QPaintDevice *device, const QStringList &script, const p.end(); } -QStringList tst_Lancelot::loadScriptFile(const QString &filePath) -{ - QFile file(filePath); - if (!file.open(QFile::ReadOnly)) { - return QStringList(); - } - //# use the new readscript function instead? - QTextStream stream(&file); - return stream.readAll().split(QLatin1Char('\n'), QString::SkipEmptyParts); -} - QTEST_MAIN(tst_Lancelot) #include "tst_lancelot.moc" -- cgit v0.12