From 3a49d7d4e5af01d1a6016e94f0b2dbb765798e19 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 2 Aug 2023 13:59:12 -0700 Subject: [PATCH] tst_QFile: extend virtualFile() to find QtCore and QtTest In non-static builds, of course. Change-Id: Ifbf974a4d10745b099b1fffd1777ac97c0921759 Reviewed-by: Ahmad Samir Reviewed-by: Fabian Kosmale --- tests/auto/corelib/io/qfile/tst_qfile.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp index 5fda0c04e3..794cc32053 100644 --- a/tests/auto/corelib/io/qfile/tst_qfile.cpp +++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp @@ -2685,6 +2685,28 @@ void tst_QFile::virtualFile() lines += std::move(data); } + if (!QT_CONFIG(static) && !QTestPrivate::isRunningArmOnX86()) { + // we must be able to find QtCore and QtTest somewhere + static const char corelib[] = "libQt" QT_STRINGIFY(QT_VERSION_MAJOR) "Core"; + static const char testlib[] = "libQt" QT_STRINGIFY(QT_VERSION_MAJOR) "Test"; + auto contains = [&](QByteArrayView text, quintptr ptr = 0) { + // this is not the same a QList::contains() + return std::any_of(lines.constBegin(), lines.constEnd(), [=](QByteArrayView entry) { + if (!entry.contains(text)) + return false; + if (!ptr) + return true; + qsizetype dash = entry.indexOf('-'); + qsizetype space = entry.indexOf(' ', dash); + quintptr start = entry.left(dash).toULong(nullptr, 16); + quintptr end = entry.left(space).mid(dash + 1).toULong(nullptr, 16); + return start <= ptr && ptr <= end; + }); + }; + QVERIFY(contains(corelib, quintptr(f.metaObject()))); + QVERIFY(contains(testlib)); + } + // read all: QVERIFY(f.seek(0)); data = f.readAll();