summaryrefslogtreecommitdiffstats
path: root/tests/arthur
diff options
context:
space:
mode:
authoraavit <qt-info@nokia.com>2011-04-11 10:26:27 (GMT)
committeraavit <qt-info@nokia.com>2011-04-11 10:26:27 (GMT)
commitf6ed698944a75cc7c238a6baf6a359cda81ab1a8 (patch)
treef45e34b509ad835a4611fce06cb394300e5f28f9 /tests/arthur
parent082b9125d627df11692f2a03b80c9e962e82eda5 (diff)
downloadQt-f6ed698944a75cc7c238a6baf6a359cda81ab1a8.zip
Qt-f6ed698944a75cc7c238a6baf6a359cda81ab1a8.tar.gz
Qt-f6ed698944a75cc7c238a6baf6a359cda81ab1a8.tar.bz2
Lancelot: support for custom keys added to protocol. API cleanup.
Diffstat (limited to 'tests/arthur')
-rw-r--r--tests/arthur/common/baselineprotocol.cpp150
-rw-r--r--tests/arthur/common/baselineprotocol.h47
2 files changed, 144 insertions, 53 deletions
diff --git a/tests/arthur/common/baselineprotocol.cpp b/tests/arthur/common/baselineprotocol.cpp
index 0e7e507..88cea36 100644
--- a/tests/arthur/common/baselineprotocol.cpp
+++ b/tests/arthur/common/baselineprotocol.cpp
@@ -50,6 +50,18 @@
#include <QTime>
#include <QPointer>
+const QString PI_TestCase(QLS("TestCase"));
+const QString PI_HostName(QLS("HostName"));
+const QString PI_HostAddress(QLS("HostAddress"));
+const QString PI_OSName(QLS("OSName"));
+const QString PI_OSVersion(QLS("OSVersion"));
+const QString PI_QtVersion(QLS("QtVersion"));
+const QString PI_BuildKey(QLS("BuildKey"));
+const QString PI_GitCommit(QLS("GitCommit"));
+const QString PI_QMakeSpec(QLS("QMakeSpec"));
+const QString PI_PulseGitBranch(QLS("PulseGitBranch"));
+const QString PI_PulseTestrBranch(QLS("PulseTestrBranch"));
+
#ifndef QMAKESPEC
#define QMAKESPEC "Unknown"
#endif
@@ -70,60 +82,117 @@ void BaselineProtocol::sysSleep(int ms)
#endif
}
-PlatformInfo::PlatformInfo(bool useLocal)
- : QMap<QString, QString>()
+PlatformInfo::PlatformInfo()
+ : QMap<QString, QString>(), replaceDefault(false)
{
- if (useLocal) {
- insert(PI_HostName, QHostInfo::localHostName());
- insert(PI_QtVersion, QLS(qVersion()));
- insert(PI_QMakeSpec, QString(QLS(QMAKESPEC)).remove(QRegExp(QLS("^.*mkspecs/"))));
- insert(PI_BuildKey, QLibraryInfo::buildKey());
+}
+
+PlatformInfo PlatformInfo::localHostInfo()
+{
+ PlatformInfo pi;
+ pi.insert(PI_HostName, QHostInfo::localHostName());
+ pi.insert(PI_QtVersion, QLS(qVersion()));
+ pi.insert(PI_QMakeSpec, QString(QLS(QMAKESPEC)).remove(QRegExp(QLS("^.*mkspecs/"))));
+ pi.insert(PI_BuildKey, QLibraryInfo::buildKey());
#if defined(Q_OS_LINUX)
- insert(PI_OSName, QLS("Linux"));
- QProcess uname;
- uname.start(QLS("uname"), QStringList() << QLS("-r"));
- if (uname.waitForFinished(3000))
- insert(PI_OSVersion, QString::fromLocal8Bit(uname.readAllStandardOutput().constData()).simplified());
+ pi.insert(PI_OSName, QLS("Linux"));
+ QProcess uname;
+ uname.start(QLS("uname"), QStringList() << QLS("-r"));
+ if (uname.waitForFinished(3000))
+ pi.insert(PI_OSVersion, QString::fromLocal8Bit(uname.readAllStandardOutput().constData()).simplified());
#elif defined(Q_OS_WINCE)
- insert(PI_OSName, QLS("WinCE"));
- insert(PI_OSVersion, QString::number(QSysInfo::windowsVersion()));
+ pi.insert(PI_OSName, QLS("WinCE"));
+ pi.insert(PI_OSVersion, QString::number(QSysInfo::windowsVersion()));
#elif defined(Q_OS_WIN)
- insert(PI_OSName, QLS("Windows"));
- insert(PI_OSVersion, QString::number(QSysInfo::windowsVersion()));
+ pi.insert(PI_OSName, QLS("Windows"));
+ pi.insert(PI_OSVersion, QString::number(QSysInfo::windowsVersion()));
#elif defined(Q_OS_MAC)
- insert(PI_OSName, QLS("MacOS"));
- insert(PI_OSVersion, QString::number(qMacVersion()));
+ pi.insert(PI_OSName, QLS("MacOS"));
+ pi.insert(PI_OSVersion, QString::number(qMacVersion()));
#elif defined(Q_OS_SYMBIAN)
- insert(PI_OSName, QLS("Symbian"));
- insert(PI_OSVersion, QString::number(QSysInfo::symbianVersion());
+ pi.insert(PI_OSName, QLS("Symbian"));
+ pi.insert(PI_OSVersion, QString::number(QSysInfo::symbianVersion());
#else
- insert(PI_OSName, QLS("Other"));
+ pi.insert(PI_OSName, QLS("Other"));
#endif
- QProcess git;
- QString cmd;
- QStringList args;
+ QProcess git;
+ QString cmd;
+ QStringList args;
#if defined(Q_OS_WIN)
- cmd = QLS("cmd.exe");
- args << QLS("/c") << QLS("git");
+ cmd = QLS("cmd.exe");
+ args << QLS("/c") << QLS("git");
#else
- cmd = QLS("git");
+ cmd = QLS("git");
#endif
- args << QLS("log") << QLS("--max-count=1") << QLS("--pretty=%H [%an] [%ad] %s");
- git.start(cmd, args);
- git.waitForFinished(3000);
- if (!git.exitCode())
- insert(PI_GitCommit, QString::fromLocal8Bit(git.readAllStandardOutput().constData()).simplified());
- else
- insert(PI_GitCommit, QLS("Unknown"));
- }
+ args << QLS("log") << QLS("--max-count=1") << QLS("--pretty=%H [%an] [%ad] %s");
+ git.start(cmd, args);
+ git.waitForFinished(3000);
+ if (!git.exitCode())
+ pi.insert(PI_GitCommit, QString::fromLocal8Bit(git.readAllStandardOutput().constData()).simplified());
+ else
+ pi.insert(PI_GitCommit, QLS("Unknown"));
QByteArray gb = qgetenv("PULSE_GIT_BRANCH");
if (!gb.isEmpty())
- insert(PI_PulseGitBranch, QString::fromLatin1(gb));
+ pi.insert(PI_PulseGitBranch, QString::fromLatin1(gb));
QByteArray tb = qgetenv("PULSE_TESTR_BRANCH");
if (!tb.isEmpty())
- insert(PI_PulseTestrBranch, QString::fromLatin1(tb));
+ pi.insert(PI_PulseTestrBranch, QString::fromLatin1(tb));
+
+ return pi;
+}
+
+
+PlatformInfo::PlatformInfo(const PlatformInfo &other)
+ : QMap<QString, QString>(other)
+{
+ sigKeys = other.sigKeys;
+ replaceDefault = other.replaceDefault;
+}
+
+
+PlatformInfo &PlatformInfo::operator=(const PlatformInfo &other)
+{
+ QMap<QString, QString>::operator=(other);
+ sigKeys = other.sigKeys;
+ replaceDefault = other.replaceDefault;
+ return *this;
+}
+
+
+void PlatformInfo::addSignificantKeys(const QStringList &keys, bool replaceDefaultKeys)
+{
+ sigKeys = keys;
+ replaceDefault = replaceDefaultKeys;
+}
+
+
+QStringList PlatformInfo::addedKeys() const
+{
+ return sigKeys;
+}
+
+
+bool PlatformInfo::addedKeysReplaceDefault() const
+{
+ return replaceDefault;
+}
+
+
+QDataStream & operator<< (QDataStream &stream, const PlatformInfo &pi)
+{
+ stream << static_cast<const QMap<QString, QString>&>(pi);
+ stream << pi.sigKeys << pi.replaceDefault;
+ return stream;
+}
+
+
+QDataStream & operator>> (QDataStream &stream, PlatformInfo &pi)
+{
+ stream >> static_cast<QMap<QString, QString>&>(pi);
+ stream >> pi.sigKeys >> pi.replaceDefault;
+ return stream;
}
@@ -251,7 +320,7 @@ void ImageItem::readImageFromStream(QDataStream &in)
QDataStream & operator<< (QDataStream &stream, const ImageItem &ii)
{
- stream << ii.testFunction << ii.itemName << ii.itemChecksum << quint8(ii.status) << ii.imageChecksums;
+ stream << ii.testFunction << ii.itemName << ii.itemChecksum << quint8(ii.status) << ii.imageChecksums << ii.misc;
ii.writeImageToStream(stream);
return stream;
}
@@ -259,7 +328,7 @@ QDataStream & operator<< (QDataStream &stream, const ImageItem &ii)
QDataStream & operator>> (QDataStream &stream, ImageItem &ii)
{
quint8 encStatus;
- stream >> ii.testFunction >> ii.itemName >> ii.itemChecksum >> encStatus >> ii.imageChecksums;
+ stream >> ii.testFunction >> ii.itemName >> ii.itemChecksum >> encStatus >> ii.imageChecksums >> ii.misc;
ii.status = ImageItem::ItemStatus(encStatus);
ii.readImageFromStream(stream);
return stream;
@@ -293,7 +362,7 @@ bool BaselineProtocol::connect(const QString &testCase, bool *dryrun)
}
}
- PlatformInfo pi(true);
+ PlatformInfo pi = PlatformInfo::localHostInfo();
pi.insert(PI_TestCase, testCase);
QByteArray block;
QDataStream ds(&block, QIODevice::ReadWrite);
@@ -453,3 +522,4 @@ QString BaselineProtocol::errorMessage()
ret += QLS(" Socket state: ") + socket.errorString();
return ret;
}
+
diff --git a/tests/arthur/common/baselineprotocol.h b/tests/arthur/common/baselineprotocol.h
index 259555d..8a99ace 100644
--- a/tests/arthur/common/baselineprotocol.h
+++ b/tests/arthur/common/baselineprotocol.h
@@ -48,29 +48,49 @@
#include <QVector>
#include <QMap>
#include <QPointer>
+#include <QStringList>
#define QLS QLatin1String
#define QLC QLatin1Char
#define FileFormat "png"
-const QString PI_TestCase(QLS("TestCase"));
-const QString PI_HostName(QLS("HostName"));
-const QString PI_HostAddress(QLS("HostAddress"));
-const QString PI_OSName(QLS("OSName"));
-const QString PI_OSVersion(QLS("OSVersion"));
-const QString PI_QtVersion(QLS("QtVersion"));
-const QString PI_BuildKey(QLS("BuildKey"));
-const QString PI_GitCommit(QLS("GitCommit"));
-const QString PI_QMakeSpec(QLS("QMakeSpec"));
-const QString PI_PulseGitBranch(QLS("PulseGitBranch"));
-const QString PI_PulseTestrBranch(QLS("PulseTestrBranch"));
+extern const QString PI_TestCase;
+extern const QString PI_HostName;
+extern const QString PI_HostAddress;
+extern const QString PI_OSName;
+extern const QString PI_OSVersion;
+extern const QString PI_QtVersion;
+extern const QString PI_BuildKey;
+extern const QString PI_GitCommit;
+extern const QString PI_QMakeSpec;
+extern const QString PI_PulseGitBranch;
+extern const QString PI_PulseTestrBranch;
class PlatformInfo : public QMap<QString, QString>
{
public:
- PlatformInfo(bool useLocal = false);
+ PlatformInfo();
+ PlatformInfo(const PlatformInfo &other);
+ ~PlatformInfo()
+ {}
+ PlatformInfo &operator=(const PlatformInfo &other);
+
+ static PlatformInfo localHostInfo();
+
+ void addSignificantKeys(const QStringList& keys, bool replaceDefaultKeys=false);
+ QStringList addedKeys() const;
+ bool addedKeysReplaceDefault() const;
+
+private:
+ QStringList sigKeys;
+ bool replaceDefault;
+ friend QDataStream & operator<< (QDataStream &stream, const PlatformInfo &pi);
+ friend QDataStream & operator>> (QDataStream &stream, PlatformInfo& pi);
};
+QDataStream & operator<< (QDataStream &stream, const PlatformInfo &pi);
+QDataStream & operator>> (QDataStream &stream, PlatformInfo& pi);
+
struct ImageItem
{
@@ -99,6 +119,7 @@ public:
QImage image;
QList<quint64> imageChecksums;
quint16 itemChecksum;
+ QByteArray misc;
void writeImageToStream(QDataStream &stream) const;
void readImageFromStream(QDataStream &stream);
@@ -123,7 +144,7 @@ public:
// Important constants here
// ****************************************************
enum Constant {
- ProtocolVersion = 4,
+ ProtocolVersion = 5,
ServerPort = 54129,
Timeout = 5000
};