[Box Backup-commit] COMMIT r1113 - box/chris/merge/test/backupstore

boxbackup-dev at fluffy.co.uk boxbackup-dev at fluffy.co.uk
Fri Oct 27 20:08:07 BST 2006


Author: chris
Date: 2006-10-27 20:08:07 +0100 (Fri, 27 Oct 2006)
New Revision: 1113

Modified:
   box/chris/merge/test/backupstore/testbackupstore.cpp
Log:
Remove double initialisation (now done in 
infrastructure/buildenv-testmain-template.cpp) (refs #3)


Modified: box/chris/merge/test/backupstore/testbackupstore.cpp
===================================================================
--- box/chris/merge/test/backupstore/testbackupstore.cpp	2006-10-27 19:06:13 UTC (rev 1112)
+++ box/chris/merge/test/backupstore/testbackupstore.cpp	2006-10-27 19:08:07 UTC (rev 1113)
@@ -948,7 +948,7 @@
 		// Set the client store marker
 		protocol.QuerySetClientStoreMarker(0x8732523ab23aLL);
 
-#ifndef WIN32 // can't open more than one connection on Win32
+#ifndef WIN32
 		// Open a new connection which is read only
 		SocketStreamTLS connReadOnly;
 		connReadOnly.Open(context, Socket::TypeINET, hostname, BOX_PORT_BBSTORED);
@@ -968,7 +968,6 @@
 			TEST_THAT(loginConf->GetClientStoreMarker() == 0x8732523ab23aLL);
 		}
 #else // WIN32
-		// we can't open a new connection, so fake it
 		BackupProtocolClient& protocolReadOnly(protocol);
 #endif
 
