diff --git a/tests/QTestExtensions.h b/tests/QTestExtensions.h index c43ef3f73e..ac037d831b 100644 --- a/tests/QTestExtensions.h +++ b/tests/QTestExtensions.h @@ -317,7 +317,7 @@ inline QString getTestResource(const QString& relativePath) { return QDir::cleanPath(dir.absoluteFilePath(relativePath)); } -inline bool afterUsecs(uint64_t& startUsecs, uint64_t maxIntervalUecs) { +inline bool afterUsecs(quint64& startUsecs, quint64 maxIntervalUecs) { auto now = usecTimestampNow(); auto interval = now - startUsecs; if (interval > maxIntervalUecs) { @@ -327,18 +327,18 @@ inline bool afterUsecs(uint64_t& startUsecs, uint64_t maxIntervalUecs) { return false; } -inline bool afterSecs(uint64_t& startUsecs, uint64_t maxIntervalSecs) { +inline bool afterSecs(quint64& startUsecs, quint64 maxIntervalSecs) { return afterUsecs(startUsecs, maxIntervalSecs * USECS_PER_SECOND); } template -void reportEvery(uint64_t& lastReportUsecs, uint64_t secs, F lamdba) { +void doEvery(quint64& lastReportUsecs, quint64 secs, F lamdba) { if (afterSecs(lastReportUsecs, secs)) { lamdba(); } } -inline void failAfter(uint64_t startUsecs, uint64_t secs, const char* message) { +inline void failAfter(quint64 startUsecs, quint64 secs, const char* message) { if (afterSecs(startUsecs, secs)) { QFAIL(message); } diff --git a/tests/gpu/src/TextureTest.cpp b/tests/gpu/src/TextureTest.cpp index 65d0933302..18361af791 100644 --- a/tests/gpu/src/TextureTest.cpp +++ b/tests/gpu/src/TextureTest.cpp @@ -206,7 +206,7 @@ void TextureTest::testTextureLoading() { auto lastReport = usecTimestampNow(); auto start = usecTimestampNow(); while (expectedAllocation != allocatedMemory) { - reportEvery(lastReport, 4, reportLambda); + doEvery(lastReport, 4, reportLambda); failAfter(start, 10, "Failed to allocate texture memory after 10 seconds"); renderFrame(renderTexturesLamdba); allocatedMemory = gpu::Context::getTextureResourceGPUMemSize(); @@ -218,7 +218,7 @@ void TextureTest::testTextureLoading() { start = usecTimestampNow(); // Cycle frames we're fully populated while (allocatedMemory != populatedMemory || 0 != gpu::Context::getTexturePendingGPUTransferMemSize()) { - reportEvery(lastReport, 4, reportLambda); + doEvery(lastReport, 4, reportLambda); failAfter(start, 10, "Failed to populate texture memory after 10 seconds"); renderFrame(); allocatedMemory = gpu::Context::getTextureResourceGPUMemSize(); @@ -240,7 +240,7 @@ void TextureTest::testTextureLoading() { start = usecTimestampNow(); // Cycle frames until the allocated memory is below the max memory while (allocatedMemory > maxMemory || allocatedMemory != populatedMemory) { - reportEvery(lastReport, 4, reportLambda); + doEvery(lastReport, 4, reportLambda); failAfter(start, 10, "Failed to deallocate texture memory after 10 seconds"); renderFrame(renderTexturesLamdba); allocatedMemory = gpu::Context::getTextureResourceGPUMemSize(); @@ -259,7 +259,7 @@ void TextureTest::testTextureLoading() { gpu::Texture::setAllowedGPUMemoryUsage(0); // Cycle frames we're fully populated while (allocatedMemory != expectedAllocation || allocatedMemory != populatedMemory) { - reportEvery(lastReport, 4, reportLambda); + doEvery(lastReport, 4, reportLambda); failAfter(start, 10, "Failed to populate texture memory after 10 seconds"); renderFrame(); allocatedMemory = gpu::Context::getTextureResourceGPUMemSize(); @@ -268,4 +268,17 @@ void TextureTest::testTextureLoading() { reportLambda(); QCOMPARE(allocatedMemory, expectedAllocation); QCOMPARE(populatedMemory, allocatedMemory); + + _textures.clear(); + // Cycle frames we're fully populated + while (allocatedMemory != 0) { + failAfter(start, 10, "Failed to clear texture memory after 10 seconds"); + renderFrame(); + allocatedMemory = gpu::Context::getTextureResourceGPUMemSize(); + populatedMemory = gpu::Context::getTextureResourcePopulatedGPUMemSize(); + } + QCOMPARE(allocatedMemory, 0); + QCOMPARE(populatedMemory, 0); + qDebug() << "Done"; + }