[Box Backup-commit] COMMIT r1292 - box/chris/general/test/backupstore

boxbackup-dev@fluffy.co.uk boxbackup-dev@fluffy.co.uk
Wed, 14 Feb 2007 23:20:12 +0000


Author: chris
Date: 2007-02-14 23:20:11 +0000 (Wed, 14 Feb 2007)
New Revision: 1292

Modified:
   box/chris/general/test/backupstore/testbackupstore.cpp
Log:
Use new constants for paths to executables, remove ifdefs.

Clean up comment formatting.


Modified: box/chris/general/test/backupstore/testbackupstore.cpp
===================================================================
--- box/chris/general/test/backupstore/testbackupstore.cpp	2007-02-14 23:19:24 UTC (rev 1291)
+++ box/chris/general/test/backupstore/testbackupstore.cpp	2007-02-14 23:20:11 UTC (rev 1292)
@@ -1597,7 +1597,6 @@
 			FileStream f("testfiles" DIRECTORY_SEPARATOR 
 				"testenc2", O_WRONLY | O_CREAT | O_EXCL);
 			f.Write(encfile + 2, FILE_SIZE_JUST_OVER);
-			f.Close();
 			BackupStoreFilenameClear name("testenc2");
 			std::auto_ptr<IOStream> encoded(
 				BackupStoreFile::EncodeFile(
@@ -1745,17 +1744,17 @@
 		}
 
 		// Create an account for the test client
-#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);
+		TEST_THAT_ABORTONFAIL(::system(BBSTOREACCOUNTS
+			" -c testfiles/bbstored.conf create 01234567 0 "
+			"10000B 20000B") == 0);
+
 		TestRemoteProcessMemLeaks("bbstoreaccounts.memleaks");
-#endif
 
 		TEST_THAT(TestDirExists("testfiles/0_0/backup/01234567"));
 		TEST_THAT(TestDirExists("testfiles/0_1/backup/01234567"));
 		TEST_THAT(TestDirExists("testfiles/0_2/backup/01234567"));
-		TEST_THAT(TestGetFileSize("testfiles/accounts.txt") > 8);	// make sure something is written to it
+		TEST_THAT(TestGetFileSize("testfiles/accounts.txt") > 8);
+		// make sure something is written to it
 
 		TEST_THAT(ServerIsAlive(pid));
 
@@ -1779,22 +1778,17 @@
 		TestRemoteProcessMemLeaks("bbstored.memleaks");
 #endif
 		
-		// Set a new limit on the account -- leave the hard limit high to make sure the target for
-		// freeing space is the soft limit.
-
-#ifdef WIN32
-		TEST_THAT_ABORTONFAIL(::system("..\\..\\bin\\bbstoreaccounts\\bbstoreaccounts -c testfiles/bbstored.conf setlimit 01234567 10B 20000B") == 0);
-#else
-		TEST_THAT_ABORTONFAIL(::system("../../bin/bbstoreaccounts/bbstoreaccounts -c testfiles/bbstored.conf setlimit 01234567 10B 20000B") == 0);
+		// Set a new limit on the account -- leave the hard limit 
+		// high to make sure the target for freeing space is the 
+		// soft limit.
+		TEST_THAT_ABORTONFAIL(::system(BBSTOREACCOUNTS 
+			" -c testfiles/bbstored.conf setlimit 01234567 "
+			"10B 20000B") == 0);
 		TestRemoteProcessMemLeaks("bbstoreaccounts.memleaks");
-#endif
 
 		// Start things up
-#ifdef WIN32
-		pid = LaunchServer("..\\..\\bin\\bbstored\\bbstored testfiles/bbstored.conf", "testfiles/bbstored.pid");
-#else
-		pid = LaunchServer("../../bin/bbstored/bbstored testfiles/bbstored.conf", "testfiles/bbstored.pid");
-#endif
+		pid = LaunchServer(BBSTORED " testfiles/bbstored.conf", 
+			"testfiles/bbstored.pid");
 
 		::sleep(1);
 		TEST_THAT(ServerIsAlive(pid));
@@ -1811,8 +1805,9 @@
 
 		// Count the objects again
 		recursive_count_objects_results after = {0,0,0};
-		recursive_count_objects("localhost", BackupProtocolClientListDirectory::RootDirectory, after);
-printf("after.objectsNotDel=%i, deleted=%i, old=%i\n",after.objectsNotDel, after.deleted, after.old);
+		recursive_count_objects("localhost", 
+			BackupProtocolClientListDirectory::RootDirectory, 
+			after);
 
 		// If these tests fail then try increasing the timeout above
 		TEST_THAT(after.objectsNotDel == before.objectsNotDel);
@@ -1820,12 +1815,10 @@
 		TEST_THAT(after.old == 0);
 		
 		// Set a really small hard limit
-#ifdef WIN32
-		TEST_THAT_ABORTONFAIL(::system("..\\..\\bin\\bbstoreaccounts\\bbstoreaccounts -c testfiles/bbstored.conf setlimit 01234567 10B 20B") == 0);
-#else
-		TEST_THAT_ABORTONFAIL(::system("../../bin/bbstoreaccounts/bbstoreaccounts -c testfiles/bbstored.conf setlimit 01234567 10B 20B") == 0);
+		TEST_THAT_ABORTONFAIL(::system(BBSTOREACCOUNTS 
+			" -c testfiles/bbstored.conf setlimit 01234567 "
+			"10B 20B") == 0);
 		TestRemoteProcessMemLeaks("bbstoreaccounts.memleaks");
-#endif
 
 		// Try to upload a file and create a directory, and check an error is generated
 		{
@@ -1888,19 +1881,15 @@
 	printf("Starting server for connection from remote machines...\n");
 
 	// Create an account for the test client
-	TEST_THAT_ABORTONFAIL(::system("../../bin/bbstoreaccounts/bbstoreaccounts -c testfiles/bbstored.conf create 01234567 0 30000B 40000B") == 0);
-
-#ifndef WIN32
+	TEST_THAT_ABORTONFAIL(::system(BBSTOREACCOUNTS 
+		" -c testfiles/bbstored.conf create 01234567 0 "
+		"30000B 40000B") == 0);
 	TestRemoteProcessMemLeaks("bbstoreaccounts.memleaks");
-#endif
 
 	// First, try logging in without an account having been created... just make sure login fails.
 
-#ifdef WIN32
-	int pid = LaunchServer("..\\..\\bin\\bbstored\\bbstored testfiles/bbstored_multi.conf", "testfiles/bbstored.pid");
-#else
-	int pid = LaunchServer("../../bin/bbstored/bbstored testfiles/bbstored_multi.conf", "testfiles/bbstored.pid");
-#endif
+	int pid = LaunchServer(BBSTORED " testfiles/bbstored_multi.conf", 
+		"testfiles/bbstored.pid");
 
 	TEST_THAT(pid != -1 && pid != 0);
 	if(pid > 0)
@@ -1935,12 +1924,6 @@
 int test(int argc, const char *argv[])
 {
 #ifdef WIN32
-	// Under win32 we must initialise the Winsock library
-	// before using sockets
-
-	WSADATA info;
-	TEST_THAT(WSAStartup(0x0101, &info) != SOCKET_ERROR)
-
 	// this had better work, or bbstored will die when combining diffs
 	char* file = "foo";
 	std::string abs = ConvertPathToAbsoluteUnicode(file);