summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDenis Dzyubenko <denis.dzyubenko@nokia.com>2012-06-04 13:52:10 +0200
committerQt by Nokia <qt-info@nokia.com>2012-06-04 19:06:20 +0200
commitaf518f4eaa0dfbd108598a217c3b3d899d58a361 (patch)
tree9d3379626e3af1978c33a7288b7af954f0a32c96 /tests
parentb563b90d132f67eba7165cd5e930ed8437da4cde (diff)
Changed HBtree to take advisory lock on each open of the db file.
This changes btree to hold the advisory lock the whole time the btree file is kept open and accessed. The current implementation does not support concurrent access from multiple processes (or even from multiple file descriptors in the same process) - neither for writes nor for reads. Holding the lock on the file should ensure that if somehow multiple processes try to open the same database file, we don't just corrupt the db file, but gracefully fail to open it. Change-Id: Ib0c6e3aec0e087fedbfbb859758773182e74e46f Reviewed-by: Ali Akhtarzada <ali.akhtarzada@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/partition/testpartition.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/tests/auto/partition/testpartition.cpp b/tests/auto/partition/testpartition.cpp
index c3ca3ea2..7fb813c3 100644
--- a/tests/auto/partition/testpartition.cpp
+++ b/tests/auto/partition/testpartition.cpp
@@ -129,6 +129,7 @@ private slots:
void cleanup();
void reopen();
+ void openTwice();
void computeVersion();
void updateVersionOptimistic();
@@ -306,7 +307,8 @@ void TestPartition::initTestCase()
mJsonDbPartition = new JsonDbPartition(this);
mJsonDbPartition->setPartitionSpec(spec);
mJsonDbPartition->setDefaultOwner(mOwner);
- mJsonDbPartition->open();
+ if (!mJsonDbPartition->open())
+ qCritical() << "Failed to open the partition";
}
void TestPartition::cleanupTestCase()
@@ -374,6 +376,16 @@ void TestPartition::reopen()
mJsonDbPartition->open();
}
+void TestPartition::openTwice()
+{
+ JsonDbPartitionSpec spec = mJsonDbPartition->partitionSpec();
+
+ JsonDbPartition partition;
+ partition.setPartitionSpec(spec);
+ partition.setDefaultOwner(mOwner);
+ QVERIFY(!partition.open());
+}
+
void TestPartition::createContacts()
{
if (!mContactList.isEmpty())