Replace QTESTLIB_USE_VALGRIND with a new feature 'valgrind'
Change-Id: I851788cb1872eef86c75c7bdb2de361a0ff2af6c Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
parent
1798d3ddc8
commit
a8162e1f59
@ -16,6 +16,12 @@
|
|||||||
"purpose": "Provides a utility to test item models.",
|
"purpose": "Provides a utility to test item models.",
|
||||||
"condition": "features.itemmodel",
|
"condition": "features.itemmodel",
|
||||||
"output": [ "publicFeature" ]
|
"output": [ "publicFeature" ]
|
||||||
|
},
|
||||||
|
"valgrind": {
|
||||||
|
"label": "Valgrind",
|
||||||
|
"purpose": "Profiling support with callgrind.",
|
||||||
|
"condition": "(config.linux || config.darwin) && features.process && features.regularexpression",
|
||||||
|
"output": [ "publicFeature" ]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ QBenchmarkMeasurerBase * QBenchmarkGlobalData::createMeasurer()
|
|||||||
{
|
{
|
||||||
QBenchmarkMeasurerBase *measurer = 0;
|
QBenchmarkMeasurerBase *measurer = 0;
|
||||||
if (0) {
|
if (0) {
|
||||||
#ifdef QTESTLIB_USE_VALGRIND
|
#if QT_CONFIG(valgrind)
|
||||||
} else if (mode_ == CallgrindChildProcess || mode_ == CallgrindParentProcess) {
|
} else if (mode_ == CallgrindChildProcess || mode_ == CallgrindParentProcess) {
|
||||||
measurer = new QBenchmarkCallgrindMeasurer;
|
measurer = new QBenchmarkCallgrindMeasurer;
|
||||||
#endif
|
#endif
|
||||||
|
@ -55,12 +55,6 @@
|
|||||||
|
|
||||||
#include <QtCore/qglobal.h>
|
#include <QtCore/qglobal.h>
|
||||||
|
|
||||||
#if (defined(Q_OS_LINUX) || defined Q_OS_MACOS) && QT_CONFIG(process)
|
|
||||||
#define QTESTLIB_USE_VALGRIND
|
|
||||||
#else
|
|
||||||
#undef QTESTLIB_USE_VALGRIND
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(Q_OS_LINUX) && !defined(QT_LINUXBASE) && !defined(Q_OS_ANDROID)
|
#if defined(Q_OS_LINUX) && !defined(QT_LINUXBASE) && !defined(Q_OS_ANDROID)
|
||||||
#define QTESTLIB_USE_PERF_EVENTS
|
#define QTESTLIB_USE_PERF_EVENTS
|
||||||
#else
|
#else
|
||||||
@ -70,7 +64,7 @@
|
|||||||
#include <QtTest/private/qbenchmarkmeasurement_p.h>
|
#include <QtTest/private/qbenchmarkmeasurement_p.h>
|
||||||
#include <QtCore/QMap>
|
#include <QtCore/QMap>
|
||||||
#include <QtTest/qttestglobal.h>
|
#include <QtTest/qttestglobal.h>
|
||||||
#ifdef QTESTLIB_USE_VALGRIND
|
#if QT_CONFIG(valgrind)
|
||||||
#include <QtTest/private/qbenchmarkvalgrind_p.h>
|
#include <QtTest/private/qbenchmarkvalgrind_p.h>
|
||||||
#endif
|
#endif
|
||||||
#ifdef QTESTLIB_USE_PERF_EVENTS
|
#ifdef QTESTLIB_USE_PERF_EVENTS
|
||||||
|
@ -39,8 +39,6 @@
|
|||||||
|
|
||||||
#include <QtTest/private/qbenchmark_p.h>
|
#include <QtTest/private/qbenchmark_p.h>
|
||||||
|
|
||||||
#ifdef QTESTLIB_USE_VALGRIND
|
|
||||||
|
|
||||||
#include <QtTest/private/qbenchmarkvalgrind_p.h>
|
#include <QtTest/private/qbenchmarkvalgrind_p.h>
|
||||||
#include <QtCore/qstringlist.h>
|
#include <QtCore/qstringlist.h>
|
||||||
#include <QtCore/qcoreapplication.h>
|
#include <QtCore/qcoreapplication.h>
|
||||||
@ -243,5 +241,3 @@ QTest::QBenchmarkMetric QBenchmarkCallgrindMeasurer::metricType()
|
|||||||
}
|
}
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
#endif // QTESTLIB_USE_VALGRIND
|
|
||||||
|
@ -58,6 +58,8 @@
|
|||||||
|
|
||||||
class QStringList;
|
class QStringList;
|
||||||
|
|
||||||
|
QT_REQUIRE_CONFIG(valgrind);
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
class QBenchmarkValgrindUtils
|
class QBenchmarkValgrindUtils
|
||||||
|
@ -574,7 +574,7 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, const char *const argv[], bool
|
|||||||
" -nocrashhandler : Disables the crash handler. Useful for debugging crashes.\n"
|
" -nocrashhandler : Disables the crash handler. Useful for debugging crashes.\n"
|
||||||
"\n"
|
"\n"
|
||||||
" Benchmarking options:\n"
|
" Benchmarking options:\n"
|
||||||
#ifdef QTESTLIB_USE_VALGRIND
|
#if QT_CONFIG(valgrind)
|
||||||
" -callgrind : Use callgrind to time benchmarks\n"
|
" -callgrind : Use callgrind to time benchmarks\n"
|
||||||
#endif
|
#endif
|
||||||
#ifdef QTESTLIB_USE_PERF_EVENTS
|
#ifdef QTESTLIB_USE_PERF_EVENTS
|
||||||
@ -717,7 +717,7 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, const char *const argv[], bool
|
|||||||
}
|
}
|
||||||
} else if (strcmp(argv[i], "-nocrashhandler") == 0) {
|
} else if (strcmp(argv[i], "-nocrashhandler") == 0) {
|
||||||
QTest::noCrashHandler = true;
|
QTest::noCrashHandler = true;
|
||||||
#ifdef QTESTLIB_USE_VALGRIND
|
#if QT_CONFIG(valgrind)
|
||||||
} else if (strcmp(argv[i], "-callgrind") == 0) {
|
} else if (strcmp(argv[i], "-callgrind") == 0) {
|
||||||
if (QBenchmarkValgrindUtils::haveValgrind())
|
if (QBenchmarkValgrindUtils::haveValgrind())
|
||||||
if (QFileInfo(QDir::currentPath()).isWritable()) {
|
if (QFileInfo(QDir::currentPath()).isWritable()) {
|
||||||
@ -1459,7 +1459,7 @@ void TestMethods::invokeTests(QObject *testObject) const
|
|||||||
|
|
||||||
QScopedPointer<WatchDog> watchDog;
|
QScopedPointer<WatchDog> watchDog;
|
||||||
if (!debuggerPresent()
|
if (!debuggerPresent()
|
||||||
#ifdef QTESTLIB_USE_VALGRIND
|
#if QT_CONFIG(valgrind)
|
||||||
&& QBenchmarkGlobalData::current->mode() != QBenchmarkGlobalData::CallgrindChildProcess
|
&& QBenchmarkGlobalData::current->mode() != QBenchmarkGlobalData::CallgrindChildProcess
|
||||||
#endif
|
#endif
|
||||||
) {
|
) {
|
||||||
@ -1866,7 +1866,7 @@ int QTest::qRun()
|
|||||||
{
|
{
|
||||||
QTEST_ASSERT(currentTestObject);
|
QTEST_ASSERT(currentTestObject);
|
||||||
|
|
||||||
#ifdef QTESTLIB_USE_VALGRIND
|
#if QT_CONFIG(valgrind)
|
||||||
int callgrindChildExitCode = 0;
|
int callgrindChildExitCode = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1886,7 +1886,7 @@ int QTest::qRun()
|
|||||||
} // !noCrashHandler
|
} // !noCrashHandler
|
||||||
#endif // Q_OS_WIN
|
#endif // Q_OS_WIN
|
||||||
|
|
||||||
#ifdef QTESTLIB_USE_VALGRIND
|
#if QT_CONFIG(valgrind)
|
||||||
if (QBenchmarkGlobalData::current->mode() == QBenchmarkGlobalData::CallgrindParentProcess) {
|
if (QBenchmarkGlobalData::current->mode() == QBenchmarkGlobalData::CallgrindParentProcess) {
|
||||||
if (Q_UNLIKELY(!qApp))
|
if (Q_UNLIKELY(!qApp))
|
||||||
qFatal("QtTest: -callgrind option is not available with QTEST_APPLESS_MAIN");
|
qFatal("QtTest: -callgrind option is not available with QTEST_APPLESS_MAIN");
|
||||||
@ -1944,7 +1944,7 @@ int QTest::qRun()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef QTESTLIB_USE_VALGRIND
|
#if QT_CONFIG(valgrind)
|
||||||
if (QBenchmarkGlobalData::current->mode() == QBenchmarkGlobalData::CallgrindParentProcess)
|
if (QBenchmarkGlobalData::current->mode() == QBenchmarkGlobalData::CallgrindParentProcess)
|
||||||
return callgrindChildExitCode;
|
return callgrindChildExitCode;
|
||||||
#endif
|
#endif
|
||||||
|
@ -17,7 +17,6 @@ HEADERS = \
|
|||||||
qbenchmark_p.h \
|
qbenchmark_p.h \
|
||||||
qbenchmarkmeasurement_p.h \
|
qbenchmarkmeasurement_p.h \
|
||||||
qbenchmarktimemeasurers_p.h \
|
qbenchmarktimemeasurers_p.h \
|
||||||
qbenchmarkvalgrind_p.h \
|
|
||||||
qbenchmarkevent_p.h \
|
qbenchmarkevent_p.h \
|
||||||
qbenchmarkperfevents_p.h \
|
qbenchmarkperfevents_p.h \
|
||||||
qbenchmarkmetric.h \
|
qbenchmarkmetric.h \
|
||||||
@ -70,7 +69,6 @@ SOURCES = \
|
|||||||
qabstracttestlogger.cpp \
|
qabstracttestlogger.cpp \
|
||||||
qbenchmark.cpp \
|
qbenchmark.cpp \
|
||||||
qbenchmarkmeasurement.cpp \
|
qbenchmarkmeasurement.cpp \
|
||||||
qbenchmarkvalgrind.cpp \
|
|
||||||
qbenchmarkevent.cpp \
|
qbenchmarkevent.cpp \
|
||||||
qbenchmarkperfevents.cpp \
|
qbenchmarkperfevents.cpp \
|
||||||
qbenchmarkmetric.cpp \
|
qbenchmarkmetric.cpp \
|
||||||
@ -92,6 +90,13 @@ qtConfig(itemmodeltester) {
|
|||||||
qabstractitemmodeltester.cpp
|
qabstractitemmodeltester.cpp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qtConfig(valgrind) {
|
||||||
|
HEADERS += \
|
||||||
|
qbenchmarkvalgrind_p.h
|
||||||
|
SOURCES += \
|
||||||
|
qbenchmarkvalgrind.cpp
|
||||||
|
}
|
||||||
|
|
||||||
DEFINES *= QT_NO_CAST_TO_ASCII \
|
DEFINES *= QT_NO_CAST_TO_ASCII \
|
||||||
QT_NO_CAST_FROM_ASCII \
|
QT_NO_CAST_FROM_ASCII \
|
||||||
QT_NO_FOREACH \
|
QT_NO_FOREACH \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user