summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2014-10-31 22:09:34 +0000
committerChris Wilson <chris+github@qwirx.com>2014-10-31 22:09:34 +0000
commit6d52b312e556356030edd6ec5904faa63f5b9778 (patch)
treea51f6cd249f0c9b1e09a744c61d3e6b4a2afc210 /test
parentd95ae43d507af4f02749f1dd99500f3220253002 (diff)
Whitespace, comment and readability fixes
Diffstat (limited to 'test')
-rw-r--r--test/backupstore/testbackupstore.cpp77
-rw-r--r--test/backupstorefix/testbackupstorefix.cpp87
-rw-r--r--test/basicserver/testbasicserver.cpp12
3 files changed, 97 insertions, 79 deletions
diff --git a/test/backupstore/testbackupstore.cpp b/test/backupstore/testbackupstore.cpp
index b209b5e8..8fe76473 100644
--- a/test/backupstore/testbackupstore.cpp
+++ b/test/backupstore/testbackupstore.cpp
@@ -641,7 +641,6 @@ void check_dir_after_uploads(BackupProtocolCallable &protocol,
TEST_THAT(en == 0);
}
-
typedef struct
{
int objectsNotDel;
@@ -1159,7 +1158,7 @@ int64_t create_file(BackupProtocolCallable& protocol, int64_t subdirid,
subdirid,
modtime,
modtime, /* use for attr hash too */
- 0, /* diff from ID */
+ 0, /* diff from ID */
remote_filename_encoded,
upload));
@@ -1213,11 +1212,10 @@ bool test_multiple_uploads()
for(int l = 0; l < 3; ++l)
{
// Command
- std::auto_ptr<BackupProtocolSuccess> dirreply(
- apProtocol->QueryListDirectory(
- BACKUPSTORE_ROOT_DIRECTORY_ID,
- BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING,
- BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */));
+ apProtocol->QueryListDirectory(
+ BACKUPSTORE_ROOT_DIRECTORY_ID,
+ BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING,
+ BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */);
// Stream
BackupStoreDirectory dir(apProtocol->ReceiveStream(),
apProtocol->GetTimeout());
@@ -1226,12 +1224,11 @@ bool test_multiple_uploads()
// Read the dir from the readonly connection (make sure it gets in the cache)
// Command
- std::auto_ptr<BackupProtocolSuccess> dirreply(
- protocolReadOnly.QueryListDirectory(
- BACKUPSTORE_ROOT_DIRECTORY_ID,
- BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING,
- BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING,
- false /* no attributes */));
+ protocolReadOnly.QueryListDirectory(
+ BACKUPSTORE_ROOT_DIRECTORY_ID,
+ BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING,
+ BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING,
+ false /* no attributes */);
// Stream
BackupStoreDirectory dir(protocolReadOnly.ReceiveStream(),
protocolReadOnly.GetTimeout());
@@ -1501,11 +1498,11 @@ bool test_server_commands()
BOX_TRACE("Checking root directory using read-only connection");
{
// Command
- std::auto_ptr<BackupProtocolSuccess> dirreply(
- protocolReadOnly.QueryListDirectory(
- BACKUPSTORE_ROOT_DIRECTORY_ID,
- BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING,
- BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes! */)); // Stream
+ protocolReadOnly.QueryListDirectory(
+ BACKUPSTORE_ROOT_DIRECTORY_ID,
+ BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING,
+ BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING,
+ false /* no attributes! */); // Stream
BackupStoreDirectory dir(protocolReadOnly.ReceiveStream(),
SHORT_TIMEOUT);
@@ -1541,12 +1538,12 @@ bool test_server_commands()
BOX_TRACE("Checking subdirectory using read-only connection");
{
// Command
- std::auto_ptr<BackupProtocolSuccess> dirreply(
+ TEST_EQUAL(subdirid,
protocolReadOnly.QueryListDirectory(
subdirid,
BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING,
- BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, true /* get attributes */));
- TEST_THAT(dirreply->GetObjectID() == subdirid);
+ BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING,
+ true /* get attributes */)->GetObjectID());
BackupStoreDirectory dir(protocolReadOnly.ReceiveStream(),
SHORT_TIMEOUT);
TEST_THAT(dir.GetNumberOfEntries() == 1);
@@ -1575,10 +1572,11 @@ bool test_server_commands()
BOX_TRACE("Checking that we don't get attributes if we don't ask for them");
{
// Command
- std::auto_ptr<BackupProtocolSuccess> dirreply(protocolReadOnly.QueryListDirectory(
- subdirid,
- BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING,
- BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes! */));
+ protocolReadOnly.QueryListDirectory(
+ subdirid,
+ BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING,
+ BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING,
+ false /* no attributes! */);
// Stream
BackupStoreDirectory dir(protocolReadOnly.ReceiveStream(),
SHORT_TIMEOUT);
@@ -1604,10 +1602,11 @@ bool test_server_commands()
// Check the new attributes
{
// Command
- std::auto_ptr<BackupProtocolSuccess> dirreply(protocolReadOnly.QueryListDirectory(
- subdirid,
- 0, // no flags
- BackupProtocolListDirectory::Flags_EXCLUDE_EVERYTHING, true /* get attributes */));
+ protocolReadOnly.QueryListDirectory(
+ subdirid,
+ 0, // no flags
+ BackupProtocolListDirectory::Flags_EXCLUDE_EVERYTHING,
+ true /* get attributes */);
// Stream
BackupStoreDirectory dir(protocolReadOnly.ReceiveStream(),
SHORT_TIMEOUT);
@@ -1713,10 +1712,11 @@ bool test_server_commands()
BackupStoreFilenameClear lookFor("moved-files-x");
// Command
- std::auto_ptr<BackupProtocolSuccess> dirreply(protocolReadOnly.QueryListDirectory(
- subdirid,
- BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING,
- BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */));
+ protocolReadOnly.QueryListDirectory(
+ subdirid,
+ BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING,
+ BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING,
+ false /* no attributes */);
// Stream
BackupStoreDirectory dir(protocolReadOnly.ReceiveStream(),
@@ -1871,10 +1871,12 @@ bool test_server_commands()
// Get the root dir, checking for deleted items
{
// Command
- std::auto_ptr<BackupProtocolSuccess> dirreply(protocolReadOnly.QueryListDirectory(
- BACKUPSTORE_ROOT_DIRECTORY_ID,
- BackupProtocolListDirectory::Flags_Dir | BackupProtocolListDirectory::Flags_Deleted,
- BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */));
+ protocolReadOnly.QueryListDirectory(
+ BACKUPSTORE_ROOT_DIRECTORY_ID,
+ BackupProtocolListDirectory::Flags_Dir |
+ BackupProtocolListDirectory::Flags_Deleted,
+ BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING,
+ false /* no attributes */);
// Stream
BackupStoreDirectory dir(protocolReadOnly.ReceiveStream(),
SHORT_TIMEOUT);
@@ -2458,7 +2460,6 @@ bool test_login_with_disabled_account()
// make sure something is written to it
std::auto_ptr<BackupStoreAccountDatabase> apAccounts(
BackupStoreAccountDatabase::Read("testfiles/accounts.txt"));
-
std::auto_ptr<BackupStoreRefCountDatabase> apReferences(
BackupStoreRefCountDatabase::Load(
apAccounts->GetEntry(0x1234567), true));
diff --git a/test/backupstorefix/testbackupstorefix.cpp b/test/backupstorefix/testbackupstorefix.cpp
index 4c66b079..31cffc78 100644
--- a/test/backupstorefix/testbackupstorefix.cpp
+++ b/test/backupstorefix/testbackupstorefix.cpp
@@ -103,7 +103,7 @@ int32_t getID(const char *name)
std::map<std::string, int32_t>::iterator i(nameToID.find(std::string(name)));
TEST_THAT(i != nameToID.end());
if(i == nameToID.end()) return -1;
-
+
return i->second;
}
@@ -167,11 +167,12 @@ typedef struct
int flags;
} dir_en_check;
-void check_dir(BackupStoreDirectory &dir, dir_en_check *ck)
+bool check_dir(BackupStoreDirectory &dir, dir_en_check *ck)
{
BackupStoreDirectory::Iterator i(dir);
BackupStoreDirectory::Entry *en;
-
+ bool ok = true;
+
while((en = i.Next()) != 0)
{
BackupStoreFilenameClear clear(en->GetName());
@@ -186,9 +187,10 @@ void check_dir(BackupStoreDirectory &dir, dir_en_check *ck)
TEST_THAT(en->GetFlags() == ck->flags);
++ck;
}
-
- TEST_THAT(en == 0);
- TEST_THAT(ck->name == -1);
+
+ TEST_EQUAL_OR(en, 0, ok = false);
+ TEST_EQUAL_OR(ck->name, -1, ok = false);
+ return ok;
}
typedef struct
@@ -200,7 +202,7 @@ void check_dir_dep(BackupStoreDirectory &dir, checkdepinfoen *ck)
{
BackupStoreDirectory::Iterator i(dir);
BackupStoreDirectory::Entry *en;
-
+
while((en = i.Next()) != 0)
{
TEST_THAT(ck->id != -1);
@@ -216,7 +218,7 @@ void check_dir_dep(BackupStoreDirectory &dir, checkdepinfoen *ck)
"Wrong Older dependency for " << BOX_FORMAT_OBJECTID(ck->id));
++ck;
}
-
+
TEST_THAT(en == 0);
TEST_THAT(ck->id == -1);
}
@@ -230,19 +232,25 @@ void test_dir_fixing()
2 /* id */, 1, BackupStoreDirectory::Entry::Flags_File |
BackupStoreDirectory::Entry::Flags_OldVersion, 2);
e->SetDependsNewer(3);
-
+
TEST_THAT(dir.CheckAndFix() == true);
TEST_THAT(dir.CheckAndFix() == false);
dir_en_check ck[] = {
{-1, 0, 0}
};
-
- check_dir(dir, ck);
+
+ TEST_THAT(check_dir(dir, ck));
}
{
BackupStoreDirectory dir;
+ /*
+ Entry *AddEntry(const BackupStoreFilename &rName,
+ box_time_t ModificationTime, int64_t ObjectID,
+ int64_t SizeInBlocks, int16_t Flags,
+ uint64_t AttributesHash);
+ */
dir.AddEntry(fnames[0], 12, 2 /* id */, 1,
BackupStoreDirectory::Entry::Flags_File, 2);
dir.AddEntry(fnames[1], 12, 2 /* id */, 1,
@@ -252,14 +260,23 @@ void test_dir_fixing()
dir.AddEntry(fnames[0], 12, 5 /* id */, 1,
BackupStoreDirectory::Entry::Flags_File |
BackupStoreDirectory::Entry::Flags_OldVersion, 2);
-
+
+ /*
+ typedef struct
+ {
+ int name;
+ int64_t id;
+ int flags;
+ } dir_en_check;
+ */
+
dir_en_check ck[] = {
{1, 2, BackupStoreDirectory::Entry::Flags_File},
{0, 3, BackupStoreDirectory::Entry::Flags_File | BackupStoreDirectory::Entry::Flags_OldVersion},
{0, 5, BackupStoreDirectory::Entry::Flags_File},
{-1, 0, 0}
};
-
+
TEST_THAT(dir.CheckAndFix() == true);
TEST_THAT(dir.CheckAndFix() == false);
check_dir(dir, ck);
@@ -271,7 +288,7 @@ void test_dir_fixing()
dir.AddEntry(fnames[1], 12, 10 /* id */, 1, BackupStoreDirectory::Entry::Flags_File | BackupStoreDirectory::Entry::Flags_Dir | BackupStoreDirectory::Entry::Flags_OldVersion, 2);
dir.AddEntry(fnames[0], 12, 3 /* id */, 1, BackupStoreDirectory::Entry::Flags_File | BackupStoreDirectory::Entry::Flags_OldVersion, 2);
dir.AddEntry(fnames[0], 12, 5 /* id */, 1, BackupStoreDirectory::Entry::Flags_File | BackupStoreDirectory::Entry::Flags_OldVersion, 2);
-
+
dir_en_check ck[] = {
{0, 2, BackupStoreDirectory::Entry::Flags_File | BackupStoreDirectory::Entry::Flags_OldVersion},
{1, 10, BackupStoreDirectory::Entry::Flags_Dir},
@@ -279,7 +296,7 @@ void test_dir_fixing()
{0, 5, BackupStoreDirectory::Entry::Flags_File},
{-1, 0, 0}
};
-
+
TEST_THAT(dir.CheckAndFix() == true);
TEST_THAT(dir.CheckAndFix() == false);
check_dir(dir, ck);
@@ -310,7 +327,7 @@ void test_dir_fixing()
5 /* id */, 1, BackupStoreDirectory::Entry::Flags_File, 2);
TEST_THAT(e5 != 0);
e5->SetDependsOlder(4);
-
+
// This should all be nice and valid
TEST_THAT(dir.CheckAndFix() == false);
static checkdepinfoen c1[] = {{2, 3, 0}, {3, 4, 2}, {4, 5, 3}, {5, 0, 4}, {-1, 0, 0}};
@@ -399,7 +416,7 @@ void login_client_and_check_empty(BackupProtocolCallable& client)
check_dir_dep(dir, start_deps);
read_bb_dir(1 /* root */, dir);
-
+
// Everything should be OK at the moment
TEST_THAT(dir.CheckAndFix() == false);
@@ -419,7 +436,7 @@ void check_root_dir_ok(dir_en_check after_entries[],
// Check the store, check that the error is detected and
// repaired, by removing x1 from the directory.
RUN_CHECK_INTERNAL(0);
-
+
// Read the directory back in, check that it's empty
BackupStoreDirectory dir;
read_bb_dir(1 /* root */, dir);
@@ -555,10 +572,10 @@ int test(int argc, const char *argv[])
{
BackupStoreDirectory dir;
read_bb_dir(1 /* root */, dir);
-
+
dir.AddEntry(fnames[0], 12, 0x1234567890123456LL /* id */, 1,
BackupStoreDirectory::Entry::Flags_File, 2);
-
+
std::string fn;
StoreStructure::MakeObjectFilename(1 /* root */, accountRootDir,
discSetNum, fn, true /* EnsureDirectoryExists */);
@@ -590,7 +607,7 @@ int test(int argc, const char *argv[])
}
if (failures > 0) return 1;
-
+
// Generate a list of all the object IDs
TEST_THAT_ABORTONFAIL(::system(BBACKUPQUERY " -Wwarning "
"-c testfiles/bbackupd.conf \"list -R\" quit "
@@ -617,7 +634,7 @@ int test(int argc, const char *argv[])
::fclose(f);
}
- // ------------------------------------------------------------------------------------------------
+ // ------------------------------------------------------------------------------------------------
BOX_INFO(" === Delete store info, add random file");
{
// Delete store info
@@ -645,7 +662,7 @@ int test(int argc, const char *argv[])
accountRootDir + "01/randomfile"));
}
- // ------------------------------------------------------------------------------------------------
+ // ------------------------------------------------------------------------------------------------
BOX_INFO(" === Delete an entry for an object from dir, change that "
"object to be a patch, check it's deleted");
{
@@ -662,7 +679,7 @@ int test(int argc, const char *argv[])
dir.DeleteEntry(delID);
SaveDirectory("Test1/cannes/ict/metegoguered", dir);
}
-
+
// Adjust that entry
//
// IMPORTANT NOTE: There's a special hack in testbackupstorefix.pl to make sure that
@@ -784,8 +801,8 @@ int test(int argc, const char *argv[])
TEST_EQUAL(RaidFileUtil::AsRaid, RaidFileUtil::RaidFileExists(
rdiscSet, "backup/01234567/02/01/01/o03"));
}
-
- // ------------------------------------------------------------------------------------------------
+
+ // ------------------------------------------------------------------------------------------------
BOX_INFO(" === Delete directory, change container ID of another, "
"duplicate entry in dir, spurious file size, delete file");
{
@@ -824,8 +841,8 @@ int test(int argc, const char *argv[])
// Delete a file
DeleteObject("Test1/cannes/ict/scely");
- // We don't know quite how good the checker is (or will become) at
- // spotting errors! But asserting an exact number will help us catch
+ // We don't know quite how good the checker is (or will become) at
+ // spotting errors! But asserting an exact number will help us catch
// changes in checker behaviour, so it's not a bad thing to test.
// The 11 errors are:
@@ -875,7 +892,7 @@ int test(int argc, const char *argv[])
}
}
- // ------------------------------------------------------------------------------------------------
+ // ------------------------------------------------------------------------------------------------
BOX_INFO(" === Modify the obj ID of dir, delete dir with no members, "
"add extra reference to a file");
// Set bad object ID
@@ -909,18 +926,18 @@ int test(int argc, const char *argv[])
LoadDirectory("Test1/foreomizes/stemptinevidate/ict", dir);
TEST_THAT(dir.GetObjectID() == getID("Test1/foreomizes/stemptinevidate/ict"));
}
-
- // ------------------------------------------------------------------------------------------------
+
+ // ------------------------------------------------------------------------------------------------
BOX_INFO(" === Orphan files and dirs without being recoverable");
- DeleteObject("Test1/dir1");
- DeleteObject("Test1/dir1/dir2");
+ DeleteObject("Test1/dir1");
+ DeleteObject("Test1/dir1/dir2");
// Fix it
RUN_CHECK
// Check everything is where it is predicted to be
TEST_THAT(::system(PERL_EXECUTABLE
" testfiles/testbackupstorefix.pl check 4") == 0);
- // ------------------------------------------------------------------------------------------------
+ // ------------------------------------------------------------------------------------------------
BOX_INFO(" === Corrupt file and dir");
// File
CorruptObject("Test1/foreomizes/stemptinevidate/algoughtnerge",
@@ -934,7 +951,7 @@ int test(int argc, const char *argv[])
TEST_THAT(::system(PERL_EXECUTABLE
" testfiles/testbackupstorefix.pl check 5") == 0);
- // ------------------------------------------------------------------------------------------------
+ // ------------------------------------------------------------------------------------------------
BOX_INFO(" === Overwrite root with a file");
{
std::auto_ptr<RaidFileRead> r(RaidFileRead::Open(discSetNum, getObjectName(getID("Test1/pass/shuted/brightinats/milamptimaskates"))));
diff --git a/test/basicserver/testbasicserver.cpp b/test/basicserver/testbasicserver.cpp
index e6b0fa54..4e6aa89c 100644
--- a/test/basicserver/testbasicserver.cpp
+++ b/test/basicserver/testbasicserver.cpp
@@ -192,9 +192,9 @@ const ConfigurationVerify *testserver::GetConfigVerify() const
static ConfigurationVerify verifyserver[] =
{
{
- "Server",
- 0,
- verifyserverkeys,
+ "Server", /* mName */
+ 0, /* mpSubConfigurations */
+ verifyserverkeys, /* mpKeys */
ConfigTest_Exists | ConfigTest_LastEntry,
0
}
@@ -202,9 +202,9 @@ const ConfigurationVerify *testserver::GetConfigVerify() const
static ConfigurationVerify verify =
{
- "root",
- verifyserver,
- 0,
+ "root", /* mName */
+ verifyserver, /* mpSubConfigurations */
+ 0, /* mpKeys */
ConfigTest_Exists | ConfigTest_LastEntry,
0
};