@@ -1531,48 +1530,35 @@
 		
 		// The test block to a file
 		{
-			FileStream f("testfiles" DIRECTORY_SEPARATOR 
-				"testenc1", O_WRONLY | O_CREAT | O_EXCL);
+			FileStream f("testfiles/testenc1", O_WRONLY | O_CREAT | O_EXCL);
 			f.Write(encfile, sizeof(encfile));
 		}
 		
 		// Encode it
 		{
-			FileStream out("testfiles" DIRECTORY_SEPARATOR 
-				"testenc1_enc", O_WRONLY | O_CREAT | O_EXCL);
-			BackupStoreFilenameClear name("testfiles"
-				DIRECTORY_SEPARATOR "testenc1");
+			FileStream out("testfiles/testenc1_enc", O_WRONLY | O_CREAT | O_EXCL);
+			BackupStoreFilenameClear name("testfiles/testenc1");
 
-			std::auto_ptr<IOStream> encoded(
-				BackupStoreFile::EncodeFile(
-					"testfiles" DIRECTORY_SEPARATOR
-					"testenc1", 32, name));
+			std::auto_ptr<IOStream> encoded(BackupStoreFile::EncodeFile("testfiles/testenc1", 32, name));
 			encoded->CopyStreamTo(out);
 		}
 		
 		// Verify it
 		{
-			FileStream enc("testfiles" DIRECTORY_SEPARATOR 
-				"testenc1_enc");
+			FileStream enc("testfiles/testenc1_enc");
 			TEST_THAT(BackupStoreFile::VerifyEncodedFileFormat(enc) == true);
 		}
 		
 		// Decode it
 		{
-			FileStream enc("testfiles" DIRECTORY_SEPARATOR 
-				"testenc1_enc");
-			BackupStoreFile::DecodeFile(enc, "testfiles"
-				DIRECTORY_SEPARATOR "testenc1_orig", 
-				IOStream::TimeOutInfinite);
+			FileStream enc("testfiles/testenc1_enc");
+			BackupStoreFile::DecodeFile(enc, "testfiles/testenc1_orig", IOStream::TimeOutInfinite);
 		}
 		
 		// Read in rebuilt original, and compare contents
 		{
-			TEST_THAT(TestGetFileSize("testfiles" 
-				DIRECTORY_SEPARATOR "testenc1_orig") 
-				== sizeof(encfile));
-			FileStream in("testfiles" DIRECTORY_SEPARATOR 
-				"testenc1_orig");
+			TEST_THAT(TestGetFileSize("testfiles/testenc1_orig") == sizeof(encfile));
+			FileStream in("testfiles/testenc1_orig");
 			int encfile_i[ENCFILE_SIZE];
 			in.Read(encfile_i, sizeof(encfile_i));
 			TEST_THAT(memcmp(encfile, encfile_i, sizeof(encfile)) == 0);
@@ -1580,8 +1566,7 @@
 		
 		// Check how many blocks it had, and test the stream based interface
 		{
-			FileStream enc("testfiles" DIRECTORY_SEPARATOR 
-				"testenc1_enc");
+			FileStream enc("testfiles/testenc1_enc");
 			std::auto_ptr<BackupStoreFile::DecodedStream> decoded(BackupStoreFile::DecodeFileStream(enc, IOStream::TimeOutInfinite));
 			CollectInBufferStream d;
 			decoded->CopyStreamTo(d, IOStream::TimeOutInfinite, 971 /* buffer block size */);
@@ -1595,15 +1580,10 @@
 		// 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)
-			FileStream f("testfiles" DIRECTORY_SEPARATOR 
-				"testenc2", O_WRONLY | O_CREAT | O_EXCL);
+			FileStream f("testfiles/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(
-					"testfiles" DIRECTORY_SEPARATOR
-					"testenc2", 32, name));
+			std::auto_ptr<IOStream> encoded(BackupStoreFile::EncodeFile("testfiles/testenc2", 32, name));
 			CollectInBufferStream e;
 			encoded->CopyStreamTo(e);
 			e.SetForReading();
@@ -1619,8 +1599,7 @@
 		
 		// Test that reordered streams work too
 		{
-			FileStream enc("testfiles" DIRECTORY_SEPARATOR 
-				"testenc1_enc");
+			FileStream enc("testfiles/testenc1_enc");
 			std::auto_ptr<IOStream> reordered(BackupStoreFile::ReorderFileToStreamOrder(&enc, false));
 			std::auto_ptr<BackupStoreFile::DecodedStream> decoded(BackupStoreFile::DecodeFileStream(*reordered, IOStream::TimeOutInfinite));
 			CollectInBufferStream d;
@@ -1652,14 +1631,9 @@
 	// Store info
 	{
 		RaidFileWrite::CreateDirectory(0, "test-info");
-		BackupStoreInfo::CreateNew(76, "test-info" DIRECTORY_SEPARATOR, 
-			0, 3461231233455433LL, 2934852487LL);
-		TEST_CHECK_THROWS(BackupStoreInfo::CreateNew(76, 
-			"test-info" DIRECTORY_SEPARATOR, 0, 0, 0), 
-			RaidFileException, CannotOverwriteExistingFile);
-		std::auto_ptr<BackupStoreInfo> info(
-			BackupStoreInfo::Load(76, 
-				"test-info" DIRECTORY_SEPARATOR, 0, true));
+		BackupStoreInfo::CreateNew(76, "test-info/", 0, 3461231233455433LL, 2934852487LL);
+		TEST_CHECK_THROWS(BackupStoreInfo::CreateNew(76, "test-info/", 0, 0, 0), RaidFileException, CannotOverwriteExistingFile);
+		std::auto_ptr<BackupStoreInfo> info(BackupStoreInfo::Load(76, "test-info/", 0, true));
 		TEST_CHECK_THROWS(info->Save(), BackupStoreException, StoreInfoIsReadOnly);
 		TEST_CHECK_THROWS(info->ChangeBlocksUsed(1), BackupStoreException, StoreInfoIsReadOnly);
 		TEST_CHECK_THROWS(info->ChangeBlocksInOldFiles(1), BackupStoreException, StoreInfoIsReadOnly);
@@ -1668,8 +1642,7 @@
 		TEST_CHECK_THROWS(info->AddDeletedDirectory(2), BackupStoreException, StoreInfoIsReadOnly);
 	}
 	{
-		std::auto_ptr<BackupStoreInfo> info(BackupStoreInfo::Load(76, 
-			"test-info" DIRECTORY_SEPARATOR, 0, false));
+		std::auto_ptr<BackupStoreInfo> info(BackupStoreInfo::Load(76, "test-info/", 0, false));
 		info->ChangeBlocksUsed(8);
 		info->ChangeBlocksInOldFiles(9);
 		info->ChangeBlocksInDeletedFiles(10);
@@ -1687,8 +1660,7 @@
 		info->Save();
 	}
 	{
-		std::auto_ptr<BackupStoreInfo> info(BackupStoreInfo::Load(76, 
-			"test-info" DIRECTORY_SEPARATOR, 0, true));
+		std::auto_ptr<BackupStoreInfo> info(BackupStoreInfo::Load(76, "test-info/", 0, true));
 		TEST_THAT(info->GetBlocksUsed() == 7);
 		TEST_THAT(info->GetBlocksInOldFiles() == 5);
 		TEST_THAT(info->GetBlocksInDeletedFiles() == 1);
@@ -1706,9 +1678,9 @@
 	// Context
 	TLSContext context;
 	context.Initialise(false /* client */,
-			"testfiles" DIRECTORY_SEPARATOR "clientCerts.pem",
-			"testfiles" DIRECTORY_SEPARATOR "clientPrivKey.pem",
-			"testfiles" DIRECTORY_SEPARATOR "clientTrustedCAs.pem");
+			"testfiles/clientCerts.pem",
+			"testfiles/clientPrivKey.pem",
+			"testfiles/clientTrustedCAs.pem");
 
 	// First, try logging in without an account having been created... just make sure login fails.
 	int pid = LaunchServer("../../bin/bbstored/bbstored testfiles/bbstored.conf", "testfiles/bbstored.pid");
@@ -1740,7 +1712,7 @@
 		}
 
 		// Create an account for the test client
-		TEST_THAT_ABORTONFAIL(RunCommand("../../bin/bbstoreaccounts/bbstoreaccounts -c testfiles/bbstored.conf create 01234567 0 10000B 20000B") == 0);
+		TEST_THAT_ABORTONFAIL(::system("../../bin/bbstoreaccounts/bbstoreaccounts -c testfiles/bbstored.conf create 01234567 0 10000B 20000B") == 0);
 		TestRemoteProcessMemLeaks("bbstoreaccounts.memleaks");
 		TEST_THAT(TestDirExists("testfiles/0_0/backup/01234567"));
 		TEST_THAT(TestDirExists("testfiles/0_1/backup/01234567"));
@@ -1771,7 +1743,7 @@
 		
 		// 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(RunCommand("../../bin/bbstoreaccounts/bbstoreaccounts -c testfiles/bbstored.conf setlimit 01234567 10B 20000B") == 0);
+		TEST_THAT_ABORTONFAIL(::system("../../bin/bbstoreaccounts/bbstoreaccounts -c testfiles/bbstored.conf setlimit 01234567 10B 20000B") == 0);
 		TestRemoteProcessMemLeaks("bbstoreaccounts.memleaks");
 
 		// Start things up
@@ -1800,7 +1772,7 @@
 		TEST_THAT(after.old == 0);
 		
 		// Set a really small hard limit
-		TEST_THAT_ABORTONFAIL(RunCommand("../../bin/bbstoreaccounts/bbstoreaccounts -c testfiles/bbstored.conf setlimit 01234567 10B 20B") == 0);
+		TEST_THAT_ABORTONFAIL(::system("../../bin/bbstoreaccounts/bbstoreaccounts -c testfiles/bbstored.conf setlimit 01234567 10B 20B") == 0);
 		TestRemoteProcessMemLeaks("bbstoreaccounts.memleaks");
 
 		// Try to upload a file and create a directory, and check an error is generated
@@ -1864,11 +1836,8 @@
 	printf("Starting server for connection from remote machines...\n");
 
 	// Create an account for the test client
-	TEST_THAT_ABORTONFAIL(RunCommand("../../bin/bbstoreaccounts/bbstoreaccounts -c testfiles/bbstored.conf create 01234567 0 30000B 40000B") == 0);
-
-#ifndef WIN32
+	TEST_THAT_ABORTONFAIL(::system("../../bin/bbstoreaccounts/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.
 	int pid = LaunchServer("../../bin/bbstored/bbstored testfiles/bbstored_multi.conf", "testfiles/bbstored.pid");
@@ -1905,12 +1874,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);




More information about the Boxbackup-commit mailing list