Tidy up testlib's parsing of -callgrind parameter

Invert a condition to turn a nested if (that was missing one of its
layers of braces) into an else-if chain, split some long strings to
limit line length.

Change-Id: I10d90487a09affe981aa11c3588281aeb3666df5
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Edward Welbourne 2021-09-28 15:36:41 +02:00
parent 93830d9ed3
commit b67c367e0e

View File

@ -734,14 +734,17 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, const char *const argv[], bool
QTest::noCrashHandler = true;
#if QT_CONFIG(valgrind)
} else if (strcmp(argv[i], "-callgrind") == 0) {
if (QBenchmarkValgrindUtils::haveValgrind())
if (QFileInfo(QDir::currentPath()).isWritable()) {
QBenchmarkGlobalData::current->setMode(QBenchmarkGlobalData::CallgrindParentProcess);
if (!QBenchmarkValgrindUtils::haveValgrind()) {
fprintf(stderr,
"WARNING: Valgrind not found or too old. "
"Make sure it is installed and in your path. "
"Using the walltime measurer.\n");
} else if (QFileInfo(QDir::currentPath()).isWritable()) {
QBenchmarkGlobalData::current->setMode(
QBenchmarkGlobalData::CallgrindParentProcess);
} else {
fprintf(stderr, "WARNING: Current directory not writable. Using the walltime measurer.\n");
}
else {
fprintf(stderr, "WARNING: Valgrind not found or too old. Make sure it is installed and in your path. "
fprintf(stderr,
"WARNING: Current directory not writable. "
"Using the walltime measurer.\n");
}
} else if (strcmp(argv[i], "-callgrindchild") == 0) { // "private" option