From d2e2721815a38db704ce66c662a54b77da147484 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Fri, 31 Oct 2014 22:09:36 +0000 Subject: Add a test that temporary and permanent refcount dbs are independent Conflicts: test/backupstore/testbackupstore.cpp --- test/backupstore/testbackupstore.cpp | 40 ++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'test') diff --git a/test/backupstore/testbackupstore.cpp b/test/backupstore/testbackupstore.cpp index 8fe76473..d17ed56f 100644 --- a/test/backupstore/testbackupstore.cpp +++ b/test/backupstore/testbackupstore.cpp @@ -781,6 +781,45 @@ int64_t create_directory(BackupProtocolCallable& protocol, int64_t create_file(BackupProtocolCallable& protocol, int64_t subdirid, const std::string& remote_filename = ""); +bool run_housekeeping_and_check_account(BackupProtocolLocal2& protocol) +{ + protocol.QueryFinished(); + bool check_account_status; + TEST_THAT(check_account_status = run_housekeeping_and_check_account()); + bool check_refcount_status; + TEST_THAT(check_refcount_status = check_reference_counts()); + protocol.Reopen(); + return check_account_status & check_refcount_status; +} + +bool test_temporary_refcount_db_is_independent() +{ + SETUP(); + + std::auto_ptr apAccounts( + BackupStoreAccountDatabase::Read("testfiles/accounts.txt")); + std::auto_ptr temp( + BackupStoreRefCountDatabase::Create( + apAccounts->GetEntry(0x1234567))); + std::auto_ptr perm( + BackupStoreRefCountDatabase::Load( + apAccounts->GetEntry(0x1234567), + false // readonly + )); + + TEST_CHECK_THROWS(temp->GetRefCount(2), + BackupStoreException, UnknownObjectRefCountRequested); + TEST_CHECK_THROWS(perm->GetRefCount(2), + BackupStoreException, UnknownObjectRefCountRequested); + temp->AddReference(2); + TEST_EQUAL(1, temp->GetRefCount(2)); + TEST_CHECK_THROWS(perm->GetRefCount(2), + BackupStoreException, UnknownObjectRefCountRequested); + temp->Discard(); + + return teardown_test_backupstore(); +} + bool test_server_housekeeping() { SETUP(); @@ -3039,6 +3078,7 @@ int test(int argc, const char *argv[]) } TEST_THAT(test_filename_encoding()); + TEST_THAT(test_temporary_refcount_db_is_independent()); TEST_THAT(test_bbstoreaccounts_create()); TEST_THAT(test_bbstoreaccounts_delete()); TEST_THAT(test_backupstore_directory()); -- cgit v1.2.3