Move QEMU emulation detector to QTest
The emulation detection has been usable only on qtbase tests, move it to QTest so that it can be used in other modules as well. Change-Id: I4b2321b7856414d7b1cfd5e6b1405a633c6bb878 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit 0ce443691fac1188103e5eaa66be40278d5d5e97) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
1c0073ba72
commit
83dcbf75ad
@ -22,6 +22,7 @@ qt_internal_add_module(Test
|
||||
qbenchmarkperfevents.cpp qbenchmarkperfevents_p.h
|
||||
qbenchmarktimemeasurers_p.h
|
||||
qcsvbenchmarklogger.cpp qcsvbenchmarklogger_p.h
|
||||
qemulationdetector_p.h
|
||||
qjunittestlogger.cpp qjunittestlogger_p.h
|
||||
qplaintestlogger.cpp qplaintestlogger_p.h
|
||||
qsignaldumper.cpp qsignaldumper_p.h
|
||||
|
@ -1,9 +1,9 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2017 The Qt Company Ltd.
|
||||
** Copyright (C) 2021 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the test suite of the Qt Toolkit.
|
||||
** This file is part of the QtTest module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
|
||||
** Commercial License Usage
|
||||
@ -26,8 +26,19 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef EMULATIONDETECTOR_H
|
||||
#define EMULATIONDETECTOR_H
|
||||
#ifndef QEMULATIONDETECTOR_P_H
|
||||
#define QEMULATIONDETECTOR_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
@ -46,7 +57,7 @@
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
// Helper functions for detecting if running emulated
|
||||
namespace EmulationDetector {
|
||||
namespace QTestPrivate {
|
||||
|
||||
#ifdef SHOULD_CHECK_ARM_ON_X86
|
||||
static bool isX86SpecificFileAvailable(void);
|
||||
@ -115,7 +126,7 @@ static bool isReportedArchitectureX86(void)
|
||||
}
|
||||
#endif // SHOULD_CHECK_ARM_ON_X86
|
||||
|
||||
} // EmulationDetector namespace
|
||||
} // QTestPrivate namespace
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
@ -6,8 +6,7 @@
|
||||
|
||||
qt_internal_add_test(tst_largefile
|
||||
SOURCES
|
||||
../../../../shared/emulationdetector.h
|
||||
tst_largefile.cpp
|
||||
INCLUDE_DIRECTORIES
|
||||
../../../../shared
|
||||
PUBLIC_LIBRARIES
|
||||
Qt::TestPrivate
|
||||
)
|
||||
|
@ -48,7 +48,7 @@
|
||||
# endif
|
||||
#endif // Q_OS_WIN
|
||||
|
||||
#include "emulationdetector.h"
|
||||
#include <QtTest/private/qemulationdetector_p.h>
|
||||
|
||||
class tst_LargeFile
|
||||
: public QObject
|
||||
@ -73,7 +73,7 @@ public:
|
||||
#endif
|
||||
|
||||
// QEMU only supports < 4GB files
|
||||
if (EmulationDetector::isRunningArmOnX86())
|
||||
if (QTestPrivate::isRunningArmOnX86())
|
||||
maxSizeBits = qMin(maxSizeBits, 28);
|
||||
}
|
||||
|
||||
|
@ -19,12 +19,10 @@ list(APPEND test_data "resources/file1.ext1")
|
||||
|
||||
qt_internal_add_test(tst_qfile
|
||||
SOURCES
|
||||
../../../../shared/emulationdetector.h
|
||||
tst_qfile.cpp
|
||||
INCLUDE_DIRECTORIES
|
||||
../../../../shared
|
||||
PUBLIC_LIBRARIES
|
||||
Qt::CorePrivate
|
||||
Qt::TestPrivate
|
||||
TESTDATA ${test_data}
|
||||
)
|
||||
|
||||
|
@ -46,7 +46,7 @@
|
||||
#include <private/qfsfileengine_p.h>
|
||||
#include <private/qfilesystemengine_p.h>
|
||||
|
||||
#include "emulationdetector.h"
|
||||
#include <QtTest/private/qemulationdetector_p.h>
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
QT_BEGIN_NAMESPACE
|
||||
@ -2553,10 +2553,10 @@ void tst_QFile::virtualFile()
|
||||
// open the file
|
||||
QFile f(fname);
|
||||
QVERIFY2(f.open(QIODevice::ReadOnly), msgOpenFailed(f).constData());
|
||||
if (EmulationDetector::isRunningArmOnX86())
|
||||
if (QTestPrivate::isRunningArmOnX86())
|
||||
QEXPECT_FAIL("","QEMU does not read /proc/self/maps size correctly", Continue);
|
||||
QCOMPARE(f.size(), Q_INT64_C(0));
|
||||
if (EmulationDetector::isRunningArmOnX86())
|
||||
if (QTestPrivate::isRunningArmOnX86())
|
||||
QEXPECT_FAIL("","QEMU does not read /proc/self/maps size correctly", Continue);
|
||||
QVERIFY(f.atEnd());
|
||||
|
||||
|
@ -7,13 +7,11 @@
|
||||
qt_internal_add_test(tst_qprocess
|
||||
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../"
|
||||
SOURCES
|
||||
../../../../../shared/emulationdetector.h
|
||||
../tst_qprocess.cpp
|
||||
INCLUDE_DIRECTORIES
|
||||
../../../../../shared
|
||||
PUBLIC_LIBRARIES
|
||||
Qt::CorePrivate
|
||||
Qt::Network
|
||||
Qt::TestPrivate
|
||||
)
|
||||
|
||||
#### Keys ignored in scope 1:.:.:test.pro:<TRUE>:
|
||||
|
@ -27,11 +27,10 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <emulationdetector.h>
|
||||
|
||||
#include <QTest>
|
||||
#include <QTestEventLoop>
|
||||
#include <QSignalSpy>
|
||||
#include <QtTest/private/qemulationdetector_p.h>
|
||||
|
||||
#include <QtCore/QProcess>
|
||||
#include <QtCore/QDir>
|
||||
@ -1237,7 +1236,7 @@ void tst_QProcess::processInAThread()
|
||||
|
||||
void tst_QProcess::processesInMultipleThreads()
|
||||
{
|
||||
if (EmulationDetector::isRunningArmOnX86())
|
||||
if (QTestPrivate::isRunningArmOnX86())
|
||||
QSKIP("Flakily hangs in QEMU. QTBUG-67760");
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
// run from 1 to 10 threads, but run at least some tests
|
||||
|
@ -15,12 +15,10 @@ list(APPEND test_data "../BLACKLIST")
|
||||
qt_internal_add_test(tst_qtextstream
|
||||
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../"
|
||||
SOURCES
|
||||
../../../../../shared/emulationdetector.h
|
||||
../tst_qtextstream.cpp
|
||||
INCLUDE_DIRECTORIES
|
||||
../../../../../shared
|
||||
PUBLIC_LIBRARIES
|
||||
Qt::Network
|
||||
Qt::TestPrivate
|
||||
TESTDATA ${test_data}
|
||||
)
|
||||
|
||||
|
@ -45,7 +45,7 @@
|
||||
# include <QProcess>
|
||||
#endif
|
||||
#include "../../../network-settings.h"
|
||||
#include "emulationdetector.h"
|
||||
#include <QtTest/private/qemulationdetector_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
template<> struct QMetaTypeId<QIODevice::OpenModeFlag>
|
||||
@ -1417,7 +1417,7 @@ void tst_QTextStream::pos2()
|
||||
// ------------------------------------------------------------------------------
|
||||
void tst_QTextStream::pos3LargeFile()
|
||||
{
|
||||
if (EmulationDetector::isRunningArmOnX86())
|
||||
if (QTestPrivate::isRunningArmOnX86())
|
||||
QSKIP("Running QTextStream::pos() in tight loop is too slow on emulator");
|
||||
|
||||
{
|
||||
|
@ -6,10 +6,9 @@
|
||||
|
||||
qt_internal_add_test(tst_qthread
|
||||
SOURCES
|
||||
../../../../shared/emulationdetector.h
|
||||
tst_qthread.cpp
|
||||
INCLUDE_DIRECTORIES
|
||||
../../../../shared
|
||||
PUBLIC_LIBRARIES
|
||||
Qt::TestPrivate
|
||||
)
|
||||
|
||||
## Scopes:
|
||||
|
@ -55,7 +55,7 @@
|
||||
#include <exception>
|
||||
#endif
|
||||
|
||||
#include "emulationdetector.h"
|
||||
#include <QtTest/private/qemulationdetector_p.h>
|
||||
|
||||
class tst_QThread : public QObject
|
||||
{
|
||||
@ -951,7 +951,7 @@ void tst_QThread::adoptMultipleThreadsOverlap()
|
||||
// Disconnects on WinCE
|
||||
void tst_QThread::stressTest()
|
||||
{
|
||||
if (EmulationDetector::isRunningArmOnX86())
|
||||
if (QTestPrivate::isRunningArmOnX86())
|
||||
QSKIP("Qemu uses too much memory for each thread. Test would run out of memory.");
|
||||
|
||||
QElapsedTimer timer;
|
||||
|
@ -6,15 +6,13 @@
|
||||
|
||||
qt_internal_add_test(tst_qfilesystemmodel
|
||||
SOURCES
|
||||
../../../../shared/emulationdetector.h
|
||||
tst_qfilesystemmodel.cpp
|
||||
INCLUDE_DIRECTORIES
|
||||
../../../../shared
|
||||
PUBLIC_LIBRARIES
|
||||
Qt::CorePrivate
|
||||
Qt::Gui
|
||||
Qt::Widgets
|
||||
Qt::WidgetsPrivate
|
||||
Qt::TestPrivate
|
||||
)
|
||||
|
||||
## Scopes:
|
||||
|
@ -27,11 +27,11 @@
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#include <emulationdetector.h>
|
||||
#include <QTest>
|
||||
#include <QSignalSpy>
|
||||
#include <QTemporaryFile>
|
||||
#include <QLoggingCategory>
|
||||
#include <QtTest/private/qemulationdetector_p.h>
|
||||
|
||||
#ifdef QT_BUILD_INTERNAL
|
||||
#include <private/qfilesystemmodel_p.h>
|
||||
@ -792,7 +792,7 @@ void tst_QFileSystemModel::sort()
|
||||
QTreeView tree;
|
||||
tree.setWindowTitle(QTest::currentTestFunction());
|
||||
|
||||
if (fileDialogMode && EmulationDetector::isRunningArmOnX86())
|
||||
if (fileDialogMode && QTestPrivate::isRunningArmOnX86())
|
||||
QSKIP("Crashes in QEMU. QTBUG-70572");
|
||||
|
||||
#ifdef QT_BUILD_INTERNAL
|
||||
|
@ -11,8 +11,7 @@ qt_internal_add_test(tst_qfont
|
||||
Qt::CorePrivate
|
||||
Qt::Gui
|
||||
Qt::GuiPrivate
|
||||
INCLUDE_DIRECTORIES
|
||||
../../../../shared
|
||||
Qt::TestPrivate
|
||||
)
|
||||
|
||||
# Resources:
|
||||
|
@ -41,7 +41,7 @@
|
||||
#include <qwidget.h>
|
||||
#endif
|
||||
#include <qlist.h>
|
||||
#include "emulationdetector.h"
|
||||
#include <QtTest/private/qemulationdetector_p.h>
|
||||
|
||||
class tst_QFont : public QObject
|
||||
{
|
||||
@ -578,7 +578,7 @@ void tst_QFont::defaultFamily()
|
||||
}
|
||||
}
|
||||
#ifdef Q_PROCESSOR_ARM_32
|
||||
if (EmulationDetector::isRunningArmOnX86())
|
||||
if (QTestPrivate::isRunningArmOnX86())
|
||||
QEXPECT_FAIL("", "Fails on ARMv7 QEMU (QTQAINFRA-4127)", Continue);
|
||||
#endif
|
||||
|
||||
|
@ -6,15 +6,13 @@
|
||||
|
||||
qt_internal_add_test(tst_http2
|
||||
SOURCES
|
||||
../../../../shared/emulationdetector.h
|
||||
http2srv.cpp http2srv.h
|
||||
tst_http2.cpp
|
||||
DEFINES
|
||||
SRCDIR=\\\"${CMAKE_CURRENT_SOURCE_DIR}/\\\"
|
||||
INCLUDE_DIRECTORIES
|
||||
../../../../shared
|
||||
PUBLIC_LIBRARIES
|
||||
Qt::CorePrivate
|
||||
Qt::Network
|
||||
Qt::NetworkPrivate
|
||||
Qt::TestPrivate
|
||||
)
|
||||
|
@ -55,7 +55,7 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "emulationdetector.h"
|
||||
#include <QtTest/private/qemulationdetector_p.h>
|
||||
|
||||
#if (!defined(QT_NO_OPENSSL) && OPENSSL_VERSION_NUMBER >= 0x10002000L && !defined(OPENSSL_NO_TLSEXT)) \
|
||||
|| QT_CONFIG(schannel)
|
||||
@ -379,7 +379,7 @@ void tst_Http2::flowControlServerSide()
|
||||
// to let all replies finish without any error.
|
||||
using namespace Http2;
|
||||
|
||||
if (EmulationDetector::isRunningArmOnX86())
|
||||
if (QTestPrivate::isRunningArmOnX86())
|
||||
QSKIP("Test is too slow to run on emulator");
|
||||
|
||||
clearHTTP2State();
|
||||
|
@ -8,10 +8,9 @@ qt_internal_add_test(tst_qudpsocket
|
||||
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../" # special case
|
||||
SOURCES
|
||||
../tst_qudpsocket.cpp
|
||||
INCLUDE_DIRECTORIES
|
||||
../../../../../shared
|
||||
PUBLIC_LIBRARIES
|
||||
Qt::Network
|
||||
Qt::TestPrivate
|
||||
QT_TEST_SERVER_LIST "danted" "echo" # special case
|
||||
)
|
||||
|
||||
|
@ -52,7 +52,7 @@
|
||||
|
||||
#include <qstringlist.h>
|
||||
#include "../../../network-settings.h"
|
||||
#include "emulationdetector.h"
|
||||
#include <QtTest/private/qemulationdetector_p.h>
|
||||
|
||||
#if defined(Q_OS_LINUX)
|
||||
#define SHOULD_CHECK_SYSCALL_SUPPORT
|
||||
@ -302,7 +302,7 @@ void tst_QUdpSocket::initTestCase()
|
||||
qDebug() << "Will use multicast groups" << multicastGroup4 << multicastGroup6 << linklocalMulticastGroups;
|
||||
|
||||
m_workaroundLinuxKernelBug = shouldWorkaroundLinuxKernelBug();
|
||||
if (EmulationDetector::isRunningArmOnX86())
|
||||
if (QTestPrivate::isRunningArmOnX86())
|
||||
QSKIP("This test is unreliable due to QEMU emulation shortcomings.");
|
||||
}
|
||||
|
||||
|
@ -6,8 +6,7 @@
|
||||
|
||||
qt_internal_add_test(qobjectrace
|
||||
SOURCES
|
||||
../../../shared/emulationdetector.h
|
||||
tst_qobjectrace.cpp
|
||||
INCLUDE_DIRECTORIES
|
||||
../../../shared
|
||||
PUBLIC_LIBRARIES
|
||||
Qt::TestPrivate
|
||||
)
|
||||
|
@ -30,7 +30,7 @@
|
||||
#include <QtCore>
|
||||
#include <QTest>
|
||||
|
||||
#include "emulationdetector.h"
|
||||
#include <QtTest/private/qemulationdetector_p.h>
|
||||
|
||||
enum { OneMinute = 60 * 1000,
|
||||
TwoMinutes = OneMinute * 2 };
|
||||
@ -260,7 +260,7 @@ public:
|
||||
|
||||
void tst_QObjectRace::destroyRace()
|
||||
{
|
||||
if (EmulationDetector::isRunningArmOnX86())
|
||||
if (QTestPrivate::isRunningArmOnX86())
|
||||
QSKIP("Test is too slow to run on emulator");
|
||||
|
||||
enum { ThreadCount = 10, ObjectCountPerThread = 2777,
|
||||
|
@ -10,11 +10,8 @@ qt_internal_add_test(tst_selftests
|
||||
EXCEPTIONS
|
||||
CATCH
|
||||
SOURCES
|
||||
../../../shared/emulationdetector.h
|
||||
tst_selftests.cpp
|
||||
catch.cpp
|
||||
INCLUDE_DIRECTORIES
|
||||
../../../shared
|
||||
PUBLIC_LIBRARIES
|
||||
Qt::TestPrivate
|
||||
# special case begin
|
||||
|
@ -8,12 +8,10 @@ qt_internal_add_executable(float
|
||||
NO_INSTALL # special case
|
||||
OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} # special case
|
||||
SOURCES
|
||||
../../../../shared/emulationdetector.h
|
||||
tst_float.cpp
|
||||
INCLUDE_DIRECTORIES
|
||||
../../../../shared
|
||||
PUBLIC_LIBRARIES
|
||||
Qt::Test
|
||||
Qt::TestPrivate
|
||||
)
|
||||
|
||||
## Scopes:
|
||||
|
@ -31,7 +31,7 @@
|
||||
#include <QTest>
|
||||
#include <QDebug>
|
||||
|
||||
#include "emulationdetector.h"
|
||||
#include <QtTest/private/qemulationdetector_p.h>
|
||||
|
||||
// Test proper handling of floating-point types
|
||||
class tst_float: public QObject
|
||||
@ -182,7 +182,7 @@ void tst_float::float16Comparisons_data() const
|
||||
QTest::addColumn<qfloat16>("operandLeft");
|
||||
QTest::addColumn<qfloat16>("operandRight");
|
||||
const qfloat16 zero(0), one(1);
|
||||
const qfloat16 tiny(EmulationDetector::isRunningArmOnX86() ? 0.00099f : 0.001f);
|
||||
const qfloat16 tiny(QTestPrivate::isRunningArmOnX86() ? 0.00099f : 0.001f);
|
||||
|
||||
QTest::newRow("should FAIL 1") << one << qfloat16(3);
|
||||
QTest::newRow("should PASS 1") << zero << zero;
|
||||
|
@ -48,7 +48,7 @@
|
||||
|
||||
#include <private/cycle_p.h>
|
||||
|
||||
#include "emulationdetector.h"
|
||||
#include <QtTest/private/qemulationdetector_p.h>
|
||||
|
||||
struct BenchmarkResult
|
||||
{
|
||||
@ -345,7 +345,7 @@ bool compareLine(const QString &logger, const QString &subdir,
|
||||
return true;
|
||||
}
|
||||
|
||||
if (EmulationDetector::isRunningArmOnX86() && subdir == QLatin1String("float")) {
|
||||
if (QTestPrivate::isRunningArmOnX86() && subdir == QLatin1String("float")) {
|
||||
// QEMU cheats at qfloat16, so outputs it as if it were a float.
|
||||
if (actualLine.endsWith(QLatin1String("Actual (operandLeft) : 0.001"))
|
||||
&& expectedLine.endsWith(QLatin1String("Actual (operandLeft) : 0.000999"))) {
|
||||
@ -787,7 +787,7 @@ void checkErrorOutput(const QString &test, const QByteArray &errorOutput)
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
// QEMU outputs to stderr about uncaught signals
|
||||
if (EmulationDetector::isRunningArmOnX86() &&
|
||||
if (QTestPrivate::isRunningArmOnX86() &&
|
||||
(test == "assert"
|
||||
|| test == "blacklisted"
|
||||
|| test == "crashes"
|
||||
|
Loading…
x
Reference in New Issue
Block a user