From 172fcf113f39d79b074f0c28f30aa96329a7390a Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Thu, 18 Sep 2014 20:28:55 +0000 Subject: Whitespace fixes --- test/backupstore/testbackupstore.cpp | 212 +++++++++++++++++------------------ 1 file changed, 106 insertions(+), 106 deletions(-) diff --git a/test/backupstore/testbackupstore.cpp b/test/backupstore/testbackupstore.cpp index 481f535d..b209b5e8 100644 --- a/test/backupstore/testbackupstore.cpp +++ b/test/backupstore/testbackupstore.cpp @@ -110,7 +110,7 @@ typedef struct #define TEST_FILE_FOR_PATCHING_SIZE ((128*1024)+2564) #define UPLOAD_PATCH_EN 2 -uploadtest uploads[] = +uploadtest uploads[] = { {"0", BackupStoreFilenameClear(), 324, 455, 0, 0, false, false}, {"1", BackupStoreFilenameClear(), 3232432, 2674, 0, 0, true, false}, // old ver @@ -143,7 +143,7 @@ static const char *uploads_filenames[] = {"49587fds", "cvhjhj324", "sdfcscs324", // Nice random data for testing written files class R250 { public: - // Set up internal state table with 32-bit random numbers. + // Set up internal state table with 32-bit random numbers. // The bizarre bit-twiddling is because rand() returns 16 bits of which // the bottom bit is always zero! Hence, I use only some of the bits. // You might want to do something better than this.... @@ -160,7 +160,7 @@ public: // stir up the numbers to ensure they're random - for (int j = 0; j != stateLen * 4; ++j) + for (int j = 0; j != stateLen * 4; ++j) (void) next(); } @@ -192,7 +192,7 @@ int SkipEntries(int e, int16_t FlagsMustBeSet, int16_t FlagsNotToBeSet) do { skip = false; - + if(FlagsMustBeSet != BackupStoreDirectory::Entry::Flags_INCLUDE_EVERYTHING) { if((ens[e].flags & FlagsMustBeSet) != FlagsMustBeSet) @@ -204,20 +204,20 @@ int SkipEntries(int e, int16_t FlagsMustBeSet, int16_t FlagsNotToBeSet) { skip = true; } - + if(skip) { ++e; } } while(skip && e < DIR_NUM); - + return e; } void CheckEntries(BackupStoreDirectory &rDir, int16_t FlagsMustBeSet, int16_t FlagsNotToBeSet) { int e = 0; - + BackupStoreDirectory::Iterator i(rDir); BackupStoreDirectory::Entry *en = 0; while((en = i.Next()) != 0) @@ -231,9 +231,9 @@ void CheckEntries(BackupStoreDirectory &rDir, int16_t FlagsMustBeSet, int16_t Fl TEST_THAT(en->GetName() == ens[e].fn && en->GetModificationTime() == ens[e].mod && en->GetObjectID() == ens[e].id && en->GetFlags() == ens[e].flags && en->GetSizeInBlocks() == ens[e].size); // next - ++e; + ++e; } - + // Got them all? TEST_THAT(en == 0); TEST_THAT(DIR_NUM == SkipEntries(e, FlagsMustBeSet, FlagsNotToBeSet)); @@ -275,11 +275,11 @@ bool test_filename_encoding() BackupStoreFilenameClear fn3(fn1); TEST_THAT(fn1 == fn2); TEST_THAT(fn1 == fn3); - + // Check that it's been encrypted std::string name(fn2.GetEncodedFilename()); TEST_THAT(name.find("name") == name.npos); - + // Bung it in a stream, get it out in a Clear filename { CollectInBufferStream stream; @@ -363,7 +363,7 @@ bool test_backupstore_directory() } // Got the right number TEST_THAT(dir1.GetNumberOfEntries() == DIR_NUM); - + // Stick it into a stream and get it out again { CollectInBufferStream stream; @@ -375,7 +375,7 @@ bool test_backupstore_directory() TEST_THAT(dir2.GetContainerID() == 98); CheckEntries(dir2, BackupStoreDirectory::Entry::Flags_INCLUDE_EVERYTHING, BackupStoreDirectory::Entry::Flags_EXCLUDE_NOTHING); } - + // Then do selective writes and reads { CollectInBufferStream stream; @@ -401,7 +401,7 @@ bool test_backupstore_directory() TEST_THAT(dir2.GetNumberOfEntries() == DIR_FILES - DIR_OLD); CheckEntries(dir2, BackupStoreDirectory::Entry::Flags_File, BackupStoreDirectory::Entry::Flags_OldVersion); } - + // Finally test deleting items { dir1.DeleteEntry(12312312321LL); @@ -413,7 +413,7 @@ bool test_backupstore_directory() BackupStoreDirectory dir2(stream); TEST_THAT(dir2.GetNumberOfEntries() == DIR_FILES - 1); } - + // Check attributes { int attrI[4] = {1, 2, 3, 4}; @@ -439,18 +439,18 @@ void write_test_file(int t) std::string filename("testfiles/test"); filename += uploads[t].fnextra; BOX_TRACE("Writing " << filename); - + FileStream write(filename.c_str(), O_WRONLY | O_CREAT); - + R250 r(uploads[t].seed); - + unsigned char *data = (unsigned char*)malloc(uploads[t].size); for(int l = 0; l < uploads[t].size; ++l) { data[l] = r.next() & 0xff; } write.Write(data, uploads[t].size); - + free(data); } @@ -458,21 +458,21 @@ void test_test_file(int t, IOStream &rStream) { // Decode to a file BackupStoreFile::DecodeFile(rStream, "testfiles/test_download", SHORT_TIMEOUT); - + // Compare... FileStream in("testfiles/test_download"); TEST_THAT(in.BytesLeftToRead() == uploads[t].size); - + R250 r(uploads[t].seed); - + unsigned char *data = (unsigned char*)malloc(uploads[t].size); TEST_THAT(in.ReadFullBuffer(data, uploads[t].size, 0 /* not interested in bytes read if this fails */)); - + for(int l = 0; l < uploads[t].size; ++l) { TEST_THAT(data[l] == (r.next() & 0xff)); } - + free(data); in.Close(); TEST_THAT(unlink("testfiles/test_download") == 0); @@ -481,7 +481,7 @@ void test_test_file(int t, IOStream &rStream) void assert_everything_deleted(BackupProtocolCallable &protocol, int64_t DirID) { BOX_TRACE("Test for del: " << BOX_FORMAT_OBJECTID(DirID)); - + // Command std::auto_ptr dirreply(protocol.QueryListDirectory( DirID, @@ -509,7 +509,7 @@ void assert_everything_deleted(BackupProtocolCallable &protocol, int64_t DirID) // Check it's deleted TEST_THAT(en->IsDeleted()); } - + // Check there were the right number of files and directories TEST_THAT(files == 3); TEST_THAT(dirs == 0 || dirs == 2); @@ -554,9 +554,9 @@ int64_t create_test_data_subdirs(BackupProtocolCallable &protocol, std::auto_ptr attr(new MemBlockStream(&attrS, sizeof(attrS))); std::auto_ptr dirCreate(protocol.QueryCreateDirectory( indir, FAKE_ATTR_MODIFICATION_TIME, dirname, attr)); - subdirid = dirCreate->GetObjectID(); + subdirid = dirCreate->GetObjectID(); } - + BOX_TRACE("Creating subdirs, depth = " << depth << ", dirid = " << BOX_FORMAT_OBJECTID(subdirid)); @@ -567,7 +567,7 @@ int64_t create_test_data_subdirs(BackupProtocolCallable &protocol, } set_refcount(subdirid, 1); - + // Put more directories in it, if we haven't gone down too far if(depth > 0) { @@ -576,7 +576,7 @@ int64_t create_test_data_subdirs(BackupProtocolCallable &protocol, create_test_data_subdirs(protocol, subdirid, "dir_Two", depth - 1, pRefCount); } - + // Stick some files in it create_file_in_dir("file_One", "testfiles/test1", subdirid, protocol, pRefCount); @@ -636,7 +636,7 @@ void check_dir_after_uploads(BackupProtocolCallable &protocol, // No attributes on this one TEST_THAT(!en->HasAttributes()); } - } + } en = i.Next(); TEST_THAT(en == 0); } @@ -664,13 +664,13 @@ void recursive_count_objects_r(BackupProtocolCallable &protocol, int64_t id, BackupStoreDirectory::Iterator i(dir); // Discard first BackupStoreDirectory::Entry *en = 0; - + while((en = i.Next()) != 0) { if((en->GetFlags() & (BackupStoreDirectory::Entry::Flags_Deleted | BackupStoreDirectory::Entry::Flags_OldVersion)) == 0) results.objectsNotDel++; if(en->GetFlags() & BackupStoreDirectory::Entry::Flags_Deleted) results.deleted++; if(en->GetFlags() & BackupStoreDirectory::Entry::Flags_OldVersion) results.old++; - + if(en->GetFlags() & BackupStoreDirectory::Entry::Flags_Dir) { recursive_count_objects_r(protocol, en->GetObjectID(), results); @@ -718,11 +718,11 @@ bool check_block_index(const char *encoded_file, IOStream &rBlockIndex) break; } } - + if(rBlockIndex.StreamDataLeft()) { same = false; - + // Absorb all this excess data so procotol is in the first state char buffer[2048]; while(rBlockIndex.StreamDataLeft()) @@ -730,7 +730,7 @@ bool check_block_index(const char *encoded_file, IOStream &rBlockIndex) rBlockIndex.Read(buffer, sizeof(buffer), SHORT_TIMEOUT); } } - + return same; } @@ -759,12 +759,12 @@ bool check_files_same(const char *f1, const char *f2) break; } } - + if(f2s.StreamDataLeft()) { same = false; } - + return same; } @@ -772,7 +772,7 @@ std::auto_ptr get_raid_file(int64_t ObjectID) { std::string filename; StoreStructure::MakeObjectFilename(ObjectID, - "backup/01234567/" /* mStoreRoot */, 0 /* mStoreDiscSet */, + "backup/01234567/" /* mStoreRoot */, 0 /* mStoreDiscSet */, filename, false /* EnsureDirectoryExists */); return RaidFileRead::Open(0, filename); } @@ -805,7 +805,7 @@ bool test_server_housekeeping() BackupProtocolLocal2 protocol(0x01234567, "test", "backup/01234567/", 0, false); - + int root_dir_blocks = get_raid_file(BACKUPSTORE_ROOT_DIRECTORY_ID)->GetDiscUsageInBlocks(); TEST_THAT(check_num_files(0, 0, 0, 1)); TEST_THAT(check_num_blocks(protocol, 0, 0, 0, root_dir_blocks, @@ -893,7 +893,7 @@ bool test_server_housekeeping() in.Read(encfile_i, sizeof(encfile_i)); TEST_THAT(memcmp(encfile, encfile_i, sizeof(encfile)) == 0); } - + // Retrieve the block index, by ID { std::auto_ptr getblockindex(protocol.QueryGetBlockIndexByID(store1objid)); @@ -961,7 +961,7 @@ bool test_server_housekeeping() // It will take extra blocks, even though there are no changes, because // the server code is not smart enough to realise that the file // contents are identical, so it will create an empty patch. - + TEST_THAT(check_num_files(1, 1, 0, 1)); TEST_THAT(check_num_blocks(protocol, file1_blocks, patch1_blocks, 0, root_dir_blocks, file1_blocks + patch1_blocks + root_dir_blocks)); @@ -1235,7 +1235,7 @@ bool test_multiple_uploads() // Stream BackupStoreDirectory dir(protocolReadOnly.ReceiveStream(), protocolReadOnly.GetTimeout()); - TEST_THAT(dir.GetNumberOfEntries() == 0); + TEST_THAT(dir.GetNumberOfEntries() == 0); // TODO FIXME dedent { @@ -1256,7 +1256,7 @@ bool test_multiple_uploads() std::auto_ptr upload(BackupStoreFile::EncodeFile(filename.c_str(), BACKUPSTORE_ROOT_DIRECTORY_ID, uploads[t].name, &modtime)); TEST_THAT(modtime != 0); - + std::auto_ptr stored(apProtocol->QueryStoreFile( BACKUPSTORE_ROOT_DIRECTORY_ID, modtime, @@ -1304,7 +1304,7 @@ bool test_multiple_uploads() TEST_THAT(set->GetObjectID() == uploads[UPLOAD_ATTRS_EN].allocated_objid); TEST_THAT(check_num_files(UPLOAD_NUM - 3, 3, 0, 1)); } - + apProtocol->QueryFinished(); TEST_THAT(run_housekeeping_and_check_account()); apProtocol = connect_and_login(context); @@ -1359,7 +1359,7 @@ bool test_multiple_uploads() // And on the read/write one check_dir_after_uploads(*apProtocol, attrtest); } - + // sleep to ensure that the timestamp on the file will change ::safe_sleep(1); @@ -1409,16 +1409,16 @@ bool test_multiple_uploads() BACKUPSTORE_ROOT_DIRECTORY_ID, uploads[UPLOAD_PATCH_EN].name)); TEST_THAT(getblockindex->GetObjectID() == uploads[UPLOAD_PATCH_EN].allocated_objid); std::auto_ptr blockIndexStream(apProtocol->ReceiveStream()); - + // Do the patching bool isCompletelyDifferent = false; int64_t modtime; std::auto_ptr patchstream( BackupStoreFile::EncodeFileDiff( - TEST_FILE_FOR_PATCHING ".mod", + TEST_FILE_FOR_PATCHING ".mod", BACKUPSTORE_ROOT_DIRECTORY_ID, - uploads[UPLOAD_PATCH_EN].name, - uploads[UPLOAD_PATCH_EN].allocated_objid, + uploads[UPLOAD_PATCH_EN].name, + uploads[UPLOAD_PATCH_EN].allocated_objid, *blockIndexStream, SHORT_TIMEOUT, NULL, // pointer to DiffTimer impl @@ -1619,7 +1619,7 @@ bool test_server_commands() StreamableMemBlock attrtest(attr2, sizeof(attr2)); TEST_THAT(dir.GetAttributes() == attrtest); } - + BackupStoreFilenameClear& oldName(uploads[0].name); int64_t root_file_id = create_file(*apProtocol, BACKUPSTORE_ROOT_DIRECTORY_ID); TEST_THAT(check_num_files(2, 0, 0, 2)); @@ -1785,26 +1785,26 @@ bool test_server_commands() // Query names -- test that invalid stuff returns not found OK { std::auto_ptr nameRep(apProtocol->QueryGetObjectName(3248972347823478927LL, subsubdirid)); - TEST_THAT(nameRep->GetNumNameElements() == 0); + TEST_THAT(nameRep->GetNumNameElements() == 0); } { std::auto_ptr nameRep(apProtocol->QueryGetObjectName(subsubfileid, 2342378424LL)); - TEST_THAT(nameRep->GetNumNameElements() == 0); + TEST_THAT(nameRep->GetNumNameElements() == 0); } { std::auto_ptr nameRep(apProtocol->QueryGetObjectName(38947234789LL, 2342378424LL)); - TEST_THAT(nameRep->GetNumNameElements() == 0); + TEST_THAT(nameRep->GetNumNameElements() == 0); } { std::auto_ptr nameRep(apProtocol->QueryGetObjectName(BackupProtocolGetObjectName::ObjectID_DirectoryOnly, 2234342378424LL)); - TEST_THAT(nameRep->GetNumNameElements() == 0); + TEST_THAT(nameRep->GetNumNameElements() == 0); } // Query names... first, get info for the file { std::auto_ptr nameRep(apProtocol->QueryGetObjectName(subsubfileid, subsubdirid)); std::auto_ptr namestream(apProtocol->ReceiveStream()); - + TEST_THAT(nameRep->GetNumNameElements() == 3); TEST_THAT(nameRep->GetFlags() == BackupProtocolListDirectory::Flags_File); TEST_THAT(nameRep->GetModificationTime() == 0x123456789abcdefLL); @@ -1822,7 +1822,7 @@ bool test_server_commands() { std::auto_ptr nameRep(apProtocol->QueryGetObjectName(BackupProtocolGetObjectName::ObjectID_DirectoryOnly, subsubdirid)); std::auto_ptr namestream(apProtocol->ReceiveStream()); - + TEST_THAT(nameRep->GetNumNameElements() == 2); TEST_THAT(nameRep->GetFlags() == BackupProtocolListDirectory::Flags_Dir); static const char *testnames[] = {"sub2","lovely_directory"}; @@ -1833,7 +1833,7 @@ bool test_server_commands() TEST_THAT(fn.GetClearFilename() == testnames[l]); } } - + //} skip: std::auto_ptr apAccounts( @@ -1850,7 +1850,7 @@ bool test_server_commands() BACKUPSTORE_ROOT_DIRECTORY_ID, "test_delete", 6 /* depth */, apRefCount.get()); TEST_THAT(check_reference_counts()); - + apProtocol->QueryFinished(); TEST_THAT(run_housekeeping_and_check_account()); TEST_THAT(check_reference_counts()); @@ -1878,10 +1878,10 @@ bool test_server_commands() // Stream BackupStoreDirectory dir(protocolReadOnly.ReceiveStream(), SHORT_TIMEOUT); - + // Check there's only that one entry TEST_THAT(dir.GetNumberOfEntries() == 1); - + BackupStoreDirectory::Iterator i(dir); BackupStoreDirectory::Entry *en = i.Next(); TEST_THAT(en != 0); @@ -1891,7 +1891,7 @@ bool test_server_commands() BackupStoreFilenameClear n("test_delete"); TEST_THAT(en->GetName() == n); } - + // Then... check everything's deleted assert_everything_deleted(protocolReadOnly, dirtodelete); } @@ -2163,14 +2163,14 @@ bool test_encoding() TEST_THAT(encBlockSize > SMALL_BLOCK_SIZE); BackupStoreFile::EncodingBuffer encoded; encoded.Allocate(encBlockSize / 8); // make sure reallocation happens - + // Encode! int encSize = BackupStoreFile::EncodeChunk(encfile, SMALL_BLOCK_SIZE, encoded); // Check the header says it's not been compressed TEST_THAT((encoded.mpBuffer[0] & 1) == 0); // Check the output size has been inflated (no compression) TEST_THAT(encSize > SMALL_BLOCK_SIZE); - + // Decode it int decBlockSize = BackupStoreFile::OutputBufferSizeForKnownOutputSize(SMALL_BLOCK_SIZE); TEST_THAT(decBlockSize > SMALL_BLOCK_SIZE); @@ -2178,10 +2178,10 @@ bool test_encoding() int decSize = BackupStoreFile::DecodeChunk(encoded.mpBuffer, encSize, decoded, decBlockSize); TEST_THAT(decSize < decBlockSize); TEST_THAT(decSize == SMALL_BLOCK_SIZE); - + // Check it came out of the wash the same TEST_THAT(::memcmp(encfile, decoded, SMALL_BLOCK_SIZE) == 0); - + free(decoded); } @@ -2191,14 +2191,14 @@ bool test_encoding() TEST_THAT(encBlockSize > ENCFILE_SIZE); BackupStoreFile::EncodingBuffer encoded; encoded.Allocate(encBlockSize / 8); // make sure reallocation happens - + // Encode! int encSize = BackupStoreFile::EncodeChunk(encfile, ENCFILE_SIZE, encoded); // Check the header says it's compressed TEST_THAT((encoded.mpBuffer[0] & 1) == 1); // Check the output size make it likely that it's compressed (is very compressible data) TEST_THAT(encSize < ENCFILE_SIZE); - + // Decode it int decBlockSize = BackupStoreFile::OutputBufferSizeForKnownOutputSize(ENCFILE_SIZE); TEST_THAT(decBlockSize > ENCFILE_SIZE); @@ -2209,16 +2209,16 @@ bool test_encoding() // Check it came out of the wash the same TEST_THAT(::memcmp(encfile, decoded, ENCFILE_SIZE) == 0); - + free(decoded); } - + // The test block to a file { FileStream f("testfiles/testenc1", O_WRONLY | O_CREAT); f.Write(encfile, sizeof(encfile)); } - + // Encode it { FileStream out("testfiles/testenc1_enc", O_WRONLY | O_CREAT); @@ -2227,20 +2227,20 @@ bool test_encoding() std::auto_ptr encoded(BackupStoreFile::EncodeFile("testfiles/testenc1", 32, name)); encoded->CopyStreamTo(out); } - + // Verify it { FileStream enc("testfiles/testenc1_enc"); TEST_THAT(BackupStoreFile::VerifyEncodedFileFormat(enc) == true); } - + // Decode it { UNLINK_IF_EXISTS("testfiles/testenc1_orig"); FileStream enc("testfiles/testenc1_enc"); BackupStoreFile::DecodeFile(enc, "testfiles/testenc1_orig", IOStream::TimeOutInfinite); } - + // Read in rebuilt original, and compare contents { TEST_THAT(TestGetFileSize("testfiles/testenc1_orig") == sizeof(encfile)); @@ -2249,7 +2249,7 @@ bool test_encoding() in.Read(encfile_i, sizeof(encfile_i)); TEST_THAT(memcmp(encfile, encfile_i, sizeof(encfile)) == 0); } - + // Check how many blocks it had, and test the stream based interface { FileStream enc("testfiles/testenc1_enc"); @@ -2262,7 +2262,7 @@ bool test_encoding() TEST_THAT(decoded->GetNumBlocks() == 3); } - + // Test that the last block in a file, if less than 256 bytes, gets put into the last block { #define FILE_SIZE_JUST_OVER ((4096*2)+58) @@ -2278,11 +2278,11 @@ bool test_encoding() decoded->CopyStreamTo(d, IOStream::TimeOutInfinite, 879 /* buffer block size */); d.SetForReading(); TEST_THAT(d.GetSize() == FILE_SIZE_JUST_OVER); - TEST_THAT(memcmp(encfile + 2, d.GetBuffer(), FILE_SIZE_JUST_OVER) == 0); + TEST_THAT(memcmp(encfile + 2, d.GetBuffer(), FILE_SIZE_JUST_OVER) == 0); TEST_THAT(decoded->GetNumBlocks() == 2); } - + // Test that reordered streams work too { FileStream enc("testfiles/testenc1_enc"); @@ -2315,7 +2315,7 @@ bool test_symlinks() BackupStoreFilenameClear name("testsymlink"); std::auto_ptr encoded(BackupStoreFile::EncodeFile("testfiles/testsymlink", 32, name)); - // Can't decode it from the stream, because it's in file order, and doesn't have the + // Can't decode it from the stream, because it's in file order, and doesn't have the // required properties to be able to reorder it. So buffer it... CollectInBufferStream b; encoded->CopyStreamTo(b); @@ -2325,7 +2325,7 @@ bool test_symlinks() UNLINK_IF_EXISTS("testfiles/testsymlink_2"); BackupStoreFile::DecodeFile(b, "testfiles/testsymlink_2", IOStream::TimeOutInfinite); } - teardown_test_backupstore(); + teardown_test_backupstore(); #endif return true; @@ -2405,7 +2405,7 @@ bool test_login_without_account() // Login TEST_CHECK_THROWS(std::auto_ptr loginConf(protocol.QueryLogin(0x01234567, 0)), ConnectionException, Protocol_UnexpectedReply); - + // Finish the connection protocol.QueryFinished(); } @@ -2444,7 +2444,7 @@ bool test_bbstoreaccounts_delete() return teardown_test_backupstore(); } -// Test that login fails on a disabled account +// Test that login fails on a disabled account bool test_login_with_disabled_account() { SETUP(); @@ -2466,8 +2466,8 @@ bool test_login_with_disabled_account() apReferences->GetLastObjectIDUsed()); TEST_EQUAL(1, apReferences->GetRefCount(BACKUPSTORE_ROOT_DIRECTORY_ID)) apReferences.reset(); - - // Test that login fails on a disabled account + + // Test that login fails on a disabled account TEST_THAT_OR(::system(BBSTOREACCOUNTS " -c testfiles/bbstored.conf enabled 01234567 no") == 0, FAIL); TestRemoteProcessMemLeaks("bbstoreaccounts.memleaks"); @@ -2610,7 +2610,7 @@ bool test_account_limits_respected() TEST_THAT_OR(StartServer(), FAIL); // Set a really small hard limit - TEST_THAT_OR(::system(BBSTOREACCOUNTS + TEST_THAT_OR(::system(BBSTOREACCOUNTS " -c testfiles/bbstored.conf setlimit 01234567 " "2B 2B") == 0, FAIL); TestRemoteProcessMemLeaks("bbstoreaccounts.memleaks"); @@ -2657,14 +2657,14 @@ int multi_server() printf("Starting server for connection from remote machines...\n"); // Create an account for the test client - TEST_THAT_OR(::system(BBSTOREACCOUNTS + TEST_THAT_OR(::system(BBSTOREACCOUNTS " -c testfiles/bbstored.conf create 01234567 0 " "30000B 40000B") == 0, FAIL); TestRemoteProcessMemLeaks("bbstoreaccounts.memleaks"); // First, try logging in without an account having been created... just make sure login fails. - int pid = LaunchServer(BBSTORED " testfiles/bbstored_multi.conf", + int pid = LaunchServer(BBSTORED " testfiles/bbstored_multi.conf", "testfiles/bbstored.pid"); TEST_THAT(pid != -1 && pid != 0); @@ -2692,7 +2692,7 @@ bool test_open_files_with_limited_win32_permissions() // this had better work, or bbstored will die when combining diffs char* file = "foo"; - DWORD accessRights = FILE_READ_ATTRIBUTES | + DWORD accessRights = FILE_READ_ATTRIBUTES | FILE_LIST_DIRECTORY | FILE_READ_EA | FILE_WRITE_ATTRIBUTES | FILE_WRITE_DATA | FILE_WRITE_EA /*| FILE_ALL_ACCESS*/; DWORD shareMode = FILE_SHARE_READ | FILE_SHARE_WRITE; @@ -2702,7 +2702,7 @@ bool test_open_files_with_limited_win32_permissions() assert(h1 != INVALID_HANDLE_VALUE); TEST_THAT(h1 != INVALID_HANDLE_VALUE); - accessRights = FILE_READ_ATTRIBUTES | + accessRights = FILE_READ_ATTRIBUTES | FILE_LIST_DIRECTORY | FILE_READ_EA; HANDLE h2 = CreateFileA(file, accessRights, shareMode, @@ -2781,7 +2781,7 @@ void compare_backupstoreinfo_values_to_expected TEST_EQUAL_LINE(expected_account_enabled, actual.IsAccountEnabled(), test_phase << " AccountEnabled"); - TEST_EQUAL_LINE(extra_data.GetSize(), actual.GetExtraData().GetSize(), + TEST_EQUAL_LINE(extra_data.GetSize(), actual.GetExtraData().GetSize(), test_phase << " extra data has wrong size"); TEST_EQUAL_LINE(0, memcmp(extra_data.GetBuffer(), actual.GetExtraData().GetBuffer(), extra_data.GetSize()), @@ -2825,7 +2825,7 @@ bool test_read_old_backupstoreinfo_files() apArchive->Write((int64_t) 14); rfw->Commit(/* ConvertToRaidNow */ true); rfw.reset(); - + apInfo = BackupStoreInfo::Load(0x1234567, "backup/01234567/", 0, /* ReadOnly */ false); compare_backupstoreinfo_values_to_expected("loaded from v1", info_v1, @@ -2833,10 +2833,10 @@ bool test_read_old_backupstoreinfo_files() true /* enabled by default */); apInfo->SetAccountName("bonk"); - + // Save the info again apInfo->Save(/* allowOverwrite */ true); - + // Check that it was saved in the new Archive format std::auto_ptr rfr(RaidFileRead::Open(0, info_filename, 0)); int32_t magic; @@ -2855,7 +2855,7 @@ bool test_read_old_backupstoreinfo_files() /* ReadOnly */ false); compare_backupstoreinfo_values_to_expected("loaded in v1, resaved in v2", info_v1, *apInfo, "bonk", true); - + // Check that the new AccountEnabled flag is saved properly apInfo->SetAccountEnabled(false); apInfo->Save(/* allowOverwrite */ true); @@ -2874,7 +2874,7 @@ bool test_read_old_backupstoreinfo_files() // Now save the info in v2 format without the AccountEnabled flag // (boxbackup 0.11 format) and check that the flag is set to true // for backwards compatibility - + rfw.reset(new RaidFileWrite(0, info_filename)); rfw->Open(/* allowOverwrite */ true); magic = htonl(INFO_MAGIC_VALUE_2); @@ -2900,7 +2900,7 @@ bool test_read_old_backupstoreinfo_files() apArchive->Write(apInfo->GetDeletedDirectories()[1]); rfw->Commit(/* ConvertToRaidNow */ true); rfw.reset(); - + apInfo = BackupStoreInfo::Load(0x1234567, "backup/01234567/", 0, /* ReadOnly */ false); compare_backupstoreinfo_values_to_expected("saved in v2 without " @@ -2910,7 +2910,7 @@ bool test_read_old_backupstoreinfo_files() // Rewrite using full length, so that the first 4 bytes of extra data // doesn't get swallowed by "extra data". apInfo->Save(/* allowOverwrite */ true); - + // Append some extra data after the known account values, to simulate a // new addition to the store format. Check that this extra data is loaded // and resaved with the info file. We made the mistake of deleting it in @@ -2930,7 +2930,7 @@ bool test_read_old_backupstoreinfo_files() rfw.reset(); apInfo = BackupStoreInfo::Load(0x1234567, "backup/01234567/", 0, /* ReadOnly */ false); - TEST_EQUAL_LINE(extra_data.GetSize(), apInfo->GetExtraData().GetSize(), + TEST_EQUAL_LINE(extra_data.GetSize(), apInfo->GetExtraData().GetSize(), "wrong amount of extra data loaded from info file"); TEST_EQUAL_LINE(0, memcmp(extra_data.GetBuffer(), apInfo->GetExtraData().GetBuffer(), extra_data.GetSize()), @@ -2940,7 +2940,7 @@ bool test_read_old_backupstoreinfo_files() apInfo = BackupStoreInfo::Load(0x1234567, "backup/01234567/", 0, true); compare_backupstoreinfo_values_to_expected("saved in future format " "with extra_data", info_v1, *apInfo, "test", true, extra_data); - + // Check that the new bbstoreaccounts command sets the flag properly TEST_THAT_OR(::system(BBSTOREACCOUNTS " -c testfiles/bbstored.conf enabled 01234567 no") == 0, FAIL); @@ -3002,17 +3002,17 @@ int test(int argc, const char *argv[]) // Initialise the raid file controller RaidFileController &rcontroller = RaidFileController::GetController(); rcontroller.Initialise("testfiles/raidfile.conf"); - + TEST_THAT(test_read_old_backupstoreinfo_files()); - + // SSL library SSLLib::Initialise(); - + // Use the setup crypto command to set up all these keys, so that the bbackupquery command can be used // for seeing what's going on. - BackupClientCryptoKeys_Setup("testfiles/bbackupd.keys"); - - // encode in some filenames -- can't do static initialisation + BackupClientCryptoKeys_Setup("testfiles/bbackupd.keys"); + + // encode in some filenames -- can't do static initialisation // because the key won't be set up when these are initialised { MEMLEAKFINDER_NO_LEAKS @@ -3026,7 +3026,7 @@ int test(int argc, const char *argv[]) uploads[l].name = BackupStoreFilenameClear(uploads_filenames[l]); } } - + // Trace errors out SET_DEBUG_SSLLIB_TRACE_ERRORS -- cgit v1.2.3