diff options
author | Ali Akhtarzada <ali.akhtarzada@nokia.com> | 2012-05-11 10:13:21 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-05-14 12:50:18 +0200 |
commit | de1af8de8c95105547da0235282f77f04907644b (patch) | |
tree | 201709867acd9a3063d06731cf46c122fe7cf762 | |
parent | 85a12894a9319c951afdbf95c170a63d15f8969c (diff) |
Wrap forceCommitFail in test lib ifdef for hbtree tests
Don't want this to be defined when not executing within the QTest
framework
Change-Id: Ic80fb6c805a8f7a2c168bfcb5c201e430354afee
Reviewed-by: Prasanth Ullattil <prasanth.ullattil@nokia.com>
-rw-r--r-- | src/hbtree/hbtree.cpp | 15 | ||||
-rw-r--r-- | src/hbtree/hbtree_p.h | 2 |
2 files changed, 15 insertions, 2 deletions
diff --git a/src/hbtree/hbtree.cpp b/src/hbtree/hbtree.cpp index 3d86392..4b513ac 100644 --- a/src/hbtree/hbtree.cpp +++ b/src/hbtree/hbtree.cpp @@ -96,7 +96,10 @@ HBtreePrivate::HBtreePrivate(HBtree *q, const QString &name) : q_ptr(q), fileName_(name), fd_(-1), openMode_(HBtree::ReadOnly), size_(0), lastSyncedId_(0), cacheSize_(20), compareFunction_(0), writeTransaction_(0), readTransaction_(0), lastPage_(PageInfo::INVALID_PAGE), cursorDisrupted_(false), - forceCommitFail_(0), lastWriteError_(0), lastReadError_(0) +#ifdef QT_TESTLIB_LIB + forceCommitFail_(0), +#endif + lastWriteError_(0), lastReadError_(0) { } @@ -908,11 +911,19 @@ bool HBtreePrivate::commit(HBtreeTransaction *transaction, quint64 tag) quint32 sizeBefore = lseek(fd_, 0, SEEK_END); PageMap::iterator it = dirtyPages_.begin(); +#ifdef QT_TESTLIB_LIB int numCommited = 0; +#endif while (it != dirtyPages_.constEnd()) { HBTREE_ASSERT(verifyIntegrity(it.value()))(*it.value()); pageBuffer_ = serializePage(*it.value()); - if ((forceCommitFail_ && numCommited++ >= forceCommitFail_) || !writePage(&pageBuffer_)) { + bool ok = true; +#ifdef QT_TESTLIB_LIB + ok = !(forceCommitFail_ && numCommited++ >= forceCommitFail_); + if (ok) +#endif + ok = writePage(&pageBuffer_); + if (!ok) { HBTREE_DEBUG("failed to commit page" << *it.value()); if (lseek(fd_, 0, SEEK_END) != sizeBefore) { HBTREE_DEBUG("size increased to" << lseek(fd_, 0, SEEK_END) << "- truncating to" << sizeBefore); diff --git a/src/hbtree/hbtree_p.h b/src/hbtree/hbtree_p.h index 0686409..5917335 100644 --- a/src/hbtree/hbtree_p.h +++ b/src/hbtree/hbtree_p.h @@ -399,7 +399,9 @@ public: bool cursorDisrupted_; mutable QByteArray pageBuffer_; bool verifyIntegrity(const Page *pPage) const; +#ifdef QT_TESTLIB_LIB int forceCommitFail_; +#endif mutable int lastWriteError_; int lastReadError_; }; |