From 86dcc235fd56423b50b7bd5d7064bd61d4a71b53 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Fri, 26 Dec 2014 23:16:59 +0000 Subject: Catch exceptions in individual tests and clean up nicely. This stops stale daemons from hanging around if a single test fails because it throws an exception, which otherwise would cause the whole suite to abort immediately without cleaning up after itself. --- test/bbackupd/testbbackupd.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'test/bbackupd') diff --git a/test/bbackupd/testbbackupd.cpp b/test/bbackupd/testbbackupd.cpp index 21aa7520..190b3930 100644 --- a/test/bbackupd/testbbackupd.cpp +++ b/test/bbackupd/testbbackupd.cpp @@ -472,7 +472,9 @@ int num_tests_selected = 0; if (!setUp(__FUNCTION__)) return true; \ num_tests_selected++; \ int old_failure_count = failures; \ - TEST_THAT(kill_running_daemons()); + TEST_THAT(kill_running_daemons()); \ + try \ + { // left open #define SETUP_WITHOUT_FILES() \ SETUP() \ @@ -508,7 +510,16 @@ bool teardown_test_bbackupd(std::string test_name, int old_failure_count) } #define TEARDOWN() \ - return teardown_test_bbackupd(__FUNCTION__, old_failure_count); + return teardown_test_bbackupd(__FUNCTION__, old_failure_count); \ + } \ + catch (BoxException &e) \ + { \ + BOX_NOTICE(__FUNCTION__ << " errored: " << e.what()); \ + bool status = teardown_test_bbackupd(__FUNCTION__, old_failure_count); \ + s_test_status[__FUNCTION__] = "ERRORED"; \ + return status; \ + } + bool test_basics() { -- cgit v1.2.3