summaryrefslogtreecommitdiffstats
path: root/tests/auto/testlib/selftests
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2021-09-28 14:15:41 +0200
committerEdward Welbourne <edward.welbourne@qt.io>2021-12-09 20:54:25 +0100
commit4eb2dcd4b96cbca099d8ac0db12ced5066e1e90e (patch)
treed8dcc1ae2ab0ddbebfc62b2afd8bed74f115779f /tests/auto/testlib/selftests
parent197753d8aea5e550338dabbabf9dd656c611bbcf (diff)
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>
Diffstat (limited to 'tests/auto/testlib/selftests')
-rw-r--r--tests/auto/testlib/selftests/benchlibcallgrind/tst_benchlibcallgrind.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/tests/auto/testlib/selftests/benchlibcallgrind/tst_benchlibcallgrind.cpp b/tests/auto/testlib/selftests/benchlibcallgrind/tst_benchlibcallgrind.cpp
index db3e4123fb..51fb4d358a 100644
--- a/tests/auto/testlib/selftests/benchlibcallgrind/tst_benchlibcallgrind.cpp
+++ b/tests/auto/testlib/selftests/benchlibcallgrind/tst_benchlibcallgrind.cpp
@@ -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"