summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2014-02-21 19:02:45 -0800
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-24 11:52:27 +0100
commite85b4ed77a6b77e4a5aa9b858e41ff4bbcea04b0 (patch)
treefe21f2ece7a8703406626bcfcbc3f2f07536c405
parent12a7d23d528262ec1eca3c870fc19ef7d54ca417 (diff)
QtTest: Don't crash when -callgrind is used on QTEST_APPLESS_MAIN
If there's no qApp, then QCoreApplication::arguments() returns an empty list (after printing a warning). That means the callgrind runner can't get the arguments it needs in order to rerun the benchmark. The crash happens because it always uses .at(0) to try and get the executable's path. Even if we get the path from somewhere else, we still need the arguments. Change-Id: I5c74af4d96fc5824b2b7fd7a89648d78393016e2 Reviewed-by: Sergio Ahumada <sahumada@blackberry.com>
-rw-r--r--src/testlib/qtestcase.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
index f0520330af..10bf200f4f 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -2442,6 +2442,9 @@ int QTest::qExec(QObject *testObject, int argc, char **argv)
#ifdef QTESTLIB_USE_VALGRIND
if (QBenchmarkGlobalData::current->mode() == QBenchmarkGlobalData::CallgrindParentProcess) {
+ if (!qApp)
+ qFatal("QtTest: -callgrind option is not available with QTEST_APPLESS_MAIN");
+
const QStringList origAppArgs(QCoreApplication::arguments());
if (!QBenchmarkValgrindUtils::rerunThroughCallgrind(origAppArgs, callgrindChildExitCode))
return -1;