From: Caroline Chao Date: Thu, 16 Feb 2012 11:18:43 +0000 (+0100) Subject: CodeCoverage: Fixes regression. X-Git-Tag: qt-v5.0.0-alpha1~337 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5b3d57e8f88dd9adc6787043d7f8e0d305ab4860;p=profile%2Fivi%2Fqtdeclarative.git CodeCoverage: Fixes regression. Fixes segmentation fault introduced by qtbase change: 36f5cc848de2525 Coverage data are now saved in QTestLog::stopLogging. Also the current application name needs to be set for a quick test as well. Remove also code coverage call to installCodeCoverage from quicktest due to refactor of the code coverage setup in qtestlib. This should be less error-prone. See qtbase change: 949b7452e0d2402 Change-Id: I13566cc43dfb3af264d3b2be2e5f2617128f4801 Reviewed-by: Caroline Chao --- diff --git a/src/qmltest/quicktest.cpp b/src/qmltest/quicktest.cpp index 875e992..19acfaf 100644 --- a/src/qmltest/quicktest.cpp +++ b/src/qmltest/quicktest.cpp @@ -68,36 +68,6 @@ #include QT_BEGIN_NAMESPACE -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 -} - - class QTestRootObject : public QObject { Q_OBJECT @@ -224,10 +194,13 @@ int quick_test_main(int argc, char **argv, const char *name, quick_test_viewport argc = outargc; // Parse the command-line arguments. - QuickTestResult::parseArgs(argc, argv); + + // Setting currentAppname and currentTestObjectName (via setProgramName) are needed + // for the code coverage analysis. Must be done before parseArgs is called. + QuickTestResult::setCurrentAppname(argv[0]); QuickTestResult::setProgramName(name); - installCoverageTool(argv[0], name); + QuickTestResult::parseArgs(argc, argv); QTranslator translator; if (!translationFile.isEmpty()) { @@ -338,8 +311,6 @@ int quick_test_main(int argc, char **argv, const char *name, quick_test_viewport // Flush the current logging stream. QuickTestResult::setProgramName(0); - saveCoverageTool(argv[0], QuickTestResult::exitCode() != 0); - //Sometimes delete app cause crash here with some qpa plugins, //so we comment the follow line out to make them happy. //delete app; diff --git a/src/qmltest/quicktestresult.cpp b/src/qmltest/quicktestresult.cpp index 5654c87..33c5fef 100644 --- a/src/qmltest/quicktestresult.cpp +++ b/src/qmltest/quicktestresult.cpp @@ -564,6 +564,11 @@ void QuickTestResult::setProgramName(const char *name) QTestResult::setCurrentTestObject(globalProgramName); } +void QuickTestResult::setCurrentAppname(const char *appname) +{ + QTestResult::setCurrentAppname(appname); +} + int QuickTestResult::exitCode() { #if defined(QTEST_NOEXITCODE) diff --git a/src/qmltest/quicktestresult_p.h b/src/qmltest/quicktestresult_p.h index 3bc6f9c..697cfd7 100644 --- a/src/qmltest/quicktestresult_p.h +++ b/src/qmltest/quicktestresult_p.h @@ -143,6 +143,7 @@ public: // Helper functions for the C++ main() shell. static void parseArgs(int argc, char *argv[]); static void setProgramName(const char *name); + static void setCurrentAppname(const char *appname); static int exitCode(); Q_SIGNALS: