summaryrefslogtreecommitdiffstats
path: root/src/testlib
diff options
context:
space:
mode:
authorRohan McGovern <rohan.mcgovern@nokia.com>2011-06-23 10:48:33 +0200
committerQt by Nokia <qt-info@nokia.com>2011-11-15 07:21:48 +0100
commit4e014ace452af8f1e22b95ba22d112fc2419ec6d (patch)
tree8a891f75e7cfcd194580fecb1db64479ab3de01b /src/testlib
parentb4d23e61ed19c770caf6b993a8ab0e4474d3f417 (diff)
Integrate testcocoon support into Qt build system.
To instrument a Qt application or library with the TestCocoon coverage tool, do `CONFIG+=testcocoon' in the application .pro file. To instrument Qt itself with testcocoon, use the `-testcocoon' configure option. Change-Id: Ie77109a078d11ea51f7a073621e0df9c752c44ae Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com> Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
Diffstat (limited to 'src/testlib')
-rw-r--r--src/testlib/qtestcase.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
index 4e0205ccbc..f01c588e6d 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -857,6 +857,35 @@ QT_BEGIN_NAMESPACE
QTouchEventSequence is called (ie when the object returned runs out of scope).
*/
+static void installCoverageTool(const char * appname, const char * testname)
+{
+#ifdef __COVERAGESCANNER__
+ // Install Coverage Tool
+ __coveragescanner_install(appname);
+ __coveragescanner_testname(testname);
+ __coveragescanner_clear();
+#else
+ Q_UNUSED(appname);
+ Q_UNUSED(testname);
+#endif
+}
+
+static void saveCoverageTool(const char * appname, bool testfailed)
+{
+#ifdef __COVERAGESCANNER__
+ // install again to make sure the filename is correct.
+ // without this, a plugin or similar may have changed the filename.
+ __coveragescanner_install(appname);
+ __coveragescanner_teststate(testfailed ? "FAILED" : "PASSED");
+ __coveragescanner_save();
+ __coveragescanner_testname("");
+ __coveragescanner_clear();
+#else
+ Q_UNUSED(appname);
+ Q_UNUSED(testfailed);
+#endif
+}
+
namespace QTest
{
static QObject *currentTestObject = 0;
@@ -1904,6 +1933,8 @@ int QTest::qExec(QObject *testObject, int argc, char **argv)
const QMetaObject *metaObject = testObject->metaObject();
QTEST_ASSERT(metaObject);
+ installCoverageTool(argv[0], metaObject->className());
+
QTestResult::setCurrentTestObject(metaObject->className());
qtest_qParseArgs(argc, argv, false);
#ifdef QTESTLIB_USE_VALGRIND
@@ -1954,6 +1985,8 @@ int QTest::qExec(QObject *testObject, int argc, char **argv)
}
#endif
+ saveCoverageTool(argv[0], QTestResult::failCount());
+
#ifdef QTESTLIB_USE_VALGRIND
if (QBenchmarkGlobalData::current->mode() == QBenchmarkGlobalData::CallgrindParentProcess)
return callgrindChildExitCode;