From 34aede1c187c06ad94076bb7947f879bae2889ce Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Sun, 16 Nov 2014 23:12:22 +0000 Subject: Fix test failures caused by reference count database changes. --- lib/backupstore/StoreTestUtils.cpp | 11 +++++++++++ test/backupstore/testbackupstore.cpp | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/backupstore/StoreTestUtils.cpp b/lib/backupstore/StoreTestUtils.cpp index 48b6370c..44bdb9c1 100644 --- a/lib/backupstore/StoreTestUtils.cpp +++ b/lib/backupstore/StoreTestUtils.cpp @@ -151,6 +151,17 @@ void set_refcount(int64_t ObjectID, uint32_t RefCount) ExpectedRefCounts.resize(ObjectID + 1, 0); } ExpectedRefCounts[ObjectID] = RefCount; + for (size_t i = ExpectedRefCounts.size() - 1; i >= 1; i--) + { + if (ExpectedRefCounts[i] == 0) + { + // BackupStoreCheck and housekeeping will both + // regenerate the refcount DB without any missing + // items at the end, so we need to prune ourselves + // of all items with no references to match. + ExpectedRefCounts.resize(i); + } + } } void init_context(TLSContext& rContext) diff --git a/test/backupstore/testbackupstore.cpp b/test/backupstore/testbackupstore.cpp index f1ff3223..2e8f9f37 100644 --- a/test/backupstore/testbackupstore.cpp +++ b/test/backupstore/testbackupstore.cpp @@ -2024,6 +2024,7 @@ bool test_directory_parent_entry_tracks_directory_size() // Now delete an entry, and check that the size is reduced protocol.QueryDeleteFile(subdirid, BackupStoreFilenameClear(last_added_filename)); + ExpectedRefCounts[last_added_file_id] = 0; // Reduce the limits, to remove it permanently from the store protocol.QueryFinished(); @@ -2094,13 +2095,13 @@ bool test_directory_parent_entry_tracks_directory_size() // Delete it again, which should reduce the object size again protocol.QueryDeleteDirectory(dir2id); + set_refcount(dir2id, 0); // Reduce the limits, to remove it permanently from the store protocol.QueryFinished(); protocolReadOnly.QueryFinished(); TEST_THAT(change_account_limits("0B", "20000B")); TEST_THAT(run_housekeeping_and_check_account()); - set_refcount(dir2id, 0); protocol.Reopen(); protocolReadOnly.Reopen(); -- cgit v1.2.3