author | Eckhart Koeppen <eckhart.koppen@nokia.com> |
Thu, 22 Apr 2010 16:15:11 +0300 | |
branch | RCL_3 |
changeset 14 | 8c4229025c0b |
parent 13 | c0432d11811c |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the test suite of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
||
43 |
#include <QtCore> |
|
44 |
#include <QtTest/QtTest> |
|
45 |
#include <QtXml/QXmlStreamReader> |
|
46 |
#include <private/cycle_p.h> |
|
47 |
||
48 |
class tst_Selftests: public QObject |
|
49 |
{ |
|
50 |
Q_OBJECT |
|
51 |
private slots: |
|
52 |
void runSubTest_data(); |
|
53 |
void runSubTest(); |
|
13
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
54 |
void cleanupTestCase(); |
0 | 55 |
|
56 |
private: |
|
13
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
57 |
void doRunSubTest(QString const& subdir, QString const& logger, QStringList const& arguments ); |
0 | 58 |
}; |
59 |
||
60 |
struct BenchmarkResult |
|
61 |
{ |
|
62 |
qint64 total; |
|
63 |
qint64 iterations; |
|
64 |
QString unit; |
|
65 |
||
66 |
inline QString toString() const |
|
67 |
{ return QString("total:%1, unit:%2, iterations:%3").arg(total).arg(unit).arg(iterations); } |
|
68 |
||
69 |
static BenchmarkResult parse(QString const&, QString*); |
|
70 |
}; |
|
71 |
||
72 |
QT_BEGIN_NAMESPACE |
|
73 |
namespace QTest |
|
74 |
{ |
|
75 |
template <> |
|
76 |
inline bool qCompare |
|
77 |
(BenchmarkResult const &r1, BenchmarkResult const &r2, |
|
78 |
const char* actual, const char* expected, const char* file, int line) |
|
79 |
{ |
|
80 |
// First make sure the iterations and unit match. |
|
81 |
if (r1.iterations != r2.iterations || r1.unit != r2.unit) { |
|
82 |
/* Nope - compare whole string for best failure message */ |
|
83 |
return qCompare(r1.toString(), r2.toString(), actual, expected, file, line); |
|
84 |
} |
|
85 |
||
86 |
/* |
|
87 |
Now check the value. Some variance is allowed, and how much depends on the |
|
88 |
measured unit. |
|
89 |
*/ |
|
90 |
qreal variance = 0.; |
|
91 |
if (r1.unit == "msec") { |
|
92 |
variance = 0.1; |
|
93 |
} |
|
94 |
else if (r1.unit == "instr. loads") { |
|
95 |
variance = 0.001; |
|
96 |
} |
|
97 |
else if (r1.unit == "ticks") { |
|
98 |
variance = 0.001; |
|
99 |
} |
|
100 |
if (variance == 0.) { |
|
101 |
/* No variance allowed - compare whole string */ |
|
102 |
return qCompare(r1.toString(), r2.toString(), actual, expected, file, line); |
|
103 |
} |
|
104 |
||
105 |
if (qAbs(qreal(r1.total) - qreal(r2.total)) <= qreal(r1.total)*variance) { |
|
106 |
return compare_helper(true, "COMPARE()", file, line); |
|
107 |
} |
|
108 |
||
109 |
/* Whoops, didn't match. Compare the whole string for the most useful failure message. */ |
|
110 |
return qCompare(r1.toString(), r2.toString(), actual, expected, file, line); |
|
111 |
} |
|
112 |
} |
|
113 |
QT_END_NAMESPACE |
|
114 |
||
115 |
static QList<QByteArray> splitLines(QByteArray ba) |
|
116 |
{ |
|
117 |
ba.replace('\r', ""); |
|
13
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
118 |
QList<QByteArray> out = ba.split('\n'); |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
119 |
|
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
120 |
// Replace any ` file="..."' in XML with a generic location. |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
121 |
static const char marker[] = " file=\""; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
122 |
for (int i = 0; i < out.size(); ++i) { |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
123 |
QByteArray& line = out[i]; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
124 |
int index = line.indexOf(marker); |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
125 |
if (index == -1) { |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
126 |
continue; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
127 |
} |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
128 |
int end = line.indexOf('"', index + sizeof(marker)); |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
129 |
if (end == -1) { |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
130 |
continue; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
131 |
} |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
132 |
line.replace(index, end-index, " file=\"__FILE__\""); |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
133 |
} |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
134 |
|
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
135 |
return out; |
0 | 136 |
} |
137 |
||
13
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
138 |
static QList<QByteArray> expectedResult(const QString &subdir, const QString &logger) |
0 | 139 |
{ |
13
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
140 |
QString suffix = logger; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
141 |
if (suffix.isEmpty()) { |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
142 |
suffix = "txt"; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
143 |
} |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
144 |
QFile file(":/expected_" + subdir + "." + suffix); |
0 | 145 |
if (!file.open(QIODevice::ReadOnly)) |
146 |
return QList<QByteArray>(); |
|
147 |
return splitLines(file.readAll()); |
|
148 |
} |
|
149 |
||
13
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
150 |
struct Logger |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
151 |
{ |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
152 |
Logger(QString const&, QString const&, QStringList const&); |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
153 |
|
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
154 |
QString name; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
155 |
QString testdata_suffix; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
156 |
QStringList arguments; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
157 |
}; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
158 |
|
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
159 |
Logger::Logger(QString const& _name, QString const& _testdata_suffix, QStringList const& _arguments) |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
160 |
: name(_name) |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
161 |
, testdata_suffix(_testdata_suffix) |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
162 |
, arguments(_arguments) |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
163 |
{ |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
164 |
} |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
165 |
|
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
166 |
static QList<Logger> allLoggers() |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
167 |
{ |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
168 |
return QList<Logger>() |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
169 |
<< Logger("plain", "txt", QStringList()) |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
170 |
<< Logger("xml", "xml", QStringList() << "-xml") |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
171 |
<< Logger("xml flush", "xml", QStringList() << "-xml" << "-flush") |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
172 |
<< Logger("xunitxml", "xunitxml", QStringList() << "-xunitxml") |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
173 |
<< Logger("lightxml", "lightxml", QStringList() << "-lightxml") |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
174 |
; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
175 |
} |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
176 |
|
0 | 177 |
void tst_Selftests::runSubTest_data() |
178 |
{ |
|
179 |
QTest::addColumn<QString>("subdir"); |
|
13
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
180 |
QTest::addColumn<QString>("logger"); |
0 | 181 |
QTest::addColumn<QStringList>("arguments"); |
182 |
||
13
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
183 |
QStringList tests = QStringList() |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
184 |
<< "subtest" |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
185 |
<< "warnings" |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
186 |
<< "maxwarnings" |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
187 |
<< "cmptest" |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
188 |
// << "alive" // timer dependent |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
189 |
<< "globaldata" |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
190 |
<< "skipglobal" |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
191 |
<< "skip" |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
192 |
<< "strcmp" |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
193 |
<< "expectfail" |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
194 |
<< "sleep" |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
195 |
<< "fetchbogus" |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
196 |
<< "crashes" |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
197 |
<< "multiexec" |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
198 |
<< "failinit" |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
199 |
<< "failinitdata" |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
200 |
<< "skipinit" |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
201 |
<< "skipinitdata" |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
202 |
<< "datetime" |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
203 |
<< "singleskip" |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
204 |
|
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
205 |
//on windows assert does nothing in release mode and blocks execution with a popup window in debug mode |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
206 |
#if !defined(Q_OS_WIN) |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
207 |
<< "assert" |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
208 |
#endif |
0 | 209 |
|
13
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
210 |
<< "waitwithoutgui" |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
211 |
<< "differentexec" |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
212 |
#ifndef QT_NO_EXCEPTIONS |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
213 |
// The machine that run the intel autotests will popup a dialog |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
214 |
// with a warning that an uncaught exception was thrown. |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
215 |
// This will time out and falsely fail, therefore we disable the test for that platform. |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
216 |
# if !defined(Q_CC_INTEL) || !defined(Q_OS_WIN) |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
217 |
<< "exceptionthrow" |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
218 |
# endif |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
219 |
#endif |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
220 |
<< "qexecstringlist" |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
221 |
<< "datatable" |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
222 |
<< "commandlinedata" |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
223 |
|
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
224 |
#if defined(__GNUC__) && defined(__i386) && defined(Q_OS_LINUX) |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
225 |
<< "benchlibcallgrind" |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
226 |
#endif |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
227 |
<< "benchlibeventcounter" |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
228 |
<< "benchliboptions" |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
229 |
|
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
230 |
//### These tests are affected by timing and whether the CPU tick counter is |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
231 |
//### monotonically increasing. They won't work on some machines so leave them off by default. |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
232 |
//### Feel free to uncomment for your own testing. |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
233 |
#if 0 |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
234 |
<< "benchlibwalltime" |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
235 |
<< "benchlibtickcounter" |
0 | 236 |
#endif |
237 |
||
13
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
238 |
<< "xunit" |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
239 |
<< "longstring" |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
240 |
<< "badxml" |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
241 |
; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
242 |
|
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
243 |
foreach (Logger const& logger, allLoggers()) { |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
244 |
QString rowSuffix; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
245 |
if (logger.name != "plain") { |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
246 |
rowSuffix = QString(" %1").arg(logger.name); |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
247 |
} |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
248 |
|
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
249 |
foreach (QString const& subtest, tests) { |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
250 |
QStringList arguments = logger.arguments; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
251 |
if (subtest == "commandlinedata") { |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
252 |
arguments << QString("fiveTablePasses fiveTablePasses:fiveTablePasses_data1 -v2").split(' '); |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
253 |
} |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
254 |
else if (subtest == "benchlibcallgrind") { |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
255 |
arguments << "-callgrind"; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
256 |
} |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
257 |
else if (subtest == "benchlibeventcounter") { |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
258 |
arguments << "-eventcounter"; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
259 |
} |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
260 |
else if (subtest == "benchliboptions") { |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
261 |
arguments << "-eventcounter"; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
262 |
} |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
263 |
else if (subtest == "benchlibtickcounter") { |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
264 |
arguments << "-tickcounter"; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
265 |
} |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
266 |
else if (subtest == "badxml") { |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
267 |
arguments << "-eventcounter"; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
268 |
} |
0 | 269 |
|
13
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
270 |
// These tests don't work right with loggers other than plain, usually because |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
271 |
// they internally supply arguments to themselves. |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
272 |
if (logger.name != "plain") { |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
273 |
if (subtest == "differentexec") { |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
274 |
continue; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
275 |
} |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
276 |
if (subtest == "qexecstringlist") { |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
277 |
continue; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
278 |
} |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
279 |
if (subtest == "benchliboptions") { |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
280 |
continue; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
281 |
} |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
282 |
if (subtest == "waitwithoutgui") { |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
283 |
continue; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
284 |
} |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
285 |
// `crashes' will not output valid XML on platforms without a crash handler |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
286 |
if (subtest == "crashes") { |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
287 |
continue; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
288 |
} |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
289 |
// this test prints out some floats in the testlog and the formatting is |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
290 |
// platform-specific and hard to predict. |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
291 |
if (subtest == "subtest") { |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
292 |
continue; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
293 |
} |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
294 |
} |
0 | 295 |
|
13
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
296 |
QTest::newRow(qPrintable(QString("%1%2").arg(subtest).arg(rowSuffix))) |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
297 |
<< subtest |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
298 |
<< logger.testdata_suffix |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
299 |
<< arguments |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
300 |
; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
301 |
} |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
302 |
} |
0 | 303 |
} |
304 |
||
13
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
305 |
void tst_Selftests::doRunSubTest(QString const& subdir, QString const& logger, QStringList const& arguments ) |
0 | 306 |
{ |
13
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
307 |
// For the plain text logger, we'll read straight from standard output. |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
308 |
// For all other loggers (XML), we'll tell testlib to redirect to a file. |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
309 |
// The reason is that tests are allowed to print to standard output, and |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
310 |
// that means the test log is no longer guaranteed to be valid XML. |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
311 |
QStringList extraArguments; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
312 |
QString logfile; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
313 |
if (logger != "txt") { |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
314 |
logfile = "test_output"; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
315 |
extraArguments << "-o" << logfile; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
316 |
} |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
317 |
|
0 | 318 |
QProcess proc; |
319 |
proc.setEnvironment(QStringList("")); |
|
13
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
320 |
proc.start(subdir + "/" + subdir, QStringList() << arguments << extraArguments); |
0 | 321 |
QVERIFY2(proc.waitForFinished(), qPrintable(proc.errorString())); |
322 |
||
13
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
323 |
QByteArray out; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
324 |
if (logfile.isEmpty()) { |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
325 |
out = proc.readAllStandardOutput(); |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
326 |
} |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
327 |
else { |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
328 |
QFile file(logfile); |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
329 |
if (file.open(QIODevice::ReadOnly)) |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
330 |
out = file.readAll(); |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
331 |
} |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
332 |
|
0 | 333 |
const QByteArray err(proc.readAllStandardError()); |
334 |
||
335 |
/* Some platforms decides to output a message for uncaught exceptions. For instance, |
|
336 |
* this is what windows platforms says: |
|
337 |
* "This application has requested the Runtime to terminate it in an unusual way. |
|
338 |
* Please contact the application's support team for more information." */ |
|
339 |
if(subdir != QLatin1String("exceptionthrow") && subdir != QLatin1String("fetchbogus") |
|
340 |
&& subdir != QLatin1String("xunit")) |
|
341 |
QVERIFY2(err.isEmpty(), err.constData()); |
|
342 |
||
343 |
QList<QByteArray> res = splitLines(out); |
|
13
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
344 |
QList<QByteArray> exp = expectedResult(subdir, logger); |
0 | 345 |
|
346 |
if (exp.count() == 0) { |
|
347 |
QList<QList<QByteArray> > expArr; |
|
348 |
int i = 1; |
|
349 |
do { |
|
13
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
350 |
exp = expectedResult(subdir + QString("_%1").arg(i++), logger); |
0 | 351 |
if (exp.count()) |
352 |
expArr += exp; |
|
353 |
} while(exp.count()); |
|
354 |
||
355 |
for (int j = 0; j < expArr.count(); ++j) { |
|
356 |
if (res.count() == expArr.at(j).count()) { |
|
357 |
exp = expArr.at(j); |
|
358 |
break; |
|
359 |
} |
|
360 |
} |
|
361 |
} else { |
|
362 |
QCOMPARE(res.count(), exp.count()); |
|
363 |
} |
|
364 |
||
13
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
365 |
if (logger == "xunitxml" || logger == "xml" || logger == "lightxml") { |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
366 |
QByteArray xml(out); |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
367 |
// lightxml intentionally skips the root element, which technically makes it |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
368 |
// not valid XML. |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
369 |
// We'll add that ourselves for the purpose of validation. |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
370 |
if (logger == "lightxml") { |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
371 |
xml.prepend("<root>"); |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
372 |
xml.append("</root>"); |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
373 |
} |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
374 |
|
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
375 |
QXmlStreamReader reader(xml); |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
376 |
|
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
377 |
while(!reader.atEnd()) |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
378 |
reader.readNext(); |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
379 |
|
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
380 |
QVERIFY2(!reader.error(), qPrintable(QString("line %1, col %2: %3") |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
381 |
.arg(reader.lineNumber()) |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
382 |
.arg(reader.columnNumber()) |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
383 |
.arg(reader.errorString()) |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
384 |
)); |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
385 |
} |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
386 |
|
0 | 387 |
bool benchmark = false; |
388 |
for (int i = 0; i < res.count(); ++i) { |
|
389 |
QByteArray line = res.at(i); |
|
390 |
if (line.startsWith("Config: Using QTest")) |
|
391 |
continue; |
|
392 |
// the __FILE__ __LINE__ output is compiler dependent, skip it |
|
393 |
if (line.startsWith(" Loc: [") && line.endsWith(")]")) |
|
394 |
continue; |
|
395 |
if (line.endsWith(" : failure location")) |
|
396 |
continue; |
|
397 |
||
398 |
const QString output(QString::fromLatin1(line)); |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
399 |
const QString expected(QString::fromLatin1(exp.at(i)).replace("<INSERT_QT_VERSION_HERE>", QT_VERSION_STR)); |
0 | 400 |
|
13
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
401 |
if (line.contains("ASSERT") && output != expected) { |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
402 |
QEXPECT_FAIL("assert", "QTestLib prints out the absolute path.", Continue); |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
403 |
QEXPECT_FAIL("assert xml", "QTestLib prints out the absolute path.", Continue); |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
404 |
QEXPECT_FAIL("assert xml flush","QTestLib prints out the absolute path.", Continue); |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
405 |
QEXPECT_FAIL("assert lightxml", "QTestLib prints out the absolute path.", Continue); |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
406 |
QEXPECT_FAIL("assert xunitxml", "QTestLib prints out the absolute path.", Continue); |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
407 |
} |
0 | 408 |
|
409 |
/* On some platforms we compile without RTTI, and as a result we never throw an exception. */ |
|
410 |
if(expected.startsWith(QLatin1String("FAIL! : tst_Exception::throwException() Caught unhandled exce")) && expected != output) |
|
411 |
QCOMPARE(output.simplified(), QString::fromLatin1("tst_Exception::throwException()").simplified()); |
|
412 |
else |
|
413 |
{ |
|
414 |
if(output != expected && qstrcmp(QTest::currentDataTag(), "subtest") == 0) |
|
415 |
{ |
|
416 |
/* The floating point formatting differs between platforms, so let's just skip it. */ |
|
417 |
continue; |
|
418 |
} |
|
419 |
else { |
|
420 |
/* |
|
421 |
Are we expecting this line to be a benchmark result? |
|
422 |
If so, don't do a literal comparison, since results have some natural variance. |
|
423 |
*/ |
|
424 |
if (benchmark) { |
|
425 |
QString error; |
|
426 |
||
427 |
BenchmarkResult actualResult = BenchmarkResult::parse(output, &error); |
|
428 |
QVERIFY2(error.isEmpty(), qPrintable(QString("Actual line didn't parse as benchmark result: %1\nLine: %2").arg(error).arg(output))); |
|
429 |
||
430 |
BenchmarkResult expectedResult = BenchmarkResult::parse(expected, &error); |
|
431 |
QVERIFY2(error.isEmpty(), qPrintable(QString("Expected line didn't parse as benchmark result: %1\nLine: %2").arg(error).arg(expected))); |
|
432 |
||
433 |
QCOMPARE(actualResult, expectedResult); |
|
434 |
} |
|
435 |
else { |
|
436 |
QCOMPARE(output, expected); |
|
437 |
} |
|
438 |
} |
|
439 |
} |
|
440 |
||
441 |
benchmark = line.startsWith("RESULT : "); |
|
442 |
} |
|
443 |
} |
|
444 |
||
445 |
void tst_Selftests::runSubTest() |
|
446 |
{ |
|
447 |
QFETCH(QString, subdir); |
|
13
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
448 |
QFETCH(QString, logger); |
0 | 449 |
QFETCH(QStringList, arguments); |
450 |
||
13
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
451 |
doRunSubTest(subdir, logger, arguments); |
0 | 452 |
} |
453 |
||
454 |
/* Parse line into the BenchmarkResult it represents. */ |
|
455 |
BenchmarkResult BenchmarkResult::parse(QString const& line, QString* error) |
|
456 |
{ |
|
457 |
if (error) *error = QString(); |
|
458 |
BenchmarkResult out; |
|
459 |
||
460 |
QString remaining = line.trimmed(); |
|
461 |
||
462 |
if (remaining.isEmpty()) { |
|
463 |
if (error) *error = "Line is empty"; |
|
464 |
return out; |
|
465 |
} |
|
466 |
||
467 |
/* This code avoids using a QRegExp because QRegExp might be broken. */ |
|
468 |
||
469 |
/* Sample format: 4,000 msec per iteration (total: 4000, iterations: 1) */ |
|
470 |
||
471 |
QString sFirstNumber; |
|
472 |
while (!remaining.isEmpty() && !remaining.at(0).isSpace()) { |
|
473 |
sFirstNumber += remaining.at(0); |
|
474 |
remaining.remove(0,1); |
|
475 |
} |
|
476 |
remaining = remaining.trimmed(); |
|
477 |
||
478 |
/* 4,000 -> 4000 */ |
|
479 |
sFirstNumber.remove(','); |
|
480 |
||
481 |
/* Should now be parseable as floating point */ |
|
482 |
bool ok; |
|
483 |
double firstNumber = sFirstNumber.toDouble(&ok); |
|
484 |
if (!ok) { |
|
485 |
if (error) *error = sFirstNumber + " (at beginning of line) is not a valid number"; |
|
486 |
return out; |
|
487 |
} |
|
488 |
||
489 |
/* Remaining: msec per iteration (total: 4000, iterations: 1) */ |
|
490 |
static const char periterbit[] = " per iteration (total: "; |
|
491 |
QString unit; |
|
492 |
while (!remaining.startsWith(periterbit) && !remaining.isEmpty()) { |
|
493 |
unit += remaining.at(0); |
|
494 |
remaining.remove(0,1); |
|
495 |
} |
|
496 |
if (remaining.isEmpty()) { |
|
497 |
if (error) *error = "Could not find pattern: '<unit> per iteration (total: '"; |
|
498 |
return out; |
|
499 |
} |
|
500 |
||
501 |
remaining = remaining.mid(sizeof(periterbit)-1); |
|
502 |
||
503 |
/* Remaining: 4000, iterations: 1) */ |
|
504 |
static const char itersbit[] = ", iterations: "; |
|
505 |
QString sTotal; |
|
506 |
while (!remaining.startsWith(itersbit) && !remaining.isEmpty()) { |
|
507 |
sTotal += remaining.at(0); |
|
508 |
remaining.remove(0,1); |
|
509 |
} |
|
510 |
if (remaining.isEmpty()) { |
|
511 |
if (error) *error = "Could not find pattern: '<number>, iterations: '"; |
|
512 |
return out; |
|
513 |
} |
|
514 |
||
515 |
remaining = remaining.mid(sizeof(itersbit)-1); |
|
516 |
||
517 |
qint64 total = sTotal.toLongLong(&ok); |
|
518 |
if (!ok) { |
|
519 |
if (error) *error = sTotal + " (total) is not a valid integer"; |
|
520 |
return out; |
|
521 |
} |
|
522 |
||
523 |
/* Remaining: 1) */ |
|
524 |
QString sIters; |
|
525 |
while (remaining != QLatin1String(")") && !remaining.isEmpty()) { |
|
526 |
sIters += remaining.at(0); |
|
527 |
remaining.remove(0,1); |
|
528 |
} |
|
529 |
if (remaining.isEmpty()) { |
|
530 |
if (error) *error = "Could not find pattern: '<num>)'"; |
|
531 |
return out; |
|
532 |
} |
|
533 |
qint64 iters = sIters.toLongLong(&ok); |
|
534 |
if (!ok) { |
|
535 |
if (error) *error = sIters + " (iterations) is not a valid integer"; |
|
536 |
return out; |
|
537 |
} |
|
538 |
||
539 |
double calcFirstNumber = double(total)/double(iters); |
|
540 |
if (!qFuzzyCompare(firstNumber, calcFirstNumber)) { |
|
541 |
if (error) *error = QString("total/iters is %1, but benchlib output result as %2").arg(calcFirstNumber).arg(firstNumber); |
|
542 |
return out; |
|
543 |
} |
|
544 |
||
545 |
out.total = total; |
|
546 |
out.unit = unit; |
|
547 |
out.iterations = iters; |
|
548 |
return out; |
|
549 |
} |
|
550 |
||
13
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
551 |
void tst_Selftests::cleanupTestCase() |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
552 |
{ |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
553 |
QFile::remove("test_output"); |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
554 |
} |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
555 |
|
0 | 556 |
QTEST_MAIN(tst_Selftests) |
557 |
||
558 |
#include "tst_selftests.moc" |