From 28f490b3edb7a47aa27db5ea427d91e082a59f18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Fri, 6 Nov 2009 14:53:28 +0100 Subject: Improving reliability and information from the large file test Saw a couple of sporadic failures on Windows platforms. Debug output should help find what's happening. Once the fillFileSparsely test fails, there's no point in trying to read what we failed to write so maximum tested size is reset on a failed write. Reviewed-by: Markus Goetz --- tests/auto/qfile/largefile/tst_largefile.cpp | 35 ++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tests/auto/qfile/largefile/tst_largefile.cpp b/tests/auto/qfile/largefile/tst_largefile.cpp index 8ab3275..9105063 100644 --- a/tests/auto/qfile/largefile/tst_largefile.cpp +++ b/tests/auto/qfile/largefile/tst_largefile.cpp @@ -339,12 +339,47 @@ void tst_LargeFile::fillFileSparsely() QFETCH( QByteArray, block ); QCOMPARE( block.size(), blockSize ); + static int lastKnownGoodIndex = 0; + struct ScopeGuard { + ScopeGuard(tst_LargeFile* test) + : this_(test) + , failed(true) + { + QFETCH( int, index ); + index_ = index; + } + + ~ScopeGuard() + { + if (failed) { + this_->maxSizeBits = lastKnownGoodIndex; + QWARN( qPrintable( + QString("QFile::error %1: '%2'. Maximum size bits reset to %3.") + .arg(this_->largeFile.error()) + .arg(this_->largeFile.errorString()) + .arg(this_->maxSizeBits)) ); + } else + lastKnownGoodIndex = qMax(index_, lastKnownGoodIndex); + } + + private: + tst_LargeFile * const this_; + int index_; + + public: + bool failed; + }; + + ScopeGuard resetMaxSizeBitsOnFailure(this); + QVERIFY( largeFile.seek(position) ); QCOMPARE( largeFile.pos(), position ); QCOMPARE( largeFile.write(block), (qint64)blockSize ); QCOMPARE( largeFile.pos(), position + blockSize ); QVERIFY( largeFile.flush() ); + + resetMaxSizeBitsOnFailure.failed = false; } void tst_LargeFile::fileCreated() -- cgit v0.12