From fb4e179a2f4440f25f379a23c0d94744d34c4f66 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Sun, 25 Mar 2007 00:37:54 +0000 Subject: Fix spurious/suprious typos. Use #defined paths for executables to remove win32/unix differences. Don't check for bbstored memory leaks on win32. Wrap long lines for readability. (refs #3) --- test/backupstorefix/testbackupstorefix.cpp | 92 ++++++++++++++++++++---------- 1 file changed, 63 insertions(+), 29 deletions(-) diff --git a/test/backupstorefix/testbackupstorefix.cpp b/test/backupstorefix/testbackupstorefix.cpp index dd8251c5..318bea47 100644 --- a/test/backupstorefix/testbackupstorefix.cpp +++ b/test/backupstorefix/testbackupstorefix.cpp @@ -43,7 +43,7 @@ make some BackupDirectoryStore objects, CheckAndFix(), then verify - all old flags delete store info -add suprious file +add spurious file delete directory (should appear again) change container ID of directory delete a file @@ -66,8 +66,8 @@ std::map nameToID; std::map objectIsDir; #define RUN_CHECK \ - ::system("../../bin/bbstoreaccounts/bbstoreaccounts -c testfiles/bbstored.conf check 01234567"); \ - ::system("../../bin/bbstoreaccounts/bbstoreaccounts -c testfiles/bbstored.conf check 01234567 fix"); + ::system(BBSTOREACCOUNTS " -c testfiles/bbstored.conf check 01234567"); \ + ::system(BBSTOREACCOUNTS " -c testfiles/bbstored.conf check 01234567 fix"); // Get ID of an object given a filename int32_t getID(const char *name) @@ -265,7 +265,7 @@ void test_dir_fixing() TEST_THAT(dir.CheckAndFix() == false); check_dir_dep(dir, c1); - // Check that a suprious depends older ref is undone + // Check that a spurious depends older ref is undone e2->SetDependsOlder(1); TEST_THAT(dir.CheckAndFix() == true); TEST_THAT(dir.CheckAndFix() == false); @@ -290,37 +290,52 @@ int test(int argc, const char *argv[]) rcontroller.Initialise("testfiles/raidfile.conf"); // Create an account - TEST_THAT_ABORTONFAIL(::system("../../bin/bbstoreaccounts/bbstoreaccounts -c testfiles/bbstored.conf create 01234567 0 10000B 20000B") == 0); + TEST_THAT_ABORTONFAIL(::system(BBSTOREACCOUNTS + " -c testfiles/bbstored.conf " + "create 01234567 0 10000B 20000B") == 0); TestRemoteProcessMemLeaks("bbstoreaccounts.memleaks"); // Start the bbstored server - int pid = LaunchServer("../../bin/bbstored/bbstored testfiles/bbstored.conf", "testfiles/bbstored.pid"); + int pid = LaunchServer(BBSTORED " testfiles/bbstored.conf", + "testfiles/bbstored.pid"); TEST_THAT(pid != -1 && pid != 0); + if(pid > 0) { ::sleep(1); TEST_THAT(ServerIsAlive(pid)); // Run the perl script to create the initial directories - TEST_THAT_ABORTONFAIL(::system(PERL_EXECUTABLE " testfiles/testbackupstorefix.pl init") == 0); + TEST_THAT_ABORTONFAIL(::system(PERL_EXECUTABLE + " testfiles/testbackupstorefix.pl init") == 0); - int bbackupd_pid = LaunchServer("../../bin/bbackupd/bbackupd testfiles/bbackupd.conf", "testfiles/bbackupd.pid"); + int bbackupd_pid = LaunchServer(BBACKUPD + " testfiles/bbackupd.conf", "testfiles/bbackupd.pid"); TEST_THAT(bbackupd_pid != -1 && bbackupd_pid != 0); + if(bbackupd_pid > 0) { ::sleep(1); 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)); - TestRemoteProcessMemLeaks("bbackupd.memleaks"); + #ifdef WIN32 + terminate_bbackupd(bbackupd_pid); + // implicit check for memory leaks + #else + TEST_THAT(KillServer(bbackupd_pid)); + TestRemoteProcessMemLeaks("bbackupd.memleaks"); + #endif } // Generate a list of all the object IDs - TEST_THAT_ABORTONFAIL(::system("../../bin/bbackupquery/bbackupquery -q -c testfiles/bbackupd.conf \"list -r\" quit > testfiles/initial-listing.txt") == 0); + TEST_THAT_ABORTONFAIL(::system(BBACKUPQUERY " -q " + "-c testfiles/bbackupd.conf \"list -r\" quit " + "> testfiles/initial-listing.txt") == 0); + // And load it in { FILE *f = ::fopen("testfiles/initial-listing.txt", "r"); @@ -331,7 +346,8 @@ int test(int argc, const char *argv[]) char name[256]; while(::fgets(line, sizeof(line), f) != 0) { - TEST_THAT(::sscanf(line, "%x %s %s", &id, flags, name) == 3); + TEST_THAT(::sscanf(line, "%x %s %s", &id, + flags, name) == 3); bool isDir = (::strcmp(flags, "-d---") == 0); //TRACE3("%x,%d,%s\n", id, isDir, name); MEMLEAKFINDER_NO_LEAKS; @@ -349,19 +365,24 @@ int test(int argc, const char *argv[]) del.Delete(); } { - // Add a suprious file - RaidFileWrite random(discSetNum, storeRoot + "randomfile"); + // Add a spurious file + RaidFileWrite random(discSetNum, + storeRoot + "randomfile"); random.Open(); random.Write("test", 4); random.Commit(true); } + // Fix it RUN_CHECK + // Check everything is as it was - TEST_THAT(::system(PERL_EXECUTABLE " testfiles/testbackupstorefix.pl check 0") == 0); + TEST_THAT(::system(PERL_EXECUTABLE + " testfiles/testbackupstorefix.pl check 0") == 0); // Check the random file doesn't exist { - TEST_THAT(!RaidFileRead::FileExists(discSetNum, storeRoot + "01/randomfile")); + TEST_THAT(!RaidFileRead::FileExists(discSetNum, + storeRoot + "01/randomfile")); } // ------------------------------------------------------------------------------------------------ @@ -401,6 +422,8 @@ int test(int argc, const char *argv[]) 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); @@ -416,7 +439,9 @@ int test(int argc, const char *argv[]) // Fix it RUN_CHECK // Check - TEST_THAT(::system(PERL_EXECUTABLE " testfiles/testbackupstorefix.pl check 1") == 0); + TEST_THAT(::system(PERL_EXECUTABLE + " testfiles/testbackupstorefix.pl check 1") + == 0); // Check the modified file doesn't exist TEST_THAT(!RaidFileRead::FileExists(discSetNum, fn)); @@ -431,7 +456,7 @@ int test(int argc, const char *argv[]) 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); @@ -449,7 +474,7 @@ int test(int argc, const char *argv[]) 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); } @@ -462,7 +487,8 @@ int test(int argc, const char *argv[]) // Fix it RUN_CHECK // Check everything is as it should be - TEST_THAT(::system(PERL_EXECUTABLE " testfiles/testbackupstorefix.pl check 2") == 0); + TEST_THAT(::system(PERL_EXECUTABLE + " testfiles/testbackupstorefix.pl check 2") == 0); { BackupStoreDirectory dir; LoadDirectory("Test1/foreomizes/stemptinevidate/ict", dir); @@ -488,7 +514,7 @@ int test(int argc, const char *argv[]) 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); } } @@ -518,7 +544,8 @@ int test(int argc, const char *argv[]) // Fix it RUN_CHECK // Check everything is as it should be - TEST_THAT(::system(PERL_EXECUTABLE " testfiles/testbackupstorefix.pl check 3") == 0); + TEST_THAT(::system(PERL_EXECUTABLE + " testfiles/testbackupstorefix.pl check 3") == 0); { BackupStoreDirectory dir; LoadDirectory("Test1/foreomizes/stemptinevidate/ict", dir); @@ -532,18 +559,22 @@ int test(int argc, const char *argv[]) // Fix it RUN_CHECK // Check everything is where it is predicted to be - TEST_THAT(::system(PERL_EXECUTABLE " testfiles/testbackupstorefix.pl check 4") == 0); + TEST_THAT(::system(PERL_EXECUTABLE + " testfiles/testbackupstorefix.pl check 4") == 0); // ------------------------------------------------------------------------------------------------ ::printf(" === Corrupt file and dir\n"); // File - CorruptObject("Test1/foreomizes/stemptinevidate/algoughtnerge", 33, "34i729834298349283479233472983sdfhasgs"); + CorruptObject("Test1/foreomizes/stemptinevidate/algoughtnerge", + 33, "34i729834298349283479233472983sdfhasgs"); // Dir - CorruptObject("Test1/cannes/imulatrougge/foreomizes", 23, "dsf32489sdnadf897fd2hjkesdfmnbsdfcsfoisufio2iofe2hdfkjhsf"); + CorruptObject("Test1/cannes/imulatrougge/foreomizes",23, + "dsf32489sdnadf897fd2hjkesdfmnbsdfcsfoisufio2iofe2hdfkjhsf"); // Fix it RUN_CHECK // Check everything is where it should be - TEST_THAT(::system(PERL_EXECUTABLE " testfiles/testbackupstorefix.pl check 5") == 0); + TEST_THAT(::system(PERL_EXECUTABLE + " testfiles/testbackupstorefix.pl check 5") == 0); // ------------------------------------------------------------------------------------------------ ::printf(" === Overwrite root with a file\n"); @@ -557,13 +588,16 @@ int test(int argc, const char *argv[]) // Fix it RUN_CHECK // Check everything is where it should be - TEST_THAT(::system(PERL_EXECUTABLE " testfiles/testbackupstorefix.pl reroot 6") == 0); + TEST_THAT(::system(PERL_EXECUTABLE + " testfiles/testbackupstorefix.pl reroot 6") == 0); // ------------------------------------------------------------------------------------------------ // Stop server TEST_THAT(KillServer(pid)); - TestRemoteProcessMemLeaks("bbstored.memleaks"); + #ifndef WIN32 + TestRemoteProcessMemLeaks("bbstored.memleaks"); + #endif } return 0; -- cgit v1.2.3