summaryrefslogtreecommitdiffstats
path: root/src/corelib/plugin
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/corelib/plugin
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/corelib/plugin')
-rw-r--r--src/corelib/plugin/qlibrary.cpp58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp
index 9eeb783b60..6a40b5b818 100644
--- a/src/corelib/plugin/qlibrary.cpp
+++ b/src/corelib/plugin/qlibrary.cpp
@@ -400,6 +400,60 @@ static bool qt_unix_query(const QString &library, uint *version, bool *debug, QL
#endif // Q_OS_UNIX && !Q_OS_MAC && !defined(Q_OS_SYMBIAN) && !defined(QT_NO_PLUGIN_CHECK)
+static void installCoverageTool(QLibraryPrivate *libPrivate)
+{
+#ifdef __COVERAGESCANNER__
+ /*
+ __COVERAGESCANNER__ is defined when Qt has been instrumented for code
+ coverage by TestCocoon. CoverageScanner is the name of the tool that
+ generates the code instrumentation.
+ This code is required here when code coverage analysis with TestCocoon
+ is enabled in order to allow the loading application to register the plugin
+ and then store its execution report. The execution report gathers information
+ about each part of the plugin's code that has been used when
+ the plugin was loaded by the launching application.
+ The execution report for the plugin will go to the same execution report
+ as the one defined for the application loading it.
+ */
+
+ int ret = __coveragescanner_register_library(libPrivate->fileName.toLocal8Bit());
+
+ if (qt_debug_component()) {
+ if (ret >= 0) {
+ qDebug("%s: coverage data for %s registered",
+ Q_FUNC_INFO,
+ qPrintable(libPrivate->fileName));
+ } else {
+ qWarning("%s: could not register %s: error %d; coverage data may be incomplete",
+ Q_FUNC_INFO,
+ qPrintable(libPrivate->fileName),
+ ret);
+ }
+ }
+#else
+ Q_UNUSED(libPrivate);
+#endif
+}
+
+static void releaseCoverageTool(QLibraryPrivate *libPrivate)
+{
+#ifdef __COVERAGESCANNER__
+ /*
+ __COVERAGESCANNER__ is defined when Qt has been instrumented for code
+ coverage by TestCocoon.
+ Here is the code to save the execution data.
+ See comments about initialization in QLibraryPrivate::load().
+ */
+ if (libPrivate->pHnd) {
+ __coveragescanner_save();
+ __coveragescanner_clear();
+ __coveragescanner_unregister_library(libPrivate->fileName.toLocal8Bit());
+ }
+#else
+ Q_UNUSED(libPrivate);
+#endif
+}
+
typedef QMap<QString, QLibraryPrivate*> LibraryMap;
struct LibraryData {
@@ -465,6 +519,8 @@ bool QLibraryPrivate::load()
lib->loadedLibs += this;
libraryRefCount.ref();
}
+
+ installCoverageTool(this);
}
return ret;
@@ -494,6 +550,8 @@ bool QLibraryPrivate::unload()
void QLibraryPrivate::release()
{
+ releaseCoverageTool(this);
+
QMutexLocker locker(qt_library_mutex());
if (!libraryRefCount.deref())
delete this;