Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | | - |
9 | | - |
10 | | - |
11 | static bool installCoverageTool(const char * appname, const char * testname) | - |
12 | { | - |
13 | | - |
14 | if (!qEnvironmentVariableIsEmpty("QT_TESTCOCOON_ACTIVE")) never evaluated: !qEnvironmentVariableIsEmpty("QT_TESTCOCOON_ACTIVE") | 0 |
15 | return false; never executed: return false; | 0 |
16 | | - |
17 | | - |
18 | qputenv("QT_TESTCOCOON_ACTIVE", "1"); | - |
19 | | - |
20 | | - |
21 | __coveragescanner_install(appname); | - |
22 | __coveragescanner_testname(testname); | - |
23 | __coveragescanner_clear(); | - |
24 | return true; executed: return true; Execution Count:399 | 399 |
25 | | - |
26 | | - |
27 | | - |
28 | | - |
29 | | - |
30 | } | - |
31 | | - |
32 | namespace QTest | - |
33 | { | - |
34 | static QObject *currentTestObject = 0; | - |
35 | | - |
36 | class TestFunction { | - |
37 | public: | - |
38 | TestFunction() : function_(-1), data_(0) {} | 0 |
39 | void set(int function, char *data) { function_ = function; data_ = data; } | 0 |
40 | char *data() const { return data_; } never executed: return data_; | 0 |
41 | int function() const { return function_; } never executed: return function_; | 0 |
42 | ~TestFunction() { delete[] data_; } | 0 |
43 | private: | - |
44 | int function_; | - |
45 | char *data_; | - |
46 | }; | - |
47 | | - |
48 | | - |
49 | | - |
50 | | - |
51 | | - |
52 | | - |
53 | static TestFunction * testFuncs = 0; | - |
54 | static int testFuncCount = 0; | - |
55 | | - |
56 | | - |
57 | static struct TestFuncCleanup | - |
58 | { | - |
59 | void cleanup() | - |
60 | { | - |
61 | delete[] testFuncs; | - |
62 | testFuncCount = 0; | - |
63 | testFuncs = 0; | - |
64 | } executed: } Execution Count:396 | 396 |
65 | | - |
66 | ~TestFuncCleanup() { cleanup(); } executed: } Execution Count:396 | 396 |
67 | } testFuncCleaner; | - |
68 | | - |
69 | static int keyDelay = -1; | - |
70 | static int mouseDelay = -1; | - |
71 | static int eventDelay = -1; | - |
72 | | - |
73 | static bool noCrashHandler = false; | - |
74 | | - |
75 | | - |
76 | | - |
77 | | - |
78 | | - |
79 | static void invokeMethod(QObject *obj, const char *methodName) | - |
80 | { | - |
81 | const QMetaObject *metaObject = obj->metaObject(); | - |
82 | int funcIndex = metaObject->indexOfMethod(methodName); | - |
83 | if (funcIndex >= 0) { evaluated: funcIndex >= 0 yes Evaluation Count:73999 | yes Evaluation Count:66896 |
| 66896-73999 |
84 | QMetaMethod method = metaObject->method(funcIndex); | - |
85 | method.invoke(obj, Qt::DirectConnection); | - |
86 | } executed: } Execution Count:73997 | 73997 |
87 | } executed: } Execution Count:140893 | 140893 |
88 | | - |
89 | int defaultEventDelay() | - |
90 | { | - |
91 | if (eventDelay == -1) { evaluated: eventDelay == -1 yes Evaluation Count:58 | yes Evaluation Count:26 |
| 26-58 |
92 | const QByteArray env = qgetenv("QTEST_EVENT_DELAY"); | - |
93 | if (!env.isEmpty()) partially evaluated: !env.isEmpty() no Evaluation Count:0 | yes Evaluation Count:58 |
| 0-58 |
94 | eventDelay = atoi(env.constData()); never executed: eventDelay = atoi(env.constData()); | 0 |
95 | else | - |
96 | eventDelay = 0; executed: eventDelay = 0; Execution Count:58 | 58 |
97 | } | - |
98 | return eventDelay; executed: return eventDelay; Execution Count:84 | 84 |
99 | } | - |
100 | | - |
101 | int __attribute__((visibility("default"))) defaultMouseDelay() | - |
102 | { | - |
103 | if (mouseDelay == -1) { evaluated: mouseDelay == -1 yes Evaluation Count:37 | yes Evaluation Count:16232 |
| 37-16232 |
104 | const QByteArray env = qgetenv("QTEST_MOUSEEVENT_DELAY"); | - |
105 | if (!env.isEmpty()) partially evaluated: !env.isEmpty() no Evaluation Count:0 | yes Evaluation Count:37 |
| 0-37 |
106 | mouseDelay = atoi(env.constData()); never executed: mouseDelay = atoi(env.constData()); | 0 |
107 | else | - |
108 | mouseDelay = defaultEventDelay(); executed: mouseDelay = defaultEventDelay(); Execution Count:37 | 37 |
109 | } | - |
110 | return mouseDelay; executed: return mouseDelay; Execution Count:16269 | 16269 |
111 | } | - |
112 | | - |
113 | int __attribute__((visibility("default"))) defaultKeyDelay() | - |
114 | { | - |
115 | if (keyDelay == -1) { evaluated: keyDelay == -1 yes Evaluation Count:47 | yes Evaluation Count:10553 |
| 47-10553 |
116 | const QByteArray env = qgetenv("QTEST_KEYEVENT_DELAY"); | - |
117 | if (!env.isEmpty()) partially evaluated: !env.isEmpty() no Evaluation Count:0 | yes Evaluation Count:47 |
| 0-47 |
118 | keyDelay = atoi(env.constData()); never executed: keyDelay = atoi(env.constData()); | 0 |
119 | else | - |
120 | keyDelay = defaultEventDelay(); executed: keyDelay = defaultEventDelay(); Execution Count:47 | 47 |
121 | } | - |
122 | return keyDelay; executed: return keyDelay; Execution Count:10600 | 10600 |
123 | } | - |
124 | | - |
125 | static bool isValidSlot(const QMetaMethod &sl) | - |
126 | { | - |
127 | if (sl.access() != QMetaMethod::Private || sl.parameterCount() != 0 evaluated: sl.access() != QMetaMethod::Private yes Evaluation Count:2172 | yes Evaluation Count:9192 |
evaluated: sl.parameterCount() != 0 yes Evaluation Count:399 | yes Evaluation Count:8793 |
| 399-9192 |
128 | || sl.returnType() != QMetaType::Void || sl.methodType() != QMetaMethod::Slot) partially evaluated: sl.returnType() != QMetaType::Void no Evaluation Count:0 | yes Evaluation Count:8793 |
partially evaluated: sl.methodType() != QMetaMethod::Slot no Evaluation Count:0 | yes Evaluation Count:8793 |
| 0-8793 |
129 | return false; executed: return false; Execution Count:2571 | 2571 |
130 | QByteArray name = sl.name(); | - |
131 | if (name.isEmpty()) partially evaluated: name.isEmpty() no Evaluation Count:0 | yes Evaluation Count:8793 |
| 0-8793 |
132 | return false; never executed: return false; | 0 |
133 | if (name.endsWith("_data")) evaluated: name.endsWith("_data") yes Evaluation Count:1880 | yes Evaluation Count:6913 |
| 1880-6913 |
134 | return false; executed: return false; Execution Count:1880 | 1880 |
135 | if (name == "initTestCase" || name == "cleanupTestCase" evaluated: name == "initTestCase" yes Evaluation Count:50 | yes Evaluation Count:6863 |
evaluated: name == "cleanupTestCase" yes Evaluation Count:17 | yes Evaluation Count:6846 |
| 17-6863 |
136 | || name == "cleanup" || name == "init") evaluated: name == "cleanup" yes Evaluation Count:11 | yes Evaluation Count:6835 |
evaluated: name == "init" yes Evaluation Count:16 | yes Evaluation Count:6819 |
| 11-6835 |
137 | return false; executed: return false; Execution Count:94 | 94 |
138 | return true; executed: return true; Execution Count:6819 | 6819 |
139 | } | - |
140 | | - |
141 | __attribute__((visibility("default"))) bool printAvailableFunctions = false; | - |
142 | __attribute__((visibility("default"))) QStringList testFunctions; | - |
143 | __attribute__((visibility("default"))) QStringList testTags; | - |
144 | | - |
145 | static void qPrintTestSlots(FILE *stream, const char *filter = 0) | - |
146 | { | - |
147 | for (int i = 0; i < QTest::currentTestObject->metaObject()->methodCount(); ++i) { never evaluated: i < QTest::currentTestObject->metaObject()->methodCount() | 0 |
148 | QMetaMethod sl = QTest::currentTestObject->metaObject()->method(i); | - |
149 | if (isValidSlot(sl)) { never evaluated: isValidSlot(sl) | 0 |
150 | const QByteArray signature = sl.methodSignature(); | - |
151 | if (!filter || QString::fromLatin1(signature).contains(QLatin1String(filter), Qt::CaseInsensitive)) never evaluated: QString::fromLatin1(signature).contains(QLatin1String(filter), Qt::CaseInsensitive) | 0 |
152 | fprintf(stream, "%s\n", signature.constData()); never executed: fprintf(stream, "%s\n", signature.constData()); | 0 |
153 | } | 0 |
154 | } | 0 |
155 | } | 0 |
156 | | - |
157 | static void qPrintDataTags(FILE *stream) | - |
158 | { | - |
159 | | - |
160 | QTestLog::setPrintAvailableTagsMode(); | - |
161 | | - |
162 | | - |
163 | QTestTable::globalTestTable(); | - |
164 | invokeMethod(QTest::currentTestObject, "initTestCase_data()"); | - |
165 | const QTestTable *gTable = QTestTable::globalTestTable(); | - |
166 | | - |
167 | const QMetaObject *currTestMetaObj = QTest::currentTestObject->metaObject(); | - |
168 | | - |
169 | | - |
170 | for (int i = 0; i < currTestMetaObj->methodCount(); ++i) { never evaluated: i < currTestMetaObj->methodCount() | 0 |
171 | QMetaMethod tf = currTestMetaObj->method(i); | - |
172 | | - |
173 | if (isValidSlot(tf)) { never evaluated: isValidSlot(tf) | 0 |
174 | | - |
175 | | - |
176 | QStringList localTags; | - |
177 | QTestTable table; | - |
178 | char *slot = qstrdup(tf.methodSignature().constData()); | - |
179 | slot[strlen(slot) - 2] = '\0'; | - |
180 | QByteArray member; | - |
181 | member.resize(qstrlen(slot) + qstrlen("_data()") + 1); | - |
182 | qsnprintf(member.data(), member.size(), "%s_data()", slot); | - |
183 | invokeMethod(QTest::currentTestObject, member.constData()); | - |
184 | for (int j = 0; j < table.dataCount(); ++j) never evaluated: j < table.dataCount() | 0 |
185 | localTags << QLatin1String(table.testData(j)->dataTag()); never executed: localTags << QLatin1String(table.testData(j)->dataTag()); | 0 |
186 | | - |
187 | | - |
188 | if (gTable->dataCount() == 0) { never evaluated: gTable->dataCount() == 0 | 0 |
189 | if (localTags.count() == 0) { never evaluated: localTags.count() == 0 | 0 |
190 | | - |
191 | fprintf(stream, "%s %s\n", currTestMetaObj->className(), slot); | - |
192 | } else { | 0 |
193 | | - |
194 | for (int k = 0; k < localTags.size(); ++k) never evaluated: k < localTags.size() | 0 |
195 | fprintf( | 0 |
196 | stream, "%s %s %s\n", | 0 |
197 | currTestMetaObj->className(), slot, localTags.at(k).toLatin1().data()); never executed: fprintf( stream, "%s %s %s\n", currTestMetaObj->className(), slot, localTags.at(k).toLatin1().data()); | 0 |
198 | } | 0 |
199 | } else { | - |
200 | for (int j = 0; j < gTable->dataCount(); ++j) { never evaluated: j < gTable->dataCount() | 0 |
201 | if (localTags.count() == 0) { never evaluated: localTags.count() == 0 | 0 |
202 | | - |
203 | fprintf( | - |
204 | stream, "%s %s __global__ %s\n", | - |
205 | currTestMetaObj->className(), slot, gTable->testData(j)->dataTag()); | - |
206 | } else { | 0 |
207 | | - |
208 | | - |
209 | for (int k = 0; k < localTags.size(); ++k) never evaluated: k < localTags.size() | 0 |
210 | fprintf( | 0 |
211 | stream, "%s %s %s __global__ %s\n", currTestMetaObj->className(), slot, | 0 |
212 | localTags.at(k).toLatin1().data(), gTable->testData(j)->dataTag()); never executed: fprintf( stream, "%s %s %s __global__ %s\n", currTestMetaObj->className(), slot, localTags.at(k).toLatin1().data(), gTable->testData(j)->dataTag()); | 0 |
213 | } | 0 |
214 | } | - |
215 | } | 0 |
216 | | - |
217 | delete[] slot; | - |
218 | } | 0 |
219 | } | 0 |
220 | } | 0 |
221 | | - |
222 | static int qToInt(char *str) | - |
223 | { | - |
224 | char *pEnd; | - |
225 | int l = (int)strtol(str, &pEnd, 10); | - |
226 | if (*pEnd != 0) { never evaluated: *pEnd != 0 | 0 |
227 | fprintf(stderr, "Invalid numeric parameter: '%s'\n", str); | - |
228 | exit(1); | 0 |
229 | } | - |
230 | return l; never executed: return l; | 0 |
231 | } | - |
232 | | - |
233 | __attribute__((visibility("default"))) void qtest_qParseArgs(int argc, char *argv[], bool qml) | - |
234 | { | - |
235 | QTestLog::LogMode logFormat = QTestLog::Plain; | - |
236 | const char *logFilename = 0; | - |
237 | | - |
238 | const char *testOptions = | - |
239 | " New-style logging options:\n" | - |
240 | " -o filename,format : Output results to file in the specified format\n" | - |
241 | " Use - to output to stdout\n" | - |
242 | " Valid formats are:\n" | - |
243 | " txt : Plain text\n" | - |
244 | " xunitxml : XML XUnit document\n" | - |
245 | " xml : XML document\n" | - |
246 | " lightxml : A stream of XML tags\n" | - |
247 | "\n" | - |
248 | " *** Multiple loggers can be specified, but at most one can log to stdout.\n" | - |
249 | "\n" | - |
250 | " Old-style logging options:\n" | - |
251 | " -o filename : Write the output into file\n" | - |
252 | " -txt : Output results in Plain Text\n" | - |
253 | " -xunitxml : Output results as XML XUnit document\n" | - |
254 | " -xml : Output results as XML document\n" | - |
255 | " -lightxml : Output results as stream of XML tags\n" | - |
256 | "\n" | - |
257 | " *** If no output file is specified, stdout is assumed.\n" | - |
258 | " *** If no output format is specified, -txt is assumed.\n" | - |
259 | "\n" | - |
260 | " Test log detail options:\n" | - |
261 | " -silent : Log failures and fatal errors only\n" | - |
262 | " -v1 : Log the start of each testfunction\n" | - |
263 | " -v2 : Log each QVERIFY/QCOMPARE/QTEST (implies -v1)\n" | - |
264 | " -vs : Log every signal emission and resulting slot invocations\n" | - |
265 | "\n" | - |
266 | " *** The -silent and -v1 options only affect plain text output.\n" | - |
267 | "\n" | - |
268 | " Testing options:\n" | - |
269 | " -functions : Returns a list of current testfunctions\n" | - |
270 | " -datatags : Returns a list of current data tags.\n" | - |
271 | " A global data tag is preceded by ' __global__ '.\n" | - |
272 | " -eventdelay ms : Set default delay for mouse and keyboard simulation to ms milliseconds\n" | - |
273 | " -keydelay ms : Set default delay for keyboard simulation to ms milliseconds\n" | - |
274 | " -mousedelay ms : Set default delay for mouse simulation to ms milliseconds\n" | - |
275 | " -maxwarnings n : Sets the maximum amount of messages to output.\n" | - |
276 | " 0 means unlimited, default: 2000\n" | - |
277 | | - |
278 | " -nocrashhandler : Disables the crash handler\n" | - |
279 | | - |
280 | "\n" | - |
281 | " Benchmarking options:\n" | - |
282 | | - |
283 | " -callgrind : Use callgrind to time benchmarks\n" | - |
284 | | - |
285 | | - |
286 | " -tickcounter : Use CPU tick counters to time benchmarks\n" | - |
287 | | - |
288 | " -eventcounter : Counts events received during benchmarks\n" | - |
289 | " -minimumvalue n : Sets the minimum acceptable measurement value\n" | - |
290 | " -iterations n : Sets the number of accumulation iterations.\n" | - |
291 | " -median n : Sets the number of median iterations.\n" | - |
292 | " -vb : Print out verbose benchmarking information.\n"; | - |
293 | | - |
294 | for (int i = 1; i < argc; ++i) { never evaluated: i < argc | 0 |
295 | if (strcmp(argv[i], "-help") == 0 || strcmp(argv[i], "--help") == 0 never evaluated: strcmp(argv[i], "-help") == 0 never evaluated: strcmp(argv[i], "--help") == 0 | 0 |
296 | || strcmp(argv[i], "/?") == 0) { never evaluated: strcmp(argv[i], "/?") == 0 | 0 |
297 | printf(" Usage: %s [options] [testfunction[:testdata]]...\n" | - |
298 | " By default, all testfunctions will be run.\n\n" | - |
299 | "%s", argv[0], testOptions); | - |
300 | | - |
301 | if (qml) { | 0 |
302 | printf ("\n" | - |
303 | " QmlTest options:\n" | - |
304 | " -import dir : Specify an import directory.\n" | - |
305 | " -input dir/file : Specify the root directory for test cases or a single test case file.\n" | - |
306 | " -qtquick1 : Run with QtQuick 1 rather than QtQuick 2.\n" | - |
307 | " -translation file : Specify the translation file.\n" | - |
308 | ); | - |
309 | } | 0 |
310 | | - |
311 | printf("\n" | - |
312 | " -help : This help\n"); | - |
313 | exit(0); | 0 |
314 | } else if (strcmp(argv[i], "-functions") == 0) { never evaluated: strcmp(argv[i], "-functions") == 0 | 0 |
315 | if (qml) { | 0 |
316 | QTest::printAvailableFunctions = true; | - |
317 | } else { | 0 |
318 | qPrintTestSlots(stdout); | - |
319 | exit(0); | 0 |
320 | } | - |
321 | } else if (strcmp(argv[i], "-datatags") == 0) { never evaluated: strcmp(argv[i], "-datatags") == 0 | 0 |
322 | if (!qml) { | 0 |
323 | qPrintDataTags(stdout); | - |
324 | exit(0); | 0 |
325 | } | - |
326 | } else if (strcmp(argv[i], "-txt") == 0) { never evaluated: strcmp(argv[i], "-txt") == 0 | 0 |
327 | logFormat = QTestLog::Plain; | - |
328 | } else if (strcmp(argv[i], "-xunitxml") == 0) { never evaluated: strcmp(argv[i], "-xunitxml") == 0 | 0 |
329 | logFormat = QTestLog::XunitXML; | - |
330 | } else if (strcmp(argv[i], "-xml") == 0) { never evaluated: strcmp(argv[i], "-xml") == 0 | 0 |
331 | logFormat = QTestLog::XML; | - |
332 | } else if (strcmp(argv[i], "-lightxml") == 0) { never evaluated: strcmp(argv[i], "-lightxml") == 0 | 0 |
333 | logFormat = QTestLog::LightXML; | - |
334 | } else if (strcmp(argv[i], "-silent") == 0) { never evaluated: strcmp(argv[i], "-silent") == 0 | 0 |
335 | QTestLog::setVerboseLevel(-1); | - |
336 | } else if (strcmp(argv[i], "-v1") == 0) { never evaluated: strcmp(argv[i], "-v1") == 0 | 0 |
337 | QTestLog::setVerboseLevel(1); | - |
338 | } else if (strcmp(argv[i], "-v2") == 0) { never evaluated: strcmp(argv[i], "-v2") == 0 | 0 |
339 | QTestLog::setVerboseLevel(2); | - |
340 | } else if (strcmp(argv[i], "-vs") == 0) { never evaluated: strcmp(argv[i], "-vs") == 0 | 0 |
341 | QSignalDumper::startDump(); | - |
342 | } else if (strcmp(argv[i], "-o") == 0) { never evaluated: strcmp(argv[i], "-o") == 0 | 0 |
343 | if (i + 1 >= argc) { never evaluated: i + 1 >= argc | 0 |
344 | fprintf(stderr, "-o needs an extra parameter specifying the filename and optional format\n"); | - |
345 | exit(1); | 0 |
346 | } | - |
347 | ++i; | - |
348 | | - |
349 | char *filename = new char[strlen(argv[i])+1]; | - |
350 | char *format = new char[strlen(argv[i])+1]; | - |
351 | if (sscanf(argv[i], "%[^,],%s", filename, format) == 1) { never evaluated: sscanf(argv[i], "%[^,],%s", filename, format) == 1 | 0 |
352 | | - |
353 | logFilename = argv[i]; | - |
354 | } else { | 0 |
355 | | - |
356 | if (strcmp(format, "txt") == 0) never evaluated: strcmp(format, "txt") == 0 | 0 |
357 | logFormat = QTestLog::Plain; never executed: logFormat = QTestLog::Plain; | 0 |
358 | else if (strcmp(format, "lightxml") == 0) never evaluated: strcmp(format, "lightxml") == 0 | 0 |
359 | logFormat = QTestLog::LightXML; never executed: logFormat = QTestLog::LightXML; | 0 |
360 | else if (strcmp(format, "xml") == 0) never evaluated: strcmp(format, "xml") == 0 | 0 |
361 | logFormat = QTestLog::XML; never executed: logFormat = QTestLog::XML; | 0 |
362 | else if (strcmp(format, "xunitxml") == 0) never evaluated: strcmp(format, "xunitxml") == 0 | 0 |
363 | logFormat = QTestLog::XunitXML; never executed: logFormat = QTestLog::XunitXML; | 0 |
364 | else { | - |
365 | fprintf(stderr, "output format must be one of txt, lightxml, xml or xunitxml\n"); | - |
366 | exit(1); | 0 |
367 | } | - |
368 | if (strcmp(filename, "-") == 0 && QTestLog::loggerUsingStdout()) { never evaluated: strcmp(filename, "-") == 0 never evaluated: QTestLog::loggerUsingStdout() | 0 |
369 | fprintf(stderr, "only one logger can log to stdout\n"); | - |
370 | exit(1); | 0 |
371 | } | - |
372 | QTestLog::addLogger(logFormat, filename); | - |
373 | } | 0 |
374 | delete [] filename; | - |
375 | delete [] format; | - |
376 | } else if (strcmp(argv[i], "-eventdelay") == 0) { never evaluated: strcmp(argv[i], "-eventdelay") == 0 | 0 |
377 | if (i + 1 >= argc) { never evaluated: i + 1 >= argc | 0 |
378 | fprintf(stderr, "-eventdelay needs an extra parameter to indicate the delay(ms)\n"); | - |
379 | exit(1); | 0 |
380 | } else { | - |
381 | QTest::eventDelay = qToInt(argv[++i]); | - |
382 | } | 0 |
383 | } else if (strcmp(argv[i], "-keydelay") == 0) { never evaluated: strcmp(argv[i], "-keydelay") == 0 | 0 |
384 | if (i + 1 >= argc) { never evaluated: i + 1 >= argc | 0 |
385 | fprintf(stderr, "-keydelay needs an extra parameter to indicate the delay(ms)\n"); | - |
386 | exit(1); | 0 |
387 | } else { | - |
388 | QTest::keyDelay = qToInt(argv[++i]); | - |
389 | } | 0 |
390 | } else if (strcmp(argv[i], "-mousedelay") == 0) { never evaluated: strcmp(argv[i], "-mousedelay") == 0 | 0 |
391 | if (i + 1 >= argc) { never evaluated: i + 1 >= argc | 0 |
392 | fprintf(stderr, "-mousedelay needs an extra parameter to indicate the delay(ms)\n"); | - |
393 | exit(1); | 0 |
394 | } else { | - |
395 | QTest::mouseDelay = qToInt(argv[++i]); | - |
396 | } | 0 |
397 | } else if (strcmp(argv[i], "-maxwarnings") == 0) { never evaluated: strcmp(argv[i], "-maxwarnings") == 0 | 0 |
398 | if (i + 1 >= argc) { never evaluated: i + 1 >= argc | 0 |
399 | fprintf(stderr, "-maxwarnings needs an extra parameter with the amount of warnings\n"); | - |
400 | exit(1); | 0 |
401 | } else { | - |
402 | QTestLog::setMaxWarnings(qToInt(argv[++i])); | - |
403 | } | 0 |
404 | | - |
405 | } else if (strcmp(argv[i], "-nocrashhandler") == 0) { never evaluated: strcmp(argv[i], "-nocrashhandler") == 0 | 0 |
406 | QTest::noCrashHandler = true; | - |
407 | | - |
408 | | - |
409 | } else if (strcmp(argv[i], "-callgrind") == 0) { never evaluated: strcmp(argv[i], "-callgrind") == 0 | 0 |
410 | if (QBenchmarkValgrindUtils::haveValgrind()) never evaluated: QBenchmarkValgrindUtils::haveValgrind() | 0 |
411 | if (QFileInfo(QDir::currentPath()).isWritable()) { never evaluated: QFileInfo(QDir::currentPath()).isWritable() | 0 |
412 | QBenchmarkGlobalData::current->setMode(QBenchmarkGlobalData::CallgrindParentProcess); | - |
413 | } else { | 0 |
414 | fprintf(stderr, "WARNING: Current directory not writable. Using the walltime measurer.\n"); | - |
415 | } | 0 |
416 | else { | - |
417 | fprintf(stderr, "WARNING: Valgrind not found or too old. Make sure it is installed and in your path. " | - |
418 | "Using the walltime measurer.\n"); | - |
419 | } | 0 |
420 | } else if (strcmp(argv[i], "-callgrindchild") == 0) { never evaluated: strcmp(argv[i], "-callgrindchild") == 0 | 0 |
421 | QBenchmarkGlobalData::current->setMode(QBenchmarkGlobalData::CallgrindChildProcess); | - |
422 | QBenchmarkGlobalData::current->callgrindOutFileBase = | - |
423 | QBenchmarkValgrindUtils::outFileBase(); | - |
424 | | - |
425 | | - |
426 | } else if (strcmp(argv[i], "-tickcounter") == 0) { never evaluated: strcmp(argv[i], "-tickcounter") == 0 | 0 |
427 | QBenchmarkGlobalData::current->setMode(QBenchmarkGlobalData::TickCounter); | - |
428 | | - |
429 | } else if (strcmp(argv[i], "-eventcounter") == 0) { never evaluated: strcmp(argv[i], "-eventcounter") == 0 | 0 |
430 | QBenchmarkGlobalData::current->setMode(QBenchmarkGlobalData::EventCounter); | - |
431 | } else if (strcmp(argv[i], "-minimumvalue") == 0) { never evaluated: strcmp(argv[i], "-minimumvalue") == 0 | 0 |
432 | if (i + 1 >= argc) { never evaluated: i + 1 >= argc | 0 |
433 | fprintf(stderr, "-minimumvalue needs an extra parameter to indicate the minimum time(ms)\n"); | - |
434 | exit(1); | 0 |
435 | } else { | - |
436 | QBenchmarkGlobalData::current->walltimeMinimum = qToInt(argv[++i]); | - |
437 | } | 0 |
438 | } else if (strcmp(argv[i], "-iterations") == 0) { never evaluated: strcmp(argv[i], "-iterations") == 0 | 0 |
439 | if (i + 1 >= argc) { never evaluated: i + 1 >= argc | 0 |
440 | fprintf(stderr, "-iterations needs an extra parameter to indicate the number of iterations\n"); | - |
441 | exit(1); | 0 |
442 | } else { | - |
443 | QBenchmarkGlobalData::current->iterationCount = qToInt(argv[++i]); | - |
444 | } | 0 |
445 | } else if (strcmp(argv[i], "-median") == 0) { never evaluated: strcmp(argv[i], "-median") == 0 | 0 |
446 | if (i + 1 >= argc) { never evaluated: i + 1 >= argc | 0 |
447 | fprintf(stderr, "-median needs an extra parameter to indicate the number of median iterations\n"); | - |
448 | exit(1); | 0 |
449 | } else { | - |
450 | QBenchmarkGlobalData::current->medianIterationCount = qToInt(argv[++i]); | - |
451 | } | 0 |
452 | | - |
453 | } else if (strcmp(argv[i], "-vb") == 0) { never evaluated: strcmp(argv[i], "-vb") == 0 | 0 |
454 | QBenchmarkGlobalData::current->verboseOutput = true; | - |
455 | } else if (argv[i][0] == '-') { never evaluated: argv[i][0] == '-' | 0 |
456 | fprintf(stderr, "Unknown option: '%s'\n\n%s", argv[i], testOptions); | - |
457 | if (qml) { | 0 |
458 | fprintf(stderr, "\nqmltest related options:\n" | - |
459 | " -import : Specify an import directory.\n" | - |
460 | " -input : Specify the root directory for test cases.\n" | - |
461 | " -qtquick1 : Run with QtQuick 1 rather than QtQuick 2.\n" | - |
462 | ); | - |
463 | } | 0 |
464 | | - |
465 | fprintf(stderr, "\n" | - |
466 | " -help : This help\n"); | - |
467 | exit(1); | 0 |
468 | } else if (qml) { | 0 |
469 | | - |
470 | | - |
471 | int colon = -1; | - |
472 | int offset; | - |
473 | for (offset = 0; *(argv[i]+offset); ++offset) { never evaluated: *(argv[i]+offset) | 0 |
474 | if (*(argv[i]+offset) == ':') { never evaluated: *(argv[i]+offset) == ':' | 0 |
475 | if (*(argv[i]+offset+1) == ':') { never evaluated: *(argv[i]+offset+1) == ':' | 0 |
476 | | - |
477 | | - |
478 | ++offset; | - |
479 | } else { | 0 |
480 | colon = offset; | - |
481 | break; | 0 |
482 | } | - |
483 | } | - |
484 | } | 0 |
485 | if (colon == -1) { never evaluated: colon == -1 | 0 |
486 | QTest::testFunctions += QString::fromLatin1(argv[i]); | - |
487 | QTest::testTags += QString(); | - |
488 | } else { | 0 |
489 | QTest::testFunctions += | - |
490 | QString::fromLatin1(argv[i], colon); | - |
491 | QTest::testTags += | - |
492 | QString::fromLatin1(argv[i] + colon + 1); | - |
493 | } | 0 |
494 | } else { | - |
495 | if (!QTest::testFuncs) { never evaluated: !QTest::testFuncs | 0 |
496 | QTest::testFuncs = new QTest::TestFunction[512]; | - |
497 | } | 0 |
498 | | - |
499 | int colon = -1; | - |
500 | char buf[512], *data=0; | - |
501 | int off; | - |
502 | for (off = 0; *(argv[i]+off); ++off) { never evaluated: *(argv[i]+off) | 0 |
503 | if (*(argv[i]+off) == ':') { never evaluated: *(argv[i]+off) == ':' | 0 |
504 | colon = off; | - |
505 | break; | 0 |
506 | } | - |
507 | } | 0 |
508 | if (colon != -1) { never evaluated: colon != -1 | 0 |
509 | data = qstrdup(argv[i]+colon+1); | - |
510 | } | 0 |
511 | qsnprintf(buf, qMin(512, off + 1), "%s", argv[i]); | - |
512 | qsnprintf(buf + off, qMin(512 - off, 3), "()"); | - |
513 | int idx = QTest::currentTestObject->metaObject()->indexOfMethod(buf); | - |
514 | if (idx < 0 || !isValidSlot(QTest::currentTestObject->metaObject()->method(idx))) { never evaluated: !isValidSlot(QTest::currentTestObject->metaObject()->method(idx)) | 0 |
515 | fprintf(stderr, "Unknown test function: '%s'. Possible matches:\n", buf); | - |
516 | buf[off] = 0; | - |
517 | qPrintTestSlots(stderr, buf); | - |
518 | fprintf(stderr, "\n%s -functions\nlists all available test functions.\n", argv[0]); | - |
519 | exit(1); | 0 |
520 | } | - |
521 | testFuncs[testFuncCount].set(idx, data); | - |
522 | testFuncCount++; | - |
523 | do { if (!(QTest::testFuncCount < 512)) qt_assert("QTest::testFuncCount < 512","qtestcase.cpp",1582); } while (0); never executed: qt_assert("QTest::testFuncCount < 512","qtestcase.cpp",1582); never evaluated: !(QTest::testFuncCount < 512) | 0 |
524 | } | 0 |
525 | } | - |
526 | | - |
527 | bool installedTestCoverage = installCoverageTool(QTestResult::currentAppname(), QTestResult::currentTestObjectName()); | - |
528 | QTestLog::setInstalledTestCoverage(installedTestCoverage); | - |
529 | | - |
530 | | - |
531 | | - |
532 | | - |
533 | if (QTestLog::loggerCount() == 0) partially evaluated: QTestLog::loggerCount() == 0 yes Evaluation Count:399 | no Evaluation Count:0 |
| 0-399 |
534 | QTestLog::addLogger(logFormat, logFilename); executed: QTestLog::addLogger(logFormat, logFilename); Execution Count:399 | 399 |
535 | } executed: } Execution Count:399 | 399 |
536 | | - |
537 | QBenchmarkResult qMedian(const QList<QBenchmarkResult> &container) | - |
538 | { | - |
539 | const int count = container.count(); | - |
540 | if (count == 0) partially evaluated: count == 0 no Evaluation Count:0 | yes Evaluation Count:8 |
| 0-8 |
541 | return QBenchmarkResult(); never executed: return QBenchmarkResult(); | 0 |
542 | | - |
543 | if (count == 1) partially evaluated: count == 1 yes Evaluation Count:8 | no Evaluation Count:0 |
| 0-8 |
544 | return container.at(0); executed: return container.at(0); Execution Count:8 | 8 |
545 | | - |
546 | QList<QBenchmarkResult> containerCopy = container; | - |
547 | qSort(containerCopy); | - |
548 | | - |
549 | const int middle = count / 2; | - |
550 | | - |
551 | | - |
552 | return containerCopy.at(middle); never executed: return containerCopy.at(middle); | 0 |
553 | } | - |
554 | | - |
555 | struct QTestDataSetter | - |
556 | { | - |
557 | QTestDataSetter(QTestData *data) | - |
558 | { | - |
559 | QTestResult::setCurrentTestData(data); | - |
560 | } executed: } Execution Count:66438 | 66438 |
561 | ~QTestDataSetter() | - |
562 | { | - |
563 | QTestResult::setCurrentTestData(0); | - |
564 | } executed: } Execution Count:66432 | 66432 |
565 | }; | - |
566 | | - |
567 | static void qInvokeTestMethodDataEntry(char *slot) | - |
568 | { | - |
569 | | - |
570 | | - |
571 | bool isBenchmark = false; | - |
572 | int i = (QBenchmarkGlobalData::current->measurer->needsWarmupIteration()) ? -1 : 0; partially evaluated: (QBenchmarkGlobalData::current->measurer->needsWarmupIteration()) yes Evaluation Count:66438 | no Evaluation Count:0 |
| 0-66438 |
573 | | - |
574 | QList<QBenchmarkResult> results; | - |
575 | do { | - |
576 | QBenchmarkTestMethodData::current->beginDataRun(); | - |
577 | | - |
578 | | - |
579 | bool invokeOk; | - |
580 | do { | - |
581 | invokeMethod(QTest::currentTestObject, "init()"); | - |
582 | if (QTestResult::skipCurrentTest() || QTestResult::currentTestFailed()) partially evaluated: QTestResult::skipCurrentTest() no Evaluation Count:0 | yes Evaluation Count:66446 |
partially evaluated: QTestResult::currentTestFailed() no Evaluation Count:0 | yes Evaluation Count:66446 |
| 0-66446 |
583 | break; | 0 |
584 | | - |
585 | QBenchmarkTestMethodData::current->result = QBenchmarkResult(); | - |
586 | QBenchmarkTestMethodData::current->resultAccepted = false; | - |
587 | | - |
588 | QBenchmarkGlobalData::current->context.tag = | - |
589 | QLatin1String( | - |
590 | QTestResult::currentDataTag() | - |
591 | ? QTestResult::currentDataTag() : ""); | - |
592 | | - |
593 | invokeOk = QMetaObject::invokeMethod(QTest::currentTestObject, slot, | - |
594 | Qt::DirectConnection); | - |
595 | if (!invokeOk) partially evaluated: !invokeOk no Evaluation Count:0 | yes Evaluation Count:66440 |
| 0-66440 |
596 | QTestResult::addFailure("Unable to execute slot", "qtestcase.cpp", 1655); never executed: QTestResult::addFailure("Unable to execute slot", "qtestcase.cpp", 1655); | 0 |
597 | | - |
598 | isBenchmark = QBenchmarkTestMethodData::current->isBenchmark(); | - |
599 | | - |
600 | QTestResult::finishedCurrentTestData(); | - |
601 | | - |
602 | invokeMethod(QTest::currentTestObject, "cleanup()"); | - |
603 | | - |
604 | | - |
605 | if (!isBenchmark) evaluated: !isBenchmark yes Evaluation Count:66424 | yes Evaluation Count:16 |
| 16-66424 |
606 | QTestResult::finishedCurrentTestDataCleanup(); executed: QTestResult::finishedCurrentTestDataCleanup(); Execution Count:66424 | 66424 |
607 | | - |
608 | | - |
609 | | - |
610 | | - |
611 | | - |
612 | } while (invokeOk && isBenchmark executed: } Execution Count:66440 partially evaluated: invokeOk yes Evaluation Count:66440 | no Evaluation Count:0 |
evaluated: isBenchmark yes Evaluation Count:16 | yes Evaluation Count:66424 |
| 0-66440 |
613 | && QBenchmarkTestMethodData::current->resultsAccepted() == false partially evaluated: QBenchmarkTestMethodData::current->resultsAccepted() == false no Evaluation Count:0 | yes Evaluation Count:16 |
| 0-16 |
614 | && !QTestResult::skipCurrentTest() && !QTestResult::currentTestFailed()); never evaluated: !QTestResult::skipCurrentTest() never evaluated: !QTestResult::currentTestFailed() | 0 |
615 | | - |
616 | QBenchmarkTestMethodData::current->endDataRun(); | - |
617 | if (!QTestResult::skipCurrentTest() && !QTestResult::currentTestFailed()) { evaluated: !QTestResult::skipCurrentTest() yes Evaluation Count:66198 | yes Evaluation Count:242 |
partially evaluated: !QTestResult::currentTestFailed() yes Evaluation Count:66198 | no Evaluation Count:0 |
| 0-66198 |
618 | if (i > -1) evaluated: i > -1 yes Evaluation Count:8 | yes Evaluation Count:66190 |
| 8-66190 |
619 | results.append(QBenchmarkTestMethodData::current->result); executed: results.append(QBenchmarkTestMethodData::current->result); Execution Count:8 | 8 |
620 | | - |
621 | if (isBenchmark && QBenchmarkGlobalData::current->verboseOutput) { evaluated: isBenchmark yes Evaluation Count:16 | yes Evaluation Count:66182 |
partially evaluated: QBenchmarkGlobalData::current->verboseOutput no Evaluation Count:0 | yes Evaluation Count:16 |
| 0-66182 |
622 | if (i == -1) { | 0 |
623 | QTestLog::info(QString(QString::fromLatin1("warmup stage result : %1") .arg(QBenchmarkTestMethodData::current->result.value)).toLocal8Bit().constData(), 0, 0); | - |
624 | | - |
625 | | - |
626 | } else { | 0 |
627 | QTestLog::info(QString(QString::fromLatin1("accumulation stage result: %1") .arg(QBenchmarkTestMethodData::current->result.value)).toLocal8Bit().constData(), 0, 0); | - |
628 | | - |
629 | | - |
630 | } | 0 |
631 | } | - |
632 | } executed: } Execution Count:66198 | 66198 |
633 | } while (isBenchmark executed: } Execution Count:66440 evaluated: isBenchmark yes Evaluation Count:16 | yes Evaluation Count:66424 |
| 16-66440 |
634 | && (++i < QBenchmarkGlobalData::current->adjustMedianIterationCount()) evaluated: (++i < QBenchmarkGlobalData::current->adjustMedianIterationCount()) yes Evaluation Count:8 | yes Evaluation Count:8 |
| 8 |
635 | && !QTestResult::skipCurrentTest() && !QTestResult::currentTestFailed()); partially evaluated: !QTestResult::skipCurrentTest() yes Evaluation Count:8 | no Evaluation Count:0 |
partially evaluated: !QTestResult::currentTestFailed() yes Evaluation Count:8 | no Evaluation Count:0 |
| 0-8 |
636 | | - |
637 | | - |
638 | if (isBenchmark) { evaluated: isBenchmark yes Evaluation Count:8 | yes Evaluation Count:66424 |
| 8-66424 |
639 | bool testPassed = !QTestResult::skipCurrentTest() && !QTestResult::currentTestFailed(); partially evaluated: !QTestResult::skipCurrentTest() yes Evaluation Count:8 | no Evaluation Count:0 |
partially evaluated: !QTestResult::currentTestFailed() yes Evaluation Count:8 | no Evaluation Count:0 |
| 0-8 |
640 | QTestResult::finishedCurrentTestDataCleanup(); | - |
641 | | - |
642 | if (testPassed && QBenchmarkTestMethodData::current->resultsAccepted()) partially evaluated: testPassed yes Evaluation Count:8 | no Evaluation Count:0 |
partially evaluated: QBenchmarkTestMethodData::current->resultsAccepted() yes Evaluation Count:8 | no Evaluation Count:0 |
| 0-8 |
643 | QTestLog::addBenchmarkResult(qMedian(results)); executed: QTestLog::addBenchmarkResult(qMedian(results)); Execution Count:8 | 8 |
644 | } executed: } Execution Count:8 | 8 |
645 | } executed: } Execution Count:66432 | 66432 |
646 | static bool qInvokeTestMethod(const char *slotName, const char *data=0) | - |
647 | { | - |
648 | do { if (!(slotName)) qt_assert("slotName","qtestcase.cpp",1717); } while (0); never executed: qt_assert("slotName","qtestcase.cpp",1717); executed: } Execution Count:6819 partially evaluated: !(slotName) no Evaluation Count:0 | yes Evaluation Count:6819 |
partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:6819 |
| 0-6819 |
649 | | - |
650 | QBenchmarkTestMethodData benchmarkData; | - |
651 | QBenchmarkTestMethodData::current = &benchmarkData; | - |
652 | | - |
653 | QBenchmarkGlobalData::current->context.slotName = QLatin1String(slotName); | - |
654 | | - |
655 | char member[512]; | - |
656 | QTestTable table; | - |
657 | | - |
658 | char *slot = qstrdup(slotName); | - |
659 | slot[strlen(slot) - 2] = '\0'; | - |
660 | QTestResult::setCurrentTestFunction(slot); | - |
661 | | - |
662 | const QTestTable *gTable = QTestTable::globalTestTable(); | - |
663 | const int globalDataCount = gTable->dataCount(); | - |
664 | int curGlobalDataIndex = 0; | - |
665 | | - |
666 | | - |
667 | do { | - |
668 | if (!gTable->isEmpty()) evaluated: !gTable->isEmpty() yes Evaluation Count:143 | yes Evaluation Count:6736 |
| 143-6736 |
669 | QTestResult::setCurrentGlobalTestData(gTable->testData(curGlobalDataIndex)); executed: QTestResult::setCurrentGlobalTestData(gTable->testData(curGlobalDataIndex)); Execution Count:143 | 143 |
670 | | - |
671 | if (curGlobalDataIndex == 0) { evaluated: curGlobalDataIndex == 0 yes Evaluation Count:6819 | yes Evaluation Count:60 |
| 60-6819 |
672 | qsnprintf(member, 512, "%s_data()", slot); | - |
673 | invokeMethod(QTest::currentTestObject, member); | - |
674 | } executed: } Execution Count:6819 | 6819 |
675 | | - |
676 | bool foundFunction = false; | - |
677 | if (!QTestResult::skipCurrentTest()) { evaluated: !QTestResult::skipCurrentTest() yes Evaluation Count:6804 | yes Evaluation Count:75 |
| 75-6804 |
678 | int curDataIndex = 0; | - |
679 | const int dataCount = table.dataCount(); | - |
680 | | - |
681 | | - |
682 | if (data && !dataCount) { partially evaluated: data no Evaluation Count:0 | yes Evaluation Count:6804 |
never evaluated: !dataCount | 0-6804 |
683 | | - |
684 | if (!*data) | 0 |
685 | data = 0; never executed: data = 0; | 0 |
686 | else { | - |
687 | fprintf(stderr, "Unknown testdata for function %s: '%s'\n", slotName, data); | - |
688 | fprintf(stderr, "Function has no testdata.\n"); | - |
689 | return false; never executed: return false; | 0 |
690 | } | - |
691 | } | - |
692 | | - |
693 | | - |
694 | do { | - |
695 | QTestResult::setSkipCurrentTest(false); | - |
696 | if (!data || !qstrcmp(data, table.testData(curDataIndex)->dataTag())) { partially evaluated: !data yes Evaluation Count:66438 | no Evaluation Count:0 |
never evaluated: !qstrcmp(data, table.testData(curDataIndex)->dataTag()) | 0-66438 |
697 | foundFunction = true; | - |
698 | QTestDataSetter s(curDataIndex >= dataCount ? static_cast<QTestData *>(0) | - |
699 | : table.testData(curDataIndex)); | - |
700 | | - |
701 | qInvokeTestMethodDataEntry(slot); | - |
702 | | - |
703 | if (data) partially evaluated: data no Evaluation Count:0 | yes Evaluation Count:66432 |
| 0-66432 |
704 | break; | 0 |
705 | } executed: } Execution Count:66432 | 66432 |
706 | ++curDataIndex; | - |
707 | } while (curDataIndex < dataCount); executed: } Execution Count:66432 evaluated: curDataIndex < dataCount yes Evaluation Count:59634 | yes Evaluation Count:6798 |
| 6798-66432 |
708 | } executed: } Execution Count:6798 | 6798 |
709 | | - |
710 | if (data && !foundFunction) { partially evaluated: data no Evaluation Count:0 | yes Evaluation Count:6873 |
never evaluated: !foundFunction | 0-6873 |
711 | fprintf(stderr, "Unknown testdata for function %s: '%s'\n", slotName, data); | - |
712 | fprintf(stderr, "Available testdata:\n"); | - |
713 | for (int i = 0; i < table.dataCount(); ++i) never evaluated: i < table.dataCount() | 0 |
714 | fprintf(stderr, "%s\n", table.testData(i)->dataTag()); never executed: fprintf(stderr, "%s\n", table.testData(i)->dataTag()); | 0 |
715 | return false; never executed: return false; | 0 |
716 | } | - |
717 | | - |
718 | QTestResult::setCurrentGlobalTestData(0); | - |
719 | ++curGlobalDataIndex; | - |
720 | } while (curGlobalDataIndex < globalDataCount); executed: } Execution Count:6873 evaluated: curGlobalDataIndex < globalDataCount yes Evaluation Count:60 | yes Evaluation Count:6813 |
| 60-6873 |
721 | | - |
722 | QTestResult::finishedCurrentTestFunction(); | - |
723 | QTestResult::setSkipCurrentTest(false); | - |
724 | QTestResult::setCurrentTestData(0); | - |
725 | delete[] slot; | - |
726 | | - |
727 | return true; executed: return true; Execution Count:6813 | 6813 |
728 | } | - |
729 | | - |
730 | void *fetchData(QTestData *data, const char *tagName, int typeId) | - |
731 | { | - |
732 | do { if (!(typeId)) qt_assert("typeId","qtestcase.cpp",1801); } while (0); never executed: qt_assert("typeId","qtestcase.cpp",1801); executed: } Execution Count:177930 partially evaluated: !(typeId) no Evaluation Count:0 | yes Evaluation Count:177930 |
partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:177930 |
| 0-177930 |
733 | do { if (!(data)) qt_assert_x("QTest::fetchData()", "Test data requested, but no testdata available.","qtestcase.cpp",1802); } while (0); never executed: qt_assert_x("QTest::fetchData()", "Test data requested, but no testdata available.","qtestcase.cpp",1802); executed: } Execution Count:177930 partially evaluated: !(data) no Evaluation Count:0 | yes Evaluation Count:177930 |
partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:177930 |
| 0-177930 |
734 | do { if (!(data->parent())) qt_assert("data->parent()","qtestcase.cpp",1803); } while (0); never executed: qt_assert("data->parent()","qtestcase.cpp",1803); executed: } Execution Count:177930 partially evaluated: !(data->parent()) no Evaluation Count:0 | yes Evaluation Count:177930 |
partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:177930 |
| 0-177930 |
735 | | - |
736 | int idx = data->parent()->indexOf(tagName); | - |
737 | | - |
738 | if (idx == -1 || idx >= data->dataCount()) { partially evaluated: idx == -1 no Evaluation Count:0 | yes Evaluation Count:177930 |
partially evaluated: idx >= data->dataCount() no Evaluation Count:0 | yes Evaluation Count:177930 |
| 0-177930 |
739 | QMessageLogger("qtestcase.cpp", 1808, __PRETTY_FUNCTION__).fatal("QFETCH: Requested testdata '%s' not available, check your _data function.", | - |
740 | tagName); | - |
741 | } | 0 |
742 | | - |
743 | if (typeId != data->parent()->elementTypeId(idx)) { partially evaluated: typeId != data->parent()->elementTypeId(idx) no Evaluation Count:0 | yes Evaluation Count:177930 |
| 0-177930 |
744 | QMessageLogger("qtestcase.cpp", 1813, __PRETTY_FUNCTION__).fatal("Requested type '%s' does not match available type '%s'.", | - |
745 | QMetaType::typeName(typeId), | - |
746 | QMetaType::typeName(data->parent()->elementTypeId(idx))); | - |
747 | } | 0 |
748 | | - |
749 | return data->data(idx); executed: return data->data(idx); Execution Count:177930 | 177930 |
750 | } | - |
751 | char *toHexRepresentation(const char *ba, int length) | - |
752 | { | - |
753 | if (length == 0) evaluated: length == 0 yes Evaluation Count:6180 | yes Evaluation Count:23152 |
| 6180-23152 |
754 | return qstrdup(""); executed: return qstrdup(""); Execution Count:6180 | 6180 |
755 | const int maxLen = 50; | - |
756 | const int len = qMin(maxLen, length); | - |
757 | char *result = 0; | - |
758 | | - |
759 | if (length > maxLen) { evaluated: length > maxLen yes Evaluation Count:1684 | yes Evaluation Count:21468 |
| 1684-21468 |
760 | const int size = len * 3 + 4; | - |
761 | result = new char[size]; | - |
762 | | - |
763 | char *const forElipsis = result + size - 5; | - |
764 | forElipsis[0] = ' '; | - |
765 | forElipsis[1] = '.'; | - |
766 | forElipsis[2] = '.'; | - |
767 | forElipsis[3] = '.'; | - |
768 | result[size - 1] = '\0'; | - |
769 | } executed: } Execution Count:1684 | 1684 |
770 | else { | - |
771 | const int size = len * 3; | - |
772 | result = new char[size]; | - |
773 | result[size - 1] = '\0'; | - |
774 | } executed: } Execution Count:21468 | 21468 |
775 | | - |
776 | const char toHex[] = "0123456789ABCDEF"; | - |
777 | int i = 0; | - |
778 | int o = 0; | - |
779 | | - |
780 | while (true) { partially evaluated: true yes Evaluation Count:221572 | no Evaluation Count:0 |
| 0-221572 |
781 | const char at = ba[i]; | - |
782 | | - |
783 | result[o] = toHex[(at >> 4) & 0x0F]; | - |
784 | ++o; | - |
785 | result[o] = toHex[at & 0x0F]; | - |
786 | | - |
787 | ++i; | - |
788 | ++o; | - |
789 | if (i == len) evaluated: i == len yes Evaluation Count:23152 | yes Evaluation Count:198420 |
| 23152-198420 |
790 | break; executed: break; Execution Count:23152 | 23152 |
791 | else { | - |
792 | result[o] = ' '; | - |
793 | ++o; | - |
794 | } executed: } Execution Count:198420 | 198420 |
795 | } | - |
796 | | - |
797 | return result; executed: return result; Execution Count:23152 | 23152 |
798 | } | - |
799 | | - |
800 | static void qInvokeTestMethods(QObject *testObject) | - |
801 | { | - |
802 | const QMetaObject *metaObject = testObject->metaObject(); | - |
803 | do { if (!(metaObject)) qt_assert("metaObject","qtestcase.cpp",1891); } while (0); never executed: qt_assert("metaObject","qtestcase.cpp",1891); executed: } Execution Count:399 partially evaluated: !(metaObject) no Evaluation Count:0 | yes Evaluation Count:399 |
partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:399 |
| 0-399 |
804 | QTestLog::startLogging(); | - |
805 | QTestResult::setCurrentTestFunction("initTestCase"); | - |
806 | QTestTable::globalTestTable(); | - |
807 | invokeMethod(testObject, "initTestCase_data()"); | - |
808 | | - |
809 | if (!QTestResult::skipCurrentTest() && !QTest::currentTestFailed()) { partially evaluated: !QTestResult::skipCurrentTest() yes Evaluation Count:399 | no Evaluation Count:0 |
partially evaluated: !QTest::currentTestFailed() yes Evaluation Count:399 | no Evaluation Count:0 |
| 0-399 |
810 | invokeMethod(testObject, "initTestCase()"); | - |
811 | | - |
812 | | - |
813 | const bool previousFailed = QTestResult::currentTestFailed(); | - |
814 | QTestResult::finishedCurrentTestData(); | - |
815 | QTestResult::finishedCurrentTestDataCleanup(); | - |
816 | QTestResult::finishedCurrentTestFunction(); | - |
817 | | - |
818 | if (!QTestResult::skipCurrentTest() && !previousFailed) { evaluated: !QTestResult::skipCurrentTest() yes Evaluation Count:397 | yes Evaluation Count:1 |
evaluated: !previousFailed yes Evaluation Count:395 | yes Evaluation Count:2 |
| 1-397 |
819 | | - |
820 | if (QTest::testFuncs) { partially evaluated: QTest::testFuncs no Evaluation Count:0 | yes Evaluation Count:395 |
| 0-395 |
821 | for (int i = 0; i != QTest::testFuncCount; i++) { never evaluated: i != QTest::testFuncCount | 0 |
822 | if (!qInvokeTestMethod(metaObject->method(QTest::testFuncs[i].function()).methodSignature().constData(), | 0 |
823 | QTest::testFuncs[i].data())) { never evaluated: !qInvokeTestMethod(metaObject->method(QTest::testFuncs[i].function()).methodSignature().constData(), QTest::testFuncs[i].data()) | 0 |
824 | break; | 0 |
825 | } | - |
826 | } | 0 |
827 | testFuncCleaner.cleanup(); | - |
828 | } else { | 0 |
829 | int methodCount = metaObject->methodCount(); | - |
830 | QMetaMethod *testMethods = new QMetaMethod[methodCount]; | - |
831 | for (int i = 0; i != methodCount; i++) evaluated: i != methodCount yes Evaluation Count:11388 | yes Evaluation Count:395 |
| 395-11388 |
832 | testMethods[i] = metaObject->method(i); executed: testMethods[i] = metaObject->method(i); Execution Count:11388 | 11388 |
833 | for (int i = 0; i != methodCount; i++) { evaluated: i != methodCount yes Evaluation Count:11364 | yes Evaluation Count:389 |
| 389-11364 |
834 | if (!isValidSlot(testMethods[i])) evaluated: !isValidSlot(testMethods[i]) yes Evaluation Count:4545 | yes Evaluation Count:6819 |
| 4545-6819 |
835 | continue; executed: continue; Execution Count:4545 | 4545 |
836 | if (!qInvokeTestMethod(testMethods[i].methodSignature().constData())) partially evaluated: !qInvokeTestMethod(testMethods[i].methodSignature().constData()) no Evaluation Count:0 | yes Evaluation Count:6813 |
| 0-6813 |
837 | break; | 0 |
838 | } executed: } Execution Count:6813 | 6813 |
839 | delete[] testMethods; | - |
840 | testMethods = 0; | - |
841 | } executed: } Execution Count:389 | 389 |
842 | } | - |
843 | | - |
844 | QTestResult::setSkipCurrentTest(false); | - |
845 | QTestResult::setCurrentTestFunction("cleanupTestCase"); | - |
846 | invokeMethod(testObject, "cleanupTestCase()"); | - |
847 | QTestResult::finishedCurrentTestData(); | - |
848 | QTestResult::finishedCurrentTestDataCleanup(); | - |
849 | } executed: } Execution Count:391 | 391 |
850 | QTestResult::finishedCurrentTestFunction(); | - |
851 | QTestResult::setCurrentTestFunction(0); | - |
852 | QTestTable::clearGlobalTestTable(); | - |
853 | | - |
854 | QTestLog::stopLogging(); | - |
855 | } executed: } Execution Count:394 | 394 |
856 | | - |
857 | | - |
858 | class FatalSignalHandler | - |
859 | { | - |
860 | public: | - |
861 | FatalSignalHandler(); | - |
862 | ~FatalSignalHandler(); | - |
863 | | - |
864 | private: | - |
865 | static void signal(int); | - |
866 | sigset_t handledSignals; | - |
867 | }; | - |
868 | | - |
869 | void FatalSignalHandler::signal(int signum) | - |
870 | { | - |
871 | QMessageLogger("qtestcase.cpp", 1959, __PRETTY_FUNCTION__).fatal("Received signal %d", signum); | - |
872 | } | 0 |
873 | | - |
874 | FatalSignalHandler::FatalSignalHandler() | - |
875 | { | - |
876 | sigemptyset(&handledSignals); | - |
877 | | - |
878 | const int fatalSignals[] = { | - |
879 | 1, 2, 3, 4, 8, 11, 13, 15, 0 }; | - |
880 | | - |
881 | struct sigaction act; | - |
882 | memset(&act, 0, sizeof(act)); | - |
883 | act.__sigaction_handler.sa_handler = FatalSignalHandler::signal; | - |
884 | | - |
885 | | - |
886 | | - |
887 | act.sa_flags = 0x80000000; | - |
888 | | - |
889 | | - |
890 | | - |
891 | sigemptyset(&act.sa_mask); | - |
892 | for (int i = 0; fatalSignals[i]; ++i) evaluated: fatalSignals[i] yes Evaluation Count:3192 | yes Evaluation Count:399 |
| 399-3192 |
893 | sigaddset(&act.sa_mask, fatalSignals[i]); executed: sigaddset(&act.sa_mask, fatalSignals[i]); Execution Count:3192 | 3192 |
894 | | - |
895 | struct sigaction oldact; | - |
896 | | - |
897 | for (int i = 0; fatalSignals[i]; ++i) { evaluated: fatalSignals[i] yes Evaluation Count:3192 | yes Evaluation Count:399 |
| 399-3192 |
898 | sigaction(fatalSignals[i], &act, &oldact); | - |
899 | if ( | - |
900 | | - |
901 | oldact.sa_flags & 4 || partially evaluated: oldact.sa_flags & 4 no Evaluation Count:0 | yes Evaluation Count:3192 |
| 0-3192 |
902 | | - |
903 | oldact.__sigaction_handler.sa_handler != ((__sighandler_t) 0)) { evaluated: oldact.__sigaction_handler.sa_handler != ((__sighandler_t) 0) yes Evaluation Count:2188 | yes Evaluation Count:1004 |
| 1004-2188 |
904 | sigaction(fatalSignals[i], &oldact, 0); | - |
905 | } else executed: } Execution Count:2188 | 2188 |
906 | { | - |
907 | sigaddset(&handledSignals, fatalSignals[i]); | - |
908 | } executed: } Execution Count:1004 | 1004 |
909 | } | - |
910 | } executed: } Execution Count:399 | 399 |
911 | | - |
912 | | - |
913 | FatalSignalHandler::~FatalSignalHandler() | - |
914 | { | - |
915 | | - |
916 | struct sigaction act; | - |
917 | memset(&act, 0, sizeof(act)); | - |
918 | act.__sigaction_handler.sa_handler = ((__sighandler_t) 0); | - |
919 | | - |
920 | struct sigaction oldact; | - |
921 | | - |
922 | for (int i = 1; i < 32; ++i) { evaluated: i < 32 yes Evaluation Count:12214 | yes Evaluation Count:394 |
| 394-12214 |
923 | if (!sigismember(&handledSignals, i)) evaluated: !sigismember(&handledSignals, i) yes Evaluation Count:11219 | yes Evaluation Count:995 |
| 995-11219 |
924 | continue; executed: continue; Execution Count:11219 | 11219 |
925 | sigaction(i, &act, &oldact); | - |
926 | | - |
927 | | - |
928 | if (oldact.__sigaction_handler.sa_handler != FatalSignalHandler::signal) evaluated: oldact.__sigaction_handler.sa_handler != FatalSignalHandler::signal yes Evaluation Count:29 | yes Evaluation Count:966 |
| 29-966 |
929 | sigaction(i, &oldact, 0); executed: sigaction(i, &oldact, 0); Execution Count:29 | 29 |
930 | } executed: } Execution Count:995 | 995 |
931 | } executed: } Execution Count:394 | 394 |
932 | | - |
933 | | - |
934 | | - |
935 | | - |
936 | } | - |
937 | int QTest::qExec(QObject *testObject, int argc, char **argv) | - |
938 | { | - |
939 | QBenchmarkGlobalData benchmarkData; | - |
940 | QBenchmarkGlobalData::current = &benchmarkData; | - |
941 | | - |
942 | | - |
943 | int callgrindChildExitCode = 0; | - |
944 | | - |
945 | | - |
946 | | - |
947 | | - |
948 | | - |
949 | | - |
950 | | - |
951 | try { | - |
952 | QTestResult::reset(); | - |
953 | | - |
954 | do { if (!(testObject)) qt_assert("testObject","qtestcase.cpp",2108); } while (0); never executed: qt_assert("testObject","qtestcase.cpp",2108); never evaluated: !(testObject) | 0 |
955 | do { if (!(!currentTestObject)) qt_assert("!currentTestObject","qtestcase.cpp",2109); } while (0); never executed: qt_assert("!currentTestObject","qtestcase.cpp",2109); never evaluated: !(!currentTestObject) | 0 |
956 | currentTestObject = testObject; | - |
957 | | - |
958 | const QMetaObject *metaObject = testObject->metaObject(); | - |
959 | do { if (!(metaObject)) qt_assert("metaObject","qtestcase.cpp",2113); } while (0); never executed: qt_assert("metaObject","qtestcase.cpp",2113); never evaluated: !(metaObject) | 0 |
960 | | - |
961 | QTestResult::setCurrentTestObject(metaObject->className()); | - |
962 | if (argc > 0) never evaluated: argc > 0 | 0 |
963 | QTestResult::setCurrentAppname(argv[0]); never executed: QTestResult::setCurrentAppname(argv[0]); | 0 |
964 | | - |
965 | qtest_qParseArgs(argc, argv, false); | - |
966 | | - |
967 | | - |
968 | if (QBenchmarkGlobalData::current->mode() == QBenchmarkGlobalData::CallgrindParentProcess) { partially evaluated: QBenchmarkGlobalData::current->mode() == QBenchmarkGlobalData::CallgrindParentProcess no Evaluation Count:0 | yes Evaluation Count:399 |
| 0-399 |
969 | const QStringList origAppArgs(QCoreApplication::arguments()); | - |
970 | if (!QBenchmarkValgrindUtils::rerunThroughCallgrind(origAppArgs, callgrindChildExitCode)) never evaluated: !QBenchmarkValgrindUtils::rerunThroughCallgrind(origAppArgs, callgrindChildExitCode) | 0 |
971 | return -1; never executed: return -1; | 0 |
972 | | - |
973 | QBenchmarkValgrindUtils::cleanup(); | - |
974 | | - |
975 | } else | 0 |
976 | | - |
977 | { | - |
978 | | - |
979 | QScopedPointer<FatalSignalHandler> handler; | - |
980 | if (!noCrashHandler) partially evaluated: !noCrashHandler yes Evaluation Count:399 | no Evaluation Count:0 |
| 0-399 |
981 | handler.reset(new FatalSignalHandler); executed: handler.reset(new FatalSignalHandler); Execution Count:399 | 399 |
982 | | - |
983 | qInvokeTestMethods(testObject); | - |
984 | } executed: } Execution Count:394 | 394 |
985 | | - |
986 | | - |
987 | } catch (...) { | - |
988 | QTestResult::addFailure("Caught unhandled exception", "qtestcase.cpp", 2142); | - |
989 | if (QTestResult::currentTestFunction()) { never evaluated: QTestResult::currentTestFunction() | 0 |
990 | QTestResult::finishedCurrentTestFunction(); | - |
991 | QTestResult::setCurrentTestFunction(0); | - |
992 | } | 0 |
993 | | - |
994 | QTestLog::stopLogging(); | - |
995 | | - |
996 | | - |
997 | | - |
998 | | - |
999 | | - |
1000 | currentTestObject = 0; | - |
1001 | | - |
1002 | | - |
1003 | throw; | 0 |
1004 | return 1; | - |
1005 | } | - |
1006 | | - |
1007 | | - |
1008 | currentTestObject = 0; | - |
1009 | | - |
1010 | QSignalDumper::endDump(); | - |
1011 | if (QBenchmarkGlobalData::current->mode() == QBenchmarkGlobalData::CallgrindParentProcess) partially evaluated: QBenchmarkGlobalData::current->mode() == QBenchmarkGlobalData::CallgrindParentProcess no Evaluation Count:0 | yes Evaluation Count:394 |
| 0-394 |
1012 | return callgrindChildExitCode; never executed: return callgrindChildExitCode; | 0 |
1013 | | - |
1014 | | - |
1015 | | - |
1016 | return qMin(QTestLog::failCount(), 127); executed: return qMin(QTestLog::failCount(), 127); Execution Count:394 | 394 |
1017 | } | - |
1018 | int QTest::qExec(QObject *testObject, const QStringList &arguments) | - |
1019 | { | - |
1020 | const int argc = arguments.count(); | - |
1021 | QVarLengthArray<char *> argv(argc); | - |
1022 | | - |
1023 | QVector<QByteArray> args; | - |
1024 | args.reserve(argc); | - |
1025 | | - |
1026 | for (int i = 0; i < argc; ++i) never evaluated: i < argc | 0 |
1027 | { | - |
1028 | args.append(arguments.at(i).toLocal8Bit().constData()); | - |
1029 | argv[i] = args.last().data(); | - |
1030 | } | 0 |
1031 | | - |
1032 | return qExec(testObject, argc, argv.data()); never executed: return qExec(testObject, argc, argv.data()); | 0 |
1033 | } | - |
1034 | | - |
1035 | | - |
1036 | | - |
1037 | void QTest::qFail(const char *statementStr, const char *file, int line) | - |
1038 | { | - |
1039 | QTestResult::addFailure(statementStr, file, line); | - |
1040 | } executed: } Execution Count:79 | 79 |
1041 | | - |
1042 | | - |
1043 | | - |
1044 | bool QTest::qVerify(bool statement, const char *statementStr, const char *description, | - |
1045 | const char *file, int line) | - |
1046 | { | - |
1047 | return QTestResult::verify(statement, statementStr, description, file, line); executed: return QTestResult::verify(statement, statementStr, description, file, line); Execution Count:12563038 | 12563038 |
1048 | } | - |
1049 | | - |
1050 | | - |
1051 | | - |
1052 | | - |
1053 | void QTest::qSkip(const char *message, const char *file, int line) | - |
1054 | { | - |
1055 | QTestResult::addSkip(message, file, line); | - |
1056 | QTestResult::setSkipCurrentTest(true); | - |
1057 | } executed: } Execution Count:315 | 315 |
1058 | | - |
1059 | | - |
1060 | | - |
1061 | | - |
1062 | bool QTest::qExpectFail(const char *dataIndex, const char *comment, | - |
1063 | QTest::TestFailMode mode, const char *file, int line) | - |
1064 | { | - |
1065 | return QTestResult::expectFail(dataIndex, qstrdup(comment), mode, file, line); executed: return QTestResult::expectFail(dataIndex, qstrdup(comment), mode, file, line); Execution Count:10963 | 10963 |
1066 | } | - |
1067 | | - |
1068 | | - |
1069 | | - |
1070 | void QTest::qWarn(const char *message, const char *file, int line) | - |
1071 | { | - |
1072 | QTestLog::warn(message, file, line); | - |
1073 | } executed: } Execution Count:8 | 8 |
1074 | void QTest::ignoreMessage(QtMsgType type, const char *message) | - |
1075 | { | - |
1076 | QTestLog::ignoreMessage(type, message); | - |
1077 | } executed: } Execution Count:469 | 469 |
1078 | QString QTest::qFindTestData(const QString& base, const char *file, int line, const char *builddir) | - |
1079 | { | - |
1080 | QString found; | - |
1081 | | - |
1082 | | - |
1083 | | - |
1084 | | - |
1085 | if (QCoreApplication::instance()) { evaluated: QCoreApplication::instance() yes Evaluation Count:477 | yes Evaluation Count:83 |
| 83-477 |
1086 | QDir binDirectory(QCoreApplication::applicationDirPath()); | - |
1087 | if (binDirectory.exists(base)) { evaluated: binDirectory.exists(base) yes Evaluation Count:472 | yes Evaluation Count:5 |
| 5-472 |
1088 | found = binDirectory.absoluteFilePath(base); | - |
1089 | } executed: } Execution Count:472 | 472 |
1090 | else if (QTestLog::verboseLevel() >= 2) { partially evaluated: QTestLog::verboseLevel() >= 2 no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
1091 | const QString candidate = QDir::toNativeSeparators(QCoreApplication::applicationDirPath() + QLatin1Char('/') + base); | - |
1092 | QTestLog::info(QString(QString::fromLatin1("testdata %1 not found relative to test binary [%2]; " "checking next location").arg(base, candidate)).toLocal8Bit().constData(), | - |
1093 | | - |
1094 | | - |
1095 | file, line); | - |
1096 | } | 0 |
1097 | } | - |
1098 | | - |
1099 | | - |
1100 | if (found.isEmpty()) { evaluated: found.isEmpty() yes Evaluation Count:88 | yes Evaluation Count:472 |
| 88-472 |
1101 | const char *testObjectName = QTestResult::currentTestObjectName(); | - |
1102 | if (testObjectName) { partially evaluated: testObjectName yes Evaluation Count:88 | no Evaluation Count:0 |
| 0-88 |
1103 | QString testsPath = QLibraryInfo::location(QLibraryInfo::TestsPath); | - |
1104 | QString candidate = QString::fromLatin1("%1/%2/%3") | - |
1105 | .arg(testsPath, QFile::decodeName(testObjectName).toLower(), base); | - |
1106 | if (QFileInfo(candidate).exists()) { partially evaluated: QFileInfo(candidate).exists() no Evaluation Count:0 | yes Evaluation Count:88 |
| 0-88 |
1107 | found = candidate; | - |
1108 | } | 0 |
1109 | else if (QTestLog::verboseLevel() >= 2) { partially evaluated: QTestLog::verboseLevel() >= 2 no Evaluation Count:0 | yes Evaluation Count:88 |
| 0-88 |
1110 | QTestLog::info(QString(QString::fromLatin1("testdata %1 not found in tests install path [%2]; " "checking next location") .arg(base, QDir::toNativeSeparators(candidate))).toLocal8Bit().constData(), | - |
1111 | | - |
1112 | | - |
1113 | | - |
1114 | file, line); | - |
1115 | } | 0 |
1116 | } | - |
1117 | } executed: } Execution Count:88 | 88 |
1118 | | - |
1119 | | - |
1120 | if (found.isEmpty()) { evaluated: found.isEmpty() yes Evaluation Count:88 | yes Evaluation Count:472 |
| 88-472 |
1121 | | - |
1122 | QFileInfo srcdir = QFileInfo(QFile::decodeName(file)).path(); | - |
1123 | | - |
1124 | | - |
1125 | | - |
1126 | if (!srcdir.isAbsolute() && builddir) { partially evaluated: !srcdir.isAbsolute() yes Evaluation Count:88 | no Evaluation Count:0 |
partially evaluated: builddir yes Evaluation Count:88 | no Evaluation Count:0 |
| 0-88 |
1127 | srcdir.setFile(QFile::decodeName(builddir) + QLatin1String("/") + srcdir.filePath()); | - |
1128 | } executed: } Execution Count:88 | 88 |
1129 | | - |
1130 | QString candidate = QString::fromLatin1("%1/%2").arg(srcdir.canonicalFilePath(), base); | - |
1131 | if (QFileInfo(candidate).exists()) { evaluated: QFileInfo(candidate).exists() yes Evaluation Count:86 | yes Evaluation Count:2 |
| 2-86 |
1132 | found = candidate; | - |
1133 | } executed: } Execution Count:86 | 86 |
1134 | else if (QTestLog::verboseLevel() >= 2) { partially evaluated: QTestLog::verboseLevel() >= 2 no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
1135 | QTestLog::info(QString(QString::fromLatin1("testdata %1 not found relative to source path [%2]") .arg(base, QDir::toNativeSeparators(candidate))).toLocal8Bit().constData(), | - |
1136 | | - |
1137 | | - |
1138 | file, line); | - |
1139 | } | 0 |
1140 | } | - |
1141 | | - |
1142 | if (found.isEmpty()) { evaluated: found.isEmpty() yes Evaluation Count:2 | yes Evaluation Count:558 |
| 2-558 |
1143 | QTest::qWarn(QString(QString::fromLatin1("testdata %1 could not be located!").arg(base)).toLocal8Bit().constData(), | - |
1144 | | - |
1145 | file, line); | - |
1146 | } executed: } Execution Count:2 | 2 |
1147 | else if (QTestLog::verboseLevel() >= 1) { partially evaluated: QTestLog::verboseLevel() >= 1 no Evaluation Count:0 | yes Evaluation Count:558 |
| 0-558 |
1148 | QTestLog::info(QString(QString::fromLatin1("testdata %1 was located at %2").arg(base, QDir::toNativeSeparators(found))).toLocal8Bit().constData(), | - |
1149 | | - |
1150 | file, line); | - |
1151 | } | 0 |
1152 | | - |
1153 | return found; executed: return found; Execution Count:560 | 560 |
1154 | } | - |
1155 | | - |
1156 | | - |
1157 | | - |
1158 | QString QTest::qFindTestData(const char *base, const char *file, int line, const char *builddir) | - |
1159 | { | - |
1160 | return qFindTestData(QFile::decodeName(base), file, line, builddir); executed: return qFindTestData(QFile::decodeName(base), file, line, builddir); Execution Count:381 | 381 |
1161 | } | - |
1162 | | - |
1163 | | - |
1164 | | - |
1165 | void *QTest::qData(const char *tagName, int typeId) | - |
1166 | { | - |
1167 | return fetchData(QTestResult::currentTestData(), tagName, typeId); executed: return fetchData(QTestResult::currentTestData(), tagName, typeId); Execution Count:176467 | 176467 |
1168 | } | - |
1169 | | - |
1170 | | - |
1171 | | - |
1172 | void *QTest::qGlobalData(const char *tagName, int typeId) | - |
1173 | { | - |
1174 | return fetchData(QTestResult::currentGlobalTestData(), tagName, typeId); executed: return fetchData(QTestResult::currentGlobalTestData(), tagName, typeId); Execution Count:1463 | 1463 |
1175 | } | - |
1176 | | - |
1177 | | - |
1178 | | - |
1179 | void *QTest::qElementData(const char *tagName, int metaTypeId) | - |
1180 | { | - |
1181 | do { if (!(tagName)) qt_assert("tagName","qtestcase.cpp",2388); } while (0); never executed: qt_assert("tagName","qtestcase.cpp",2388); executed: } Execution Count:2191 partially evaluated: !(tagName) no Evaluation Count:0 | yes Evaluation Count:2191 |
partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:2191 |
| 0-2191 |
1182 | QTestData *data = QTestResult::currentTestData(); | - |
1183 | do { if (!(data)) qt_assert("data","qtestcase.cpp",2390); } while (0); never executed: qt_assert("data","qtestcase.cpp",2390); executed: } Execution Count:2191 partially evaluated: !(data) no Evaluation Count:0 | yes Evaluation Count:2191 |
partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:2191 |
| 0-2191 |
1184 | do { if (!(data->parent())) qt_assert("data->parent()","qtestcase.cpp",2391); } while (0); never executed: qt_assert("data->parent()","qtestcase.cpp",2391); executed: } Execution Count:2191 partially evaluated: !(data->parent()) no Evaluation Count:0 | yes Evaluation Count:2191 |
partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:2191 |
| 0-2191 |
1185 | | - |
1186 | int idx = data->parent()->indexOf(tagName); | - |
1187 | do { if (!(idx != -1)) qt_assert("idx != -1","qtestcase.cpp",2394); } while (0); never executed: qt_assert("idx != -1","qtestcase.cpp",2394); executed: } Execution Count:2191 partially evaluated: !(idx != -1) no Evaluation Count:0 | yes Evaluation Count:2191 |
partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:2191 |
| 0-2191 |
1188 | do { if (!(data->parent()->elementTypeId(idx) == metaTypeId)) qt_assert("data->parent()->elementTypeId(idx) == metaTypeId","qtestcase.cpp",2395); } while (0); never executed: qt_assert("data->parent()->elementTypeId(idx) == metaTypeId","qtestcase.cpp",2395); executed: } Execution Count:2191 partially evaluated: !(data->parent()->elementTypeId(idx) == metaTypeId) no Evaluation Count:0 | yes Evaluation Count:2191 |
partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:2191 |
| 0-2191 |
1189 | | - |
1190 | return data->data(data->parent()->indexOf(tagName)); executed: return data->data(data->parent()->indexOf(tagName)); Execution Count:2191 | 2191 |
1191 | } | - |
1192 | | - |
1193 | | - |
1194 | | - |
1195 | void QTest::addColumnInternal(int id, const char *name) | - |
1196 | { | - |
1197 | QTestTable *tbl = QTestTable::currentTestTable(); | - |
1198 | do { if (!(tbl)) qt_assert_x("QTest::addColumn()", "Cannot add testdata outside of a _data slot.","qtestcase.cpp",2405); } while (0); never executed: qt_assert_x("QTest::addColumn()", "Cannot add testdata outside of a _data slot.","qtestcase.cpp",2405); executed: } Execution Count:5550 partially evaluated: !(tbl) no Evaluation Count:0 | yes Evaluation Count:5550 |
partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:5550 |
| 0-5550 |
1199 | | - |
1200 | tbl->addColumn(id, name); | - |
1201 | } executed: } Execution Count:5550 | 5550 |
1202 | QTestData &QTest::newRow(const char *dataTag) | - |
1203 | { | - |
1204 | do { if (!(dataTag)) qt_assert_x("QTest::newRow()", "Data tag can not be null","qtestcase.cpp",2428); } while (0); never executed: qt_assert_x("QTest::newRow()", "Data tag can not be null","qtestcase.cpp",2428); executed: } Execution Count:61136 partially evaluated: !(dataTag) no Evaluation Count:0 | yes Evaluation Count:61136 |
partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:61136 |
| 0-61136 |
1205 | QTestTable *tbl = QTestTable::currentTestTable(); | - |
1206 | do { if (!(tbl)) qt_assert_x("QTest::newRow()", "Cannot add testdata outside of a _data slot.","qtestcase.cpp",2430); } while (0); never executed: qt_assert_x("QTest::newRow()", "Cannot add testdata outside of a _data slot.","qtestcase.cpp",2430); executed: } Execution Count:61136 partially evaluated: !(tbl) no Evaluation Count:0 | yes Evaluation Count:61136 |
partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:61136 |
| 0-61136 |
1207 | do { if (!(tbl->elementCount())) qt_assert_x("QTest::newRow()", "Must add columns before attempting to add rows.","qtestcase.cpp",2431); } while (0); never executed: qt_assert_x("QTest::newRow()", "Must add columns before attempting to add rows.","qtestcase.cpp",2431); executed: } Execution Count:61136 partially evaluated: !(tbl->elementCount()) no Evaluation Count:0 | yes Evaluation Count:61136 |
partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:61136 |
| 0-61136 |
1208 | | - |
1209 | return *tbl->newData(dataTag); executed: return *tbl->newData(dataTag); Execution Count:61136 | 61136 |
1210 | } | - |
1211 | const char *QTest::currentTestFunction() | - |
1212 | { | - |
1213 | return QTestResult::currentTestFunction(); executed: return QTestResult::currentTestFunction(); Execution Count:357 | 357 |
1214 | } | - |
1215 | | - |
1216 | | - |
1217 | | - |
1218 | | - |
1219 | | - |
1220 | const char *QTest::currentDataTag() | - |
1221 | { | - |
1222 | return QTestResult::currentDataTag(); executed: return QTestResult::currentDataTag(); Execution Count:3918 | 3918 |
1223 | } | - |
1224 | | - |
1225 | | - |
1226 | | - |
1227 | | - |
1228 | bool QTest::currentTestFailed() | - |
1229 | { | - |
1230 | return QTestResult::currentTestFailed(); executed: return QTestResult::currentTestFailed(); Execution Count:546 | 546 |
1231 | } | - |
1232 | void QTest::qSleep(int ms) | - |
1233 | { | - |
1234 | do { if (!(ms > 0)) qt_assert("ms > 0","qtestcase.cpp",2508); } while (0); never executed: qt_assert("ms > 0","qtestcase.cpp",2508); executed: } Execution Count:76695 partially evaluated: !(ms > 0) no Evaluation Count:0 | yes Evaluation Count:76696 |
partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:76691 |
| 0-76696 |
1235 | | - |
1236 | | - |
1237 | | - |
1238 | | - |
1239 | struct timespec ts = { ms / 1000, (ms % 1000) * 1000 * 1000 }; | - |
1240 | nanosleep(&ts, __null); | - |
1241 | | - |
1242 | } executed: } Execution Count:76816 | 76816 |
1243 | | - |
1244 | | - |
1245 | | - |
1246 | QObject *QTest::testObject() | - |
1247 | { | - |
1248 | return currentTestObject; executed: return currentTestObject; Execution Count:3 | 3 |
1249 | } | - |
1250 | bool QTest::compare_helper(bool success, const char *failureMsg, | - |
1251 | char *val1, char *val2, | - |
1252 | const char *actual, const char *expected, | - |
1253 | const char *file, int line) | - |
1254 | { | - |
1255 | return QTestResult::compare(success, failureMsg, val1, val2, actual, expected, file, line); executed: return QTestResult::compare(success, failureMsg, val1, val2, actual, expected, file, line); Execution Count:24379010 | 24379010 |
1256 | } | - |
1257 | | - |
1258 | | - |
1259 | | - |
1260 | | - |
1261 | bool QTest::qCompare(float const &t1, float const &t2, const char *actual, const char *expected, | - |
1262 | const char *file, int line) | - |
1263 | { | - |
1264 | return compare_helper(qFuzzyCompare(t1, t2), "Compared floats are not the same (fuzzy compare)", | 1168 |
1265 | toString(t1), toString(t2), actual, expected, file, line); executed: return compare_helper(qFuzzyCompare(t1, t2), "Compared floats are not the same (fuzzy compare)", toString(t1), toString(t2), actual, expected, file, line); Execution Count:1168 | 1168 |
1266 | } | - |
1267 | | - |
1268 | | - |
1269 | | - |
1270 | | - |
1271 | bool QTest::qCompare(double const &t1, double const &t2, const char *actual, const char *expected, | - |
1272 | const char *file, int line) | - |
1273 | { | - |
1274 | return compare_helper(qFuzzyCompare(t1, t2), "Compared doubles are not the same (fuzzy compare)", | 2180502 |
1275 | toString(t1), toString(t2), actual, expected, file, line); executed: return compare_helper(qFuzzyCompare(t1, t2), "Compared doubles are not the same (fuzzy compare)", toString(t1), toString(t2), actual, expected, file, line); Execution Count:2180502 | 2180502 |
1276 | } | - |
1277 | template <> __attribute__((visibility("default"))) char *QTest::toString<short >(const short &t) { char *msg = new char[128]; qsnprintf(msg, 128, "%hd", t); return msg; } executed: return msg; Execution Count:318 | 318 |
1278 | template <> __attribute__((visibility("default"))) char *QTest::toString<ushort >(const ushort &t) { char *msg = new char[128]; qsnprintf(msg, 128, "%hu", t); return msg; } executed: return msg; Execution Count:862 | 862 |
1279 | template <> __attribute__((visibility("default"))) char *QTest::toString<int >(const int &t) { char *msg = new char[128]; qsnprintf(msg, 128, "%d", t); return msg; } executed: return msg; Execution Count:30037538 | 30037538 |
1280 | template <> __attribute__((visibility("default"))) char *QTest::toString<uint >(const uint &t) { char *msg = new char[128]; qsnprintf(msg, 128, "%u", t); return msg; } executed: return msg; Execution Count:2314488 | 2314488 |
1281 | template <> __attribute__((visibility("default"))) char *QTest::toString<long >(const long &t) { char *msg = new char[128]; qsnprintf(msg, 128, "%ld", t); return msg; } executed: return msg; Execution Count:142 | 142 |
1282 | template <> __attribute__((visibility("default"))) char *QTest::toString<ulong >(const ulong &t) { char *msg = new char[128]; qsnprintf(msg, 128, "%lu", t); return msg; } executed: return msg; Execution Count:1726 | 1726 |
1283 | | - |
1284 | | - |
1285 | | - |
1286 | | - |
1287 | template <> __attribute__((visibility("default"))) char *QTest::toString<qint64 >(const qint64 &t) { char *msg = new char[128]; qsnprintf(msg, 128, "%lld", t); return msg; } executed: return msg; Execution Count:1569282 | 1569282 |
1288 | template <> __attribute__((visibility("default"))) char *QTest::toString<quint64 >(const quint64 &t) { char *msg = new char[128]; qsnprintf(msg, 128, "%llu", t); return msg; } executed: return msg; Execution Count:9994 | 9994 |
1289 | | - |
1290 | template <> __attribute__((visibility("default"))) char *QTest::toString<bool >(const bool &t) { char *msg = new char[128]; qsnprintf(msg, 128, "%d", t); return msg; } executed: return msg; Execution Count:191648 | 191648 |
1291 | template <> __attribute__((visibility("default"))) char *QTest::toString<char >(const char &t) { char *msg = new char[128]; qsnprintf(msg, 128, "%c", t); return msg; } executed: return msg; Execution Count:3534234 | 3534234 |
1292 | template <> __attribute__((visibility("default"))) char *QTest::toString<float >(const float &t) { char *msg = new char[128]; qsnprintf(msg, 128, "%g", t); return msg; } executed: return msg; Execution Count:2336 | 2336 |
1293 | template <> __attribute__((visibility("default"))) char *QTest::toString<double >(const double &t) { char *msg = new char[128]; qsnprintf(msg, 128, "%lg", t); return msg; } executed: return msg; Execution Count:4361004 | 4361004 |
1294 | | - |
1295 | | - |
1296 | | - |
1297 | char *QTest::toString(const char *str) | - |
1298 | { | - |
1299 | if (!str) evaluated: !str yes Evaluation Count:16 | yes Evaluation Count:1208 |
| 16-1208 |
1300 | return 0; executed: return 0; Execution Count:16 | 16 |
1301 | char *msg = new char[strlen(str) + 1]; | - |
1302 | return qstrcpy(msg, str); executed: return qstrcpy(msg, str); Execution Count:1208 | 1208 |
1303 | } | - |
1304 | | - |
1305 | | - |
1306 | | - |
1307 | char *QTest::toString(const void *p) | - |
1308 | { | - |
1309 | char *msg = new char[128]; | - |
1310 | qsnprintf(msg, 128, "%p", p); | - |
1311 | return msg; executed: return msg; Execution Count:1916364 | 1916364 |
1312 | } | - |
1313 | | - |
1314 | | - |
1315 | | - |
1316 | bool QTest::compare_string_helper(const char *t1, const char *t2, const char *actual, | - |
1317 | const char *expected, const char *file, int line) | - |
1318 | { | - |
1319 | return compare_helper(qstrcmp(t1, t2) == 0, "Compared strings are not the same", | 612 |
1320 | toString(t1), toString(t2), actual, expected, file, line); executed: return compare_helper(qstrcmp(t1, t2) == 0, "Compared strings are not the same", toString(t1), toString(t2), actual, expected, file, line); Execution Count:612 | 612 |
1321 | } | - |
1322 | | - |
1323 | | - |
| | |