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 <thiago.macieira@intel.com>
This commit is contained in:
Giuseppe D'Angelo 2025-01-17 16:34:28 +01:00
parent fc4aff1249
commit 39ab9e0041
8 changed files with 29 additions and 5 deletions

View File

@ -0,0 +1,19 @@
// Copyright (C) 2025 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
// 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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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>

View File

@ -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
{

View File

@ -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>