Replace a random define with a __has_include() check
The given reason for needing to define it was that there was no way to test whether <valgrind/valgrind.h> is available to #include; but we now require C++17 hence __has_include(). However, moc doesn't seem to grok that, so move the test's #if-ery inside the test, since otherwise it gets omitted because the test's metatype doesn't know it's there. Change-Id: I75a100787b98a52fad4cfb0b047318a115c998e2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
parent
197753d8ae
commit
4eb2dcd4b9
@ -30,9 +30,9 @@
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QTest>
|
||||
|
||||
/* This test must be explicitly enabled since there are no compile tests for valgrind.h */
|
||||
#ifdef QT_BUG236484
|
||||
#include <valgrind/valgrind.h>
|
||||
#if __has_include(<valgrind/valgrind.h>)
|
||||
# include <valgrind/valgrind.h>
|
||||
# define HAVE_VALGRIND_H
|
||||
#endif
|
||||
|
||||
class tst_BenchlibCallgrind: public QObject
|
||||
@ -40,16 +40,14 @@ class tst_BenchlibCallgrind: public QObject
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
#ifdef QT_BUG236484
|
||||
void failInChildProcess();
|
||||
#endif
|
||||
|
||||
void twoHundredMillionInstructions();
|
||||
};
|
||||
|
||||
#ifdef QT_BUG236484
|
||||
void tst_BenchlibCallgrind::failInChildProcess()
|
||||
{
|
||||
#ifdef HAVE_VALGRIND_H
|
||||
static double f = 1.0;
|
||||
QBENCHMARK {
|
||||
for (int i = 0; i < 1000000; ++i) {
|
||||
@ -57,8 +55,10 @@ void tst_BenchlibCallgrind::failInChildProcess()
|
||||
if (RUNNING_ON_VALGRIND) QFAIL("Running under valgrind!");
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
QSKIP("Skipping test because I can't see <valgrind/valgrind.h> - is valgrind installed ?");
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_BenchlibCallgrind::twoHundredMillionInstructions()
|
||||
{
|
||||
@ -89,4 +89,5 @@ int main(int argc, char *argv[])
|
||||
QTEST_MAIN_IMPL(tst_BenchlibCallgrind)
|
||||
}
|
||||
|
||||
#undef HAVE_VALGRIND_H
|
||||
#include "tst_benchlibcallgrind.moc"
|
||||
|
Loading…
Reference in New Issue
Block a user