summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2014-09-04 01:36:50 +0000
committerChris Wilson <chris+github@qwirx.com>2014-09-04 01:36:50 +0000
commit936592b07908cf51ad8de3699a628fd8bb6fda0b (patch)
tree8a947dd1a4e1eccf60a0cb00bebfcdb764ad20cb /lib
parenteb31e3fdf19d59b4d056c7039f117c934650e619 (diff)
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.
Diffstat (limited to 'lib')
-rw-r--r--lib/backupstore/StoreTestUtils.cpp27
1 files changed, 20 insertions, 7 deletions
diff --git a/lib/backupstore/StoreTestUtils.cpp b/lib/backupstore/StoreTestUtils.cpp
index e173b8d1..abfddce8 100644
--- a/lib/backupstore/StoreTestUtils.cpp
+++ b/lib/backupstore/StoreTestUtils.cpp
@@ -55,6 +55,7 @@ bool delete_account()
std::vector<uint32_t> ExpectedRefCounts;
int bbstored_pid = 0;
+std::string OriginalWorkingDir;
bool setUp(const char* function_name)
{
@@ -87,17 +88,35 @@ bool setUp(const char* function_name)
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 @@ bool tearDown()
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;
}