From 4eb2dcd4b96cbca099d8ac0db12ced5066e1e90e Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 28 Sep 2021 14:15:41 +0200 Subject: Replace a random define with a __has_include() check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The given reason for needing to define it was that there was no way to test whether 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 Reviewed-by: MÃ¥rten Nordheim Reviewed-by: Qt CI Bot --- .../selftests/benchlibcallgrind/tst_benchlibcallgrind.cpp | 15 ++++++++------- 1 file 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 #include -/* This test must be explicitly enabled since there are no compile tests for valgrind.h */ -#ifdef QT_BUG236484 -#include +#if __has_include() +# include +# 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 - 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" -- cgit v1.2.3