From 0ce443691fac1188103e5eaa66be40278d5d5e97 Mon Sep 17 00:00:00 2001 From: Samuli Piippo Date: Thu, 11 Feb 2021 10:51:55 +0200 Subject: 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. Pick-to: 6.1 Change-Id: I4b2321b7856414d7b1cfd5e6b1405a633c6bb878 Reviewed-by: Edward Welbourne --- tests/auto/corelib/io/largefile/CMakeLists.txt | 5 ++--- tests/auto/corelib/io/largefile/tst_largefile.cpp | 4 ++-- tests/auto/corelib/io/qfile/CMakeLists.txt | 4 +--- tests/auto/corelib/io/qfile/tst_qfile.cpp | 6 +++--- tests/auto/corelib/io/qprocess/test/CMakeLists.txt | 4 +--- tests/auto/corelib/io/qprocess/tst_qprocess.cpp | 5 ++--- tests/auto/corelib/serialization/qtextstream/test/CMakeLists.txt | 4 +--- tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp | 4 ++-- tests/auto/corelib/thread/qthread/CMakeLists.txt | 5 ++--- tests/auto/corelib/thread/qthread/tst_qthread.cpp | 4 ++-- 10 files changed, 18 insertions(+), 27 deletions(-) (limited to 'tests/auto/corelib') diff --git a/tests/auto/corelib/io/largefile/CMakeLists.txt b/tests/auto/corelib/io/largefile/CMakeLists.txt index be4b21033f..a82aa0c985 100644 --- a/tests/auto/corelib/io/largefile/CMakeLists.txt +++ b/tests/auto/corelib/io/largefile/CMakeLists.txt @@ -6,8 +6,7 @@ qt_internal_add_test(tst_largefile SOURCES - ../../../../shared/emulationdetector.h tst_largefile.cpp - INCLUDE_DIRECTORIES - ../../../../shared + PUBLIC_LIBRARIES + Qt::TestPrivate ) diff --git a/tests/auto/corelib/io/largefile/tst_largefile.cpp b/tests/auto/corelib/io/largefile/tst_largefile.cpp index 98bb985c02..fcc0a31763 100644 --- a/tests/auto/corelib/io/largefile/tst_largefile.cpp +++ b/tests/auto/corelib/io/largefile/tst_largefile.cpp @@ -48,7 +48,7 @@ # endif #endif // Q_OS_WIN -#include "emulationdetector.h" +#include 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); } diff --git a/tests/auto/corelib/io/qfile/CMakeLists.txt b/tests/auto/corelib/io/qfile/CMakeLists.txt index 7a0102bfd9..4d9a0d2598 100644 --- a/tests/auto/corelib/io/qfile/CMakeLists.txt +++ b/tests/auto/corelib/io/qfile/CMakeLists.txt @@ -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} ) diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp index 2019afaf66..bdfcc2d350 100644 --- a/tests/auto/corelib/io/qfile/tst_qfile.cpp +++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp @@ -46,7 +46,7 @@ #include #include -#include "emulationdetector.h" +#include #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()); diff --git a/tests/auto/corelib/io/qprocess/test/CMakeLists.txt b/tests/auto/corelib/io/qprocess/test/CMakeLists.txt index 249cb089cf..75cddf41a8 100644 --- a/tests/auto/corelib/io/qprocess/test/CMakeLists.txt +++ b/tests/auto/corelib/io/qprocess/test/CMakeLists.txt @@ -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:: diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp index b6ba4e546c..41172a10dd 100644 --- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp +++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp @@ -27,11 +27,10 @@ ** ****************************************************************************/ -#include - #include #include #include +#include #include #include @@ -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 diff --git a/tests/auto/corelib/serialization/qtextstream/test/CMakeLists.txt b/tests/auto/corelib/serialization/qtextstream/test/CMakeLists.txt index 61d594900f..c90a6f12c5 100644 --- a/tests/auto/corelib/serialization/qtextstream/test/CMakeLists.txt +++ b/tests/auto/corelib/serialization/qtextstream/test/CMakeLists.txt @@ -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} ) diff --git a/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp b/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp index 3ab095827f..c02da8efe1 100644 --- a/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp +++ b/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp @@ -45,7 +45,7 @@ # include #endif #include "../../../network-settings.h" -#include "emulationdetector.h" +#include QT_BEGIN_NAMESPACE template<> struct QMetaTypeId @@ -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"); { diff --git a/tests/auto/corelib/thread/qthread/CMakeLists.txt b/tests/auto/corelib/thread/qthread/CMakeLists.txt index b3662f31da..96c649f106 100644 --- a/tests/auto/corelib/thread/qthread/CMakeLists.txt +++ b/tests/auto/corelib/thread/qthread/CMakeLists.txt @@ -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: diff --git a/tests/auto/corelib/thread/qthread/tst_qthread.cpp b/tests/auto/corelib/thread/qthread/tst_qthread.cpp index a34129d59a..7e06e7f51f 100644 --- a/tests/auto/corelib/thread/qthread/tst_qthread.cpp +++ b/tests/auto/corelib/thread/qthread/tst_qthread.cpp @@ -55,7 +55,7 @@ #include #endif -#include "emulationdetector.h" +#include 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; -- cgit v1.2.3