aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2021-11-17 15:15:41 +0100
committerUlf Hermann <ulf.hermann@qt.io>2022-01-14 15:05:49 +0100
commit5ea1e17920fcb02730479e5bc5d365d6fa3b90b1 (patch)
treee4de31d9baad4d2d5f3864872b1493b7280dc2bb /tests
parent92b0e8fe7012d9d2cd24f7065ea439c9041512db (diff)
Improve tst_qmlcachegen::versionChecksForAheadOfTimeUnits()
Output the messages generated by the qt.qml.diskcache logging category while loading the original unit. This might tell us why the test occasionally fails. Also, make sure to clean up in case of a failure so that we don't cause further tests to fail. Task-number: QTBUG-98404 Change-Id: I7a6da4288721164c71bbd62d1bad0909efb35fc2 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit e9eb79425535740cd28c6890f40e96aed6968e5c)
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp23
1 files changed, 14 insertions, 9 deletions
diff --git a/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp b/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp
index 5c84c46bf8..7ffcd2411b 100644
--- a/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp
+++ b/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp
@@ -387,21 +387,33 @@ void tst_qmlcachegen::versionChecksForAheadOfTimeUnits()
Q_ASSERT(!temporaryModifiedCachedUnit);
QQmlMetaType::CachedUnitLookupError error = QQmlMetaType::CachedUnitLookupError::NoError;
+ QLoggingCategory::setFilterRules("qt.qml.diskcache.debug=true");
const QQmlPrivate::CachedQmlUnit *originalUnit = QQmlMetaType::findCachedCompilationUnit(
QUrl("qrc:/data/versionchecks.qml"), &error);
+ QLoggingCategory::setFilterRules(QString());
QVERIFY(originalUnit);
QV4::CompiledData::Unit *tweakedUnit = (QV4::CompiledData::Unit *)malloc(originalUnit->qmlData->unitSize);
memcpy(reinterpret_cast<void *>(tweakedUnit),
reinterpret_cast<const void *>(originalUnit->qmlData),
originalUnit->qmlData->unitSize);
tweakedUnit->version = QV4_DATA_STRUCTURE_VERSION - 1;
- temporaryModifiedCachedUnit = new QQmlPrivate::CachedQmlUnit{tweakedUnit, nullptr, nullptr};
- auto testHandler = [](const QUrl &url) -> const QQmlPrivate::CachedQmlUnit * {
+ const auto testHandler = [](const QUrl &url) -> const QQmlPrivate::CachedQmlUnit * {
if (url == QUrl("qrc:/data/versionchecks.qml"))
return temporaryModifiedCachedUnit;
return nullptr;
};
+
+ const auto dropModifiedUnit = qScopeGuard([&testHandler]() {
+ Q_ASSERT(temporaryModifiedCachedUnit);
+ free(const_cast<QV4::CompiledData::Unit *>(temporaryModifiedCachedUnit->qmlData));
+ delete temporaryModifiedCachedUnit;
+ temporaryModifiedCachedUnit = nullptr;
+
+ QQmlMetaType::removeCachedUnitLookupFunction(testHandler);
+ });
+
+ temporaryModifiedCachedUnit = new QQmlPrivate::CachedQmlUnit{tweakedUnit, nullptr, nullptr};
QQmlMetaType::prependCachedUnitLookupFunction(testHandler);
{
@@ -415,13 +427,6 @@ void tst_qmlcachegen::versionChecksForAheadOfTimeUnits()
CleanlyLoadingComponent component(&engine, QUrl("qrc:/data/versionchecks.qml"));
QCOMPARE(component.status(), QQmlComponent::Ready);
}
-
- Q_ASSERT(temporaryModifiedCachedUnit);
- free(const_cast<QV4::CompiledData::Unit *>(temporaryModifiedCachedUnit->qmlData));
- delete temporaryModifiedCachedUnit;
- temporaryModifiedCachedUnit = nullptr;
-
- QQmlMetaType::removeCachedUnitLookupFunction(testHandler);
}
void tst_qmlcachegen::retainedResources()