[Box Backup-commit] COMMIT r3394 - box/trunk/lib/backupstore

subversion at boxbackup.org subversion at boxbackup.org
Thu Sep 4 02:36:51 BST 2014


Author: chris
Date: 2014-09-04 02:36:50 +0100 (Thu, 04 Sep 2014)
New Revision: 3394

Modified:
   box/trunk/lib/backupstore/StoreTestUtils.cpp
Log:
Fix tests broken by changing working directory.

Store the current working directory at the beginning of the first test, and
restore it at the beginning of every subsequent test.

Improve cleanup after tests: delete and recreate the bbackupd state directory.

Remove check for reference counts and account errors from tearDown, because
they are too hard to retrofit to testbbackupd, and already copied into
testbackupstore tearDown.

Modified: box/trunk/lib/backupstore/StoreTestUtils.cpp
===================================================================
--- box/trunk/lib/backupstore/StoreTestUtils.cpp	2014-09-04 01:36:49 UTC (rev 3393)
+++ box/trunk/lib/backupstore/StoreTestUtils.cpp	2014-09-04 01:36:50 UTC (rev 3394)
@@ -55,6 +55,7 @@
 
 std::vector<uint32_t> ExpectedRefCounts;
 int bbstored_pid = 0;
+std::string OriginalWorkingDir;
 
 bool setUp(const char* function_name)
 {
@@ -87,17 +88,35 @@
 		StopServer();
 	}
 
+	if (OriginalWorkingDir == "")
+	{
+		char buf[1024];
+		if (getcwd(buf, sizeof(buf)) == NULL)
+		{
+			BOX_LOG_SYS_ERROR("getcwd");
+		}
+		OriginalWorkingDir = buf;
+	}
+	else
+	{
+		if (chdir(OriginalWorkingDir.c_str()) != 0)
+		{
+			BOX_LOG_SYS_ERROR("chdir");
+		}
+	}
+
 	TEST_THAT_THROWONFAIL(system(
 		"rm -rf testfiles/TestDir* testfiles/0_0 testfiles/0_1 "
 		"testfiles/0_2 testfiles/accounts.txt " // testfiles/test* .tgz!
 		"testfiles/file* testfiles/notifyran testfiles/notifyran.* "
 		"testfiles/notifyscript.tag* "
-		"testfiles/restore* "
+		"testfiles/restore* testfiles/bbackupd-data "
 		"testfiles/syncallowscript.control "
 		"testfiles/syncallowscript.notifyran.*") == 0);
 	TEST_THAT_THROWONFAIL(mkdir("testfiles/0_0", 0755) == 0);
 	TEST_THAT_THROWONFAIL(mkdir("testfiles/0_1", 0755) == 0);
 	TEST_THAT_THROWONFAIL(mkdir("testfiles/0_2", 0755) == 0);
+	TEST_THAT_THROWONFAIL(mkdir("testfiles/bbackupd-data", 0755) == 0);
 	TEST_THAT_THROWONFAIL(system("touch testfiles/accounts.txt") == 0);
 	TEST_THAT_THROWONFAIL(create_account(10000, 20000));
 
@@ -116,12 +135,6 @@
 		TEST_THAT_OR(StopServer(), status = false);
 	}
 
-	if (FileExists("testfiles/0_0/backup/01234567/info.rf"))
-	{
-		TEST_THAT(check_reference_counts());
-		TEST_THAT(check_account());
-	}
-
 	return status;
 }
 




More information about the Boxbackup-commit mailing list