summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoão Abecasis <joao@abecasis.name>2009-11-06 13:53:28 (GMT)
committerJoão Abecasis <joao@abecasis.name>2009-11-06 18:51:11 (GMT)
commit28f490b3edb7a47aa27db5ea427d91e082a59f18 (patch)
treebd28a9beb9c593c497fb32c2f274f1b9a43f367d
parent7ee944a14582cd7202b4a8e94adc06e7ae5855a6 (diff)
downloadQt-28f490b3edb7a47aa27db5ea427d91e082a59f18.zip
Qt-28f490b3edb7a47aa27db5ea427d91e082a59f18.tar.gz
Qt-28f490b3edb7a47aa27db5ea427d91e082a59f18.tar.bz2
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
-rw-r--r--tests/auto/qfile/largefile/tst_largefile.cpp35
1 files changed, 35 insertions, 0 deletions
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<int>(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()