diff options
author | aavit <qt-info@nokia.com> | 2010-11-22 13:48:10 (GMT) |
---|---|---|
committer | aavit <qt-info@nokia.com> | 2010-11-22 13:48:10 (GMT) |
commit | 779dd15d1297c99970fc63a290fca22a405c267f (patch) | |
tree | c8edc5a9790c729d6f855dce0120c17b57989b36 | |
parent | 0b63c90f5f4f5d1948e63c12f8b9b3395d316809 (diff) | |
download | Qt-779dd15d1297c99970fc63a290fca22a405c267f.zip Qt-779dd15d1297c99970fc63a290fca22a405c267f.tar.gz Qt-779dd15d1297c99970fc63a290fca22a405c267f.tar.bz2 |
Add cmd to simulate testfail. Misc server improvements.
-rw-r--r-- | tests/arthur/baselineserver/src/baselineserver.cpp | 27 | ||||
-rw-r--r-- | tests/auto/lancelot/tst_lancelot.cpp | 28 |
2 files changed, 45 insertions, 10 deletions
diff --git a/tests/arthur/baselineserver/src/baselineserver.cpp b/tests/arthur/baselineserver/src/baselineserver.cpp index 416b58f..0399224 100644 --- a/tests/arthur/baselineserver/src/baselineserver.cpp +++ b/tests/arthur/baselineserver/src/baselineserver.cpp @@ -98,8 +98,8 @@ void BaselineServer::heartbeat() if (me.lastModified() == meLastMod) return; - // (could close() here to avoid accepting new connections, to avoid livelock) - // also, could check for a timeout to force exit, to avoid hung threads blocking + //# (could close() here to avoid accepting new connections, to avoid livelock) + //# also, could check for a timeout to force exit, to avoid hung threads blocking bool isServing = false; foreach(BaselineThread *thread, findChildren<BaselineThread *>()) { if (thread->isRunning()) { @@ -305,10 +305,13 @@ void BaselineHandler::mapPlatformInfo() if (host.isEmpty() || host == QLS("localhost")) { host = plat.value(PI_HostAddress); } else { - // remove index postfix typical of vm hostnames - host.remove(QRegExp(QLS("\\d+$"))); - if (host.endsWith(QLC('-'))) - host.chop(1); + //# Site specific, should be in a config file + if (!host.startsWith(QLS("oldhcp"))) { + // remove index postfix typical of vm hostnames + host.remove(QRegExp(QLS("\\d+$"))); + if (host.endsWith(QLC('-'))) + host.chop(1); + } } if (host.isEmpty()) host = QLS("unknownhost"); @@ -352,12 +355,16 @@ QString BaselineHandler::pathForItem(const ImageItem &item, bool isBaseline, boo QString BaselineHandler::clearAllBaselines(const QString &context) { + int tot = 0; + int failed = 0; QDirIterator it(BaselineServer::storagePath() + QLC('/') + context, QStringList() << QLS("*.png") << QLS("*.metadata")); - while (it.hasNext()) - QFile::remove(it.next()); - - return QLS("All baselines cleared from context ") + context; + while (it.hasNext()) { + tot++; + if (!QFile::remove(it.next())) + failed++; + } + return QString(QLS("%1 of %2 baselines cleared from context ")).arg((tot-failed)/2).arg(tot/2) + context; } QString BaselineHandler::updateSingleBaseline(const QString &oldBaseline, const QString &newBaseline) diff --git a/tests/auto/lancelot/tst_lancelot.cpp b/tests/auto/lancelot/tst_lancelot.cpp index 8467672..0c5d787 100644 --- a/tests/auto/lancelot/tst_lancelot.cpp +++ b/tests/auto/lancelot/tst_lancelot.cpp @@ -63,6 +63,8 @@ Q_OBJECT public: tst_Lancelot(); + static bool simfail; + private: ImageItem render(const ImageItem &item); void paint(QPaintDevice *device, const QStringList &script, const QString &filePath); @@ -91,6 +93,8 @@ private slots: #endif }; +bool tst_Lancelot::simfail = false; + tst_Lancelot::tst_Lancelot() { } @@ -290,12 +294,36 @@ void tst_Lancelot::paint(QPaintDevice *device, const QStringList &script, const { QPainter p(device); PaintCommands pcmd(script, 800, 800); + //pcmd.setShouldDrawText(false); pcmd.setType(ImageType); pcmd.setPainter(&p); pcmd.setFilePath(filePath); pcmd.runCommands(); + + if (simfail) { + p.drawLine(0, 0, 800, 800); + simfail = false; + } + p.end(); } +#define main rmain QTEST_MAIN(tst_Lancelot) +#undef main + +int main(int argc, char *argv[]) +{ + char *fargv[20]; + int fargc = 0; + for (int i = 0; i < qMin(argc, 19); i++) { + if (!qstrcmp(argv[i], "-simfail")) + tst_Lancelot::simfail = true; + else + fargv[fargc++] = argv[i]; + } + fargv[fargc] = 0; + return rmain(fargc, fargv); +} + #include "tst_lancelot.moc" |