tst_QFile: extend virtualFile() to find QtCore and QtTest

In non-static builds, of course.

Change-Id: Ifbf974a4d10745b099b1fffd1777ac97c0921759
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
Thiago Macieira 2023-08-02 13:59:12 -07:00
parent b956fec7ee
commit 3a49d7d4e5

View File

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