[Box Backup-dev] COMMIT r602 - box/chris/general/test/backupstorefix
boxbackup-dev@fluffy.co.uk
boxbackup-dev@fluffy.co.uk
Tue, 30 May 2006 19:23:22 +0000 (GMT)
Author: chris
Date: 2006-05-30 19:23:03 +0000 (Tue, 30 May 2006)
New Revision: 602
Modified:
box/chris/general/test/backupstorefix/testbackupstorefix.cpp
Log:
* testbackupstorefix.cpp
- Fixed paths on Win32
- Fixed files left open while trying to delete them
- Disabled memory leak checks on Win32
- Reduced wait for bbackupd since it has plenty of time
- Fixed some spelling errors
Modified: box/chris/general/test/backupstorefix/testbackupstorefix.cpp
===================================================================
--- box/chris/general/test/backupstorefix/testbackupstorefix.cpp 2006-05-30 19:20:18 UTC (rev 601)
+++ box/chris/general/test/backupstorefix/testbackupstorefix.cpp 2006-05-30 19:23:03 UTC (rev 602)
@@ -64,9 +64,15 @@
std::map<std::string, int32_t> nameToID;
std::map<int32_t, bool> objectIsDir;
+#ifdef WIN32
#define RUN_CHECK \
+ ::system("..\\..\\bin\\bbstoreaccounts\\bbstoreaccounts -c testfiles/bbstored.conf check 01234567"); \
+ ::system("..\\..\\bin\\bbstoreaccounts\\bbstoreaccounts -c testfiles/bbstored.conf check 01234567 fix");
+#else
+#define RUN_CHECK \
::system("../../bin/bbstoreaccounts/bbstoreaccounts -c testfiles/bbstored.conf check 01234567"); \
::system("../../bin/bbstoreaccounts/bbstoreaccounts -c testfiles/bbstored.conf check 01234567 fix");
+#endif
// Wait a given number of seconds for something to complete
void wait_for_operation(int seconds)
@@ -138,6 +144,7 @@
w.Write(rubbish, rubbish_len);
// Copy rest of file
r->CopyStreamTo(w);
+ r->Close();
// Commit
w.Commit(true /* convert now */);
}
@@ -300,11 +307,20 @@
rcontroller.Initialise("testfiles/raidfile.conf");
// Create an account
+#ifdef WIN32
+ TEST_THAT_ABORTONFAIL(::system("..\\..\\bin\\bbstoreaccounts\\bbstoreaccounts -c testfiles/bbstored.conf create 01234567 0 10000B 20000B") == 0);
+#else
TEST_THAT_ABORTONFAIL(::system("../../bin/bbstoreaccounts/bbstoreaccounts -c testfiles/bbstored.conf create 01234567 0 10000B 20000B") == 0);
TestRemoteProcessMemLeaks("bbstoreaccounts.memleaks");
+#endif
// Start the bbstored server
+#ifdef WIN32
+ int pid = LaunchServer("..\\..\\bin\\bbstored\\bbstored testfiles/bbstored.conf", "testfiles/bbstored.pid");
+#else
int pid = LaunchServer("../../bin/bbstored/bbstored testfiles/bbstored.conf", "testfiles/bbstored.pid");
+#endif
+
TEST_THAT(pid != -1 && pid != 0);
if(pid > 0)
{
@@ -314,7 +330,12 @@
// Run the perl script to create the initial directories
TEST_THAT_ABORTONFAIL(::system("perl testfiles/testbackupstorefix.pl init") == 0);
+#ifdef WIN32
+ int bbackupd_pid = LaunchServer("..\\..\\bin\\bbackupd\\bbackupd testfiles/bbackupd.conf", "testfiles/bbackupd.pid");
+#else
int bbackupd_pid = LaunchServer("../../bin/bbackupd/bbackupd testfiles/bbackupd.conf", "testfiles/bbackupd.pid");
+#endif
+
TEST_THAT(bbackupd_pid != -1 && bbackupd_pid != 0);
if(bbackupd_pid > 0)
{
@@ -322,15 +343,22 @@
TEST_THAT(ServerIsAlive(bbackupd_pid));
// Create a nice store directory
- wait_for_operation(30);
+ wait_for_operation(14);
// That'll do nicely, stop the server
TEST_THAT(KillServer(bbackupd_pid));
+#ifndef WIN32
TestRemoteProcessMemLeaks("bbackupd.memleaks");
+#endif
}
// Generate a list of all the object IDs
+#ifdef WIN32
+ TEST_THAT_ABORTONFAIL(::system("..\\..\\bin\\bbackupquery\\bbackupquery -q -c testfiles/bbackupd.conf \"list -r\" quit > testfiles/initial-listing.txt") == 0);
+#else
TEST_THAT_ABORTONFAIL(::system("../../bin/bbackupquery/bbackupquery -q -c testfiles/bbackupd.conf \"list -r\" quit > testfiles/initial-listing.txt") == 0);
+#endif
+
// And load it in
{
FILE *f = ::fopen("testfiles/initial-listing.txt", "r");
@@ -358,7 +386,7 @@
del.Delete();
}
{
- // Add a suprious file
+ // Add a spurious file
RaidFileWrite random(discSetNum, storeRoot + "randomfile");
random.Open();
random.Write("test", 4);
@@ -367,6 +395,7 @@
// Fix it
RUN_CHECK
// Check everything is as it was
+
TEST_THAT(::system("perl testfiles/testbackupstorefix.pl check 0") == 0);
// Check the random file doesn't exist
{
@@ -410,6 +439,8 @@
file_BlockIndexEntry e[2];
} h;
TEST_THAT(file->Read(&h, sizeof(h)) == sizeof(h));
+ file->Close();
+
// Modify
TEST_THAT(box_ntoh64(h.hdr.mOtherFileID) == 0);
TEST_THAT(box_ntoh64(h.hdr.mNumBlocks) >= 2);
@@ -432,7 +463,7 @@
}
// ------------------------------------------------------------------------------------------------
- ::printf(" === Delete directory, change container ID of another, duplicate entry in dir, supurious file size, delete file\n");
+ ::printf(" === Delete directory, change container ID of another, duplicate entry in dir, spurious file size, delete file\n");
{
BackupStoreDirectory dir;
LoadDirectory("Test1/foreomizes/stemptinevidate/ict", dir);
@@ -440,7 +471,7 @@
SaveDirectory("Test1/foreomizes/stemptinevidate/ict", dir);
}
int64_t duplicatedID = 0;
- int64_t notSupriousFileSize = 0;
+ int64_t notSpuriousFileSize = 0;
{
BackupStoreDirectory dir;
LoadDirectory("Test1/cannes/ict/peep", dir);
@@ -458,7 +489,7 @@
BackupStoreDirectory::Iterator i(dir);
BackupStoreDirectory::Entry *en = i.Next(BackupStoreDirectory::Entry::Flags_File);
TEST_THAT(en != 0);
- notSupriousFileSize = en->GetSizeInBlocks();
+ notSpuriousFileSize = en->GetSizeInBlocks();
en->SetSizeInBlocks(3473874);
TEST_THAT(en->GetSizeInBlocks() == 3473874);
}
@@ -497,7 +528,7 @@
BackupStoreDirectory::Iterator i(dir);
BackupStoreDirectory::Entry *en = i.Next(BackupStoreDirectory::Entry::Flags_File);
TEST_THAT(en != 0);
- TEST_THAT(en->GetSizeInBlocks() == notSupriousFileSize);
+ TEST_THAT(en->GetSizeInBlocks() == notSpuriousFileSize);
}
}
@@ -572,7 +603,9 @@
// ------------------------------------------------------------------------------------------------
// Stop server
TEST_THAT(KillServer(pid));
+#ifndef WIN32
TestRemoteProcessMemLeaks("bbstored.memleaks");
+#endif
}
return 0;