summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <[email protected]>2025-01-17 16:34:28 +0100
committerGiuseppe D'Angelo <[email protected]>2025-01-18 06:49:45 +0100
commit39ab9e00415ed0f4d77daded079b262a8353328d (patch)
tree93e550d46b332936778232fcd11197cc90353c2a
parentfc4aff1249ffbb7a1b34df8a3b06c17aacb22308 (diff)
Testlib: wrap cycle_p.h header
The header triggers compile warnings -- -Wundef, to begin with. Since it's included from multiple places, we either fix the header or wrap it. The header isn't maintained upstream (we actually keep patches "on the side"), so I'll go with the wrapping option, and suppress -Wundef in there. Task-number: QTBUG-132900 Change-Id: I8fdd32fa2ec1cde83ef28945259bce836439f73f Reviewed-by: Thiago Macieira <[email protected]>
-rw-r--r--src/testlib/3rdparty/cycle/cycle_include_p.h19
-rw-r--r--src/testlib/3rdparty/cycle/cycle_p.h4
-rw-r--r--src/testlib/CMakeLists.txt1
-rw-r--r--src/testlib/qbenchmarktimemeasurers_p.h2
-rw-r--r--src/testlib/qtestcase.cpp2
-rw-r--r--src/testlib/qtestcrashhandler.cpp2
-rw-r--r--tests/auto/testlib/selftests/benchlibtickcounter/tst_benchlibtickcounter.cpp2
-rw-r--r--tests/auto/testlib/selftests/tst_selftests.cpp2
8 files changed, 29 insertions, 5 deletions
diff --git a/src/testlib/3rdparty/cycle/cycle_include_p.h b/src/testlib/3rdparty/cycle/cycle_include_p.h
new file mode 100644
index 00000000000..2427c9f6e37
--- /dev/null
+++ b/src/testlib/3rdparty/cycle/cycle_include_p.h
@@ -0,0 +1,19 @@
+// Copyright (C) 2025 Klarälvdalens Datakonsult AB, a KDAB Group company, [email protected], author Giuseppe D'Angelo <[email protected]>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#ifndef QBENCHLIB_CYCLE_INCLUDE_H
+#define QBENCHLIB_CYCLE_INCLUDE_H
+
+#include <QtCore/qcompilerdetection.h>
+
+// This file suppresses compilation warnings coming from cycle_p.h.
+// Include this file instead of cycle_p.h directly.
+
+#define QBENCHLIB_INCLUDING_CYCLE_P
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_CLANG("-Wundef")
+QT_WARNING_DISABLE_GCC("-Wundef")
+#include "cycle_p.h"
+QT_WARNING_POP
+
+#endif // QBENCHLIB_CYCLE_INCLUDE_H
diff --git a/src/testlib/3rdparty/cycle/cycle_p.h b/src/testlib/3rdparty/cycle/cycle_p.h
index f281c55d48f..db1e31444a2 100644
--- a/src/testlib/3rdparty/cycle/cycle_p.h
+++ b/src/testlib/3rdparty/cycle/cycle_p.h
@@ -80,6 +80,10 @@
#define QBENCHLIB_CYCLE_H
#define ticks CycleCounterTicks
+#ifndef QBENCHLIB_INCLUDING_CYCLE_P
+#error Include cycle_include_p.h instead of this file
+#endif
+
/***************************************************************************/
#if TIME_WITH_SYS_TIME
diff --git a/src/testlib/CMakeLists.txt b/src/testlib/CMakeLists.txt
index bfd2b44104c..aa9597f9c4f 100644
--- a/src/testlib/CMakeLists.txt
+++ b/src/testlib/CMakeLists.txt
@@ -15,6 +15,7 @@ qt_internal_add_module(Test
EXCEPTIONS
SOURCES
3rdparty/cycle/cycle_p.h # Needed by tests, so visible to syncqt.
+ 3rdparty/cycle/cycle_include_p.h # Also needed by tests.
3rdparty/catch2/catch_p.h # Also needed by tests.
removed_api.cpp # keep first
qabstracttestlogger.cpp qabstracttestlogger_p.h
diff --git a/src/testlib/qbenchmarktimemeasurers_p.h b/src/testlib/qbenchmarktimemeasurers_p.h
index ce11a7dc6e8..9fda1c963b9 100644
--- a/src/testlib/qbenchmarktimemeasurers_p.h
+++ b/src/testlib/qbenchmarktimemeasurers_p.h
@@ -17,7 +17,7 @@
#include <QtTest/private/qbenchmarkmeasurement_p.h>
#include <QtCore/qelapsedtimer.h>
-#include <QtTest/private/cycle_p.h>
+#include <QtTest/private/cycle_include_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
index 8b7f7479751..d0f0e6b5638 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -37,7 +37,7 @@
#if QT_CONFIG(batch_test_support)
#include <QtTest/private/qtestregistry_p.h>
#endif // QT_CONFIG(batch_test_support)
-#include <QtTest/private/cycle_p.h>
+#include <QtTest/private/cycle_include_p.h>
#include <QtTest/private/qtestblacklist_p.h>
#include <QtTest/private/qtestcrashhandler_p.h>
#if defined(HAVE_XCTEST)
diff --git a/src/testlib/qtestcrashhandler.cpp b/src/testlib/qtestcrashhandler.cpp
index bc4e1629dd9..c2a10dedf64 100644
--- a/src/testlib/qtestcrashhandler.cpp
+++ b/src/testlib/qtestcrashhandler.cpp
@@ -37,7 +37,7 @@
#if QT_CONFIG(batch_test_support)
#include <QtTest/private/qtestregistry_p.h>
#endif // QT_CONFIG(batch_test_support)
-#include <QtTest/private/cycle_p.h>
+#include <QtTest/private/cycle_include_p.h>
#include <QtTest/private/qtestblacklist_p.h>
#if defined(HAVE_XCTEST)
#include <QtTest/private/qxctestlogger_p.h>
diff --git a/tests/auto/testlib/selftests/benchlibtickcounter/tst_benchlibtickcounter.cpp b/tests/auto/testlib/selftests/benchlibtickcounter/tst_benchlibtickcounter.cpp
index 204a28599ef..04371d30182 100644
--- a/tests/auto/testlib/selftests/benchlibtickcounter/tst_benchlibtickcounter.cpp
+++ b/tests/auto/testlib/selftests/benchlibtickcounter/tst_benchlibtickcounter.cpp
@@ -5,7 +5,7 @@
#include <QtCore/QCoreApplication>
#include <QTest>
-#include <private/cycle_p.h>
+#include <private/cycle_include_p.h>
class tst_BenchlibTickCounter: public QObject
{
diff --git a/tests/auto/testlib/selftests/tst_selftests.cpp b/tests/auto/testlib/selftests/tst_selftests.cpp
index 82324e06bf9..a8dd8c6fc5a 100644
--- a/tests/auto/testlib/selftests/tst_selftests.cpp
+++ b/tests/auto/testlib/selftests/tst_selftests.cpp
@@ -21,7 +21,7 @@ QT_REQUIRE_CONFIG(process);
#include <QProcess>
-#include <private/cycle_p.h>
+#include <private/cycle_include_p.h>
#include <QtTest/private/qemulationdetector_p.h>