summaryrefslogtreecommitdiff
path: root/lib/backupstore/StoreTestUtils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/backupstore/StoreTestUtils.cpp')
-rw-r--r--lib/backupstore/StoreTestUtils.cpp48
1 files changed, 47 insertions, 1 deletions
diff --git a/lib/backupstore/StoreTestUtils.cpp b/lib/backupstore/StoreTestUtils.cpp
index abfddce8..48b6370c 100644
--- a/lib/backupstore/StoreTestUtils.cpp
+++ b/lib/backupstore/StoreTestUtils.cpp
@@ -54,7 +54,7 @@ bool delete_account()
}
std::vector<uint32_t> ExpectedRefCounts;
-int bbstored_pid = 0;
+int bbstored_pid = 0, bbackupd_pid = 0;
std::string OriginalWorkingDir;
bool setUp(const char* function_name)
@@ -381,4 +381,50 @@ bool StopServer(bool wait_for_process)
return true;
}
+#define FAIL { \
+ /* \
+ std::ostringstream os; \
+ os << "failed at " << __FUNCTION__ << ":" << __LINE__; \
+ s_test_status[current_test_name] = os.str(); \
+ return fail(); \
+ */ \
+ return false; \
+}
+
+bool StartClient(const std::string& bbackupd_conf_file)
+{
+ TEST_THAT_OR(bbackupd_pid == 0, FAIL);
+
+ std::string cmd = BBACKUPD " " + bbackupd_args + " " + bbackupd_conf_file;
+ bbackupd_pid = LaunchServer(cmd.c_str(), "testfiles/bbackupd.pid");
+
+ TEST_THAT_OR(bbackupd_pid != -1 && bbackupd_pid != 0, FAIL);
+ ::sleep(1);
+ TEST_THAT_OR(ServerIsAlive(bbackupd_pid), FAIL);
+
+ return true;
+}
+
+bool StopClient(bool wait_for_process)
+{
+ TEST_THAT_OR(bbackupd_pid != 0, FAIL);
+ TEST_THAT_OR(ServerIsAlive(bbackupd_pid), FAIL);
+ TEST_THAT_OR(KillServer(bbackupd_pid, wait_for_process), FAIL);
+ ::sleep(1);
+
+ TEST_THAT_OR(!ServerIsAlive(bbackupd_pid), FAIL);
+ bbackupd_pid = 0;
+ #ifdef WIN32
+ int unlink_result = unlink("testfiles/bbackupd.pid");
+ TEST_EQUAL_LINE(0, unlink_result, "unlink testfiles/bbackupd.pid");
+ if(unlink_result != 0)
+ {
+ FAIL;
+ }
+ #else
+ TestRemoteProcessMemLeaks("bbackupd.memleaks");
+ #endif
+
+ return true;
+}