diff options
author | Chris Wilson <chris+github@qwirx.com> | 2015-07-01 19:40:41 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2015-07-01 19:40:41 +0000 |
commit | a834d2e9ff08343d3df5a466f41d0c3e7072a984 (patch) | |
tree | d88f16f40a76fd2d75818d6993df58851b240bc0 /test | |
parent | fb9042ed02544a1a783b2ffa6b5ea7e85a16a703 (diff) |
Major test refactor to support test suites.
Refactor all common code from testbbackupd and testbackupstore to allow other
test suites to contain multiple tests and execute selected tests more easily.
Report all test results within a suite in a standard, easy to read summary.
Diffstat (limited to 'test')
-rw-r--r-- | test/backupstore/testbackupstore.cpp | 137 | ||||
-rw-r--r-- | test/backupstorefix/testbackupstorefix.cpp | 2 | ||||
-rw-r--r-- | test/bbackupd/testbbackupd.cpp | 170 |
3 files changed, 126 insertions, 183 deletions
diff --git a/test/backupstore/testbackupstore.cpp b/test/backupstore/testbackupstore.cpp index 35e4ae6f..fadbc7ad 100644 --- a/test/backupstore/testbackupstore.cpp +++ b/test/backupstore/testbackupstore.cpp @@ -140,6 +140,35 @@ static const char *uploads_filenames[] = {"49587fds", "cvhjhj324", "sdfcscs324", #define UNLINK_IF_EXISTS(filename) \ if (FileExists(filename)) { TEST_THAT(unlink(filename) == 0); } +//! Simplifies calling setUp() with the current function name in each test. +#define SETUP_TEST_BACKUPSTORE() \ + SETUP(); \ + if (ServerIsAlive(bbstored_pid)) \ + TEST_THAT_OR(StopServer(), FAIL); \ + ExpectedRefCounts.resize(BACKUPSTORE_ROOT_DIRECTORY_ID + 1); \ + set_refcount(BACKUPSTORE_ROOT_DIRECTORY_ID, 1); \ + TEST_THAT_OR(create_account(10000, 20000), FAIL); + +//! Checks account for errors and shuts down daemons at end of every test. +bool teardown_test_backupstore() +{ + bool status = true; + + if (FileExists("testfiles/0_0/backup/01234567/info.rf")) + { + TEST_THAT_OR(check_reference_counts(), status = false); + TEST_THAT_OR(check_account(), status = false); + } + + return status; +} + +#define TEARDOWN_TEST_BACKUPSTORE() \ + if (ServerIsAlive(bbstored_pid)) \ + StopServer(); \ + TEST_THAT(teardown_test_backupstore()); \ + TEARDOWN(); + // Nice random data for testing written files class R250 { public: @@ -239,36 +268,9 @@ void CheckEntries(BackupStoreDirectory &rDir, int16_t FlagsMustBeSet, int16_t Fl TEST_THAT(DIR_NUM == SkipEntries(e, FlagsMustBeSet, FlagsNotToBeSet)); } -int num_tests_selected = 0; - -//! Simplifies calling setUp() with the current function name in each test. -#define SETUP() \ - if (!setUp(__FUNCTION__)) return true; \ - num_tests_selected++; - -//! Checks account for errors and shuts down daemons at end of every test. -bool teardown_test_backupstore() -{ - bool status = tearDown(); - - if (FileExists("testfiles/0_0/backup/01234567/info.rf")) - { - TEST_THAT_OR(check_reference_counts(), status = false); - TEST_THAT_OR(check_account(), status = false); - } - - return status; -} - -#define FAIL { \ - std::ostringstream os; \ - os << "failed at " << __FUNCTION__ << ":" << __LINE__; \ - return fail(); \ -} - bool test_filename_encoding() { - SETUP(); + SETUP_TEST_BACKUPSTORE(); // test some basics -- encoding and decoding filenames { @@ -349,12 +351,12 @@ bool test_filename_encoding() } } - return teardown_test_backupstore(); + TEARDOWN_TEST_BACKUPSTORE(); } bool test_backupstore_directory() { - SETUP(); + SETUP_TEST_BACKUPSTORE(); { // Now play with directories @@ -435,7 +437,7 @@ bool test_backupstore_directory() } } - return teardown_test_backupstore(); + TEARDOWN_TEST_BACKUPSTORE(); } void write_test_file(int t) @@ -798,7 +800,7 @@ bool run_housekeeping_and_check_account(BackupProtocolLocal2& protocol) bool test_temporary_refcount_db_is_independent() { - SETUP(); + SETUP_TEST_BACKUPSTORE(); std::auto_ptr<BackupStoreAccountDatabase> apAccounts( BackupStoreAccountDatabase::Read("testfiles/accounts.txt")); @@ -826,12 +828,12 @@ bool test_temporary_refcount_db_is_independent() // test failure. perm.reset(); - return teardown_test_backupstore(); + TEARDOWN_TEST_BACKUPSTORE(); } bool test_server_housekeeping() { - SETUP(); + SETUP_TEST_BACKUPSTORE(); int encfile[ENCFILE_SIZE]; { @@ -1161,7 +1163,7 @@ bool test_server_housekeeping() TEST_THAT(run_housekeeping_and_check_account()); ExpectedRefCounts.resize(3); // stop test failure in teardown_test_backupstore() - return teardown_test_backupstore(); + TEARDOWN_TEST_BACKUPSTORE(); } int64_t create_directory(BackupProtocolCallable& protocol, int64_t parent_dir_id) @@ -1239,7 +1241,7 @@ int64_t assert_readonly_connection_succeeds(BackupProtocolCallable& protocol) bool test_multiple_uploads() { - SETUP(); + SETUP_TEST_BACKUPSTORE(); TEST_THAT_OR(StartServer(), FAIL); std::auto_ptr<BackupProtocolCallable> apProtocol = @@ -1512,12 +1514,12 @@ bool test_multiple_uploads() apProtocol->QueryFinished(); protocolReadOnly.QueryFinished(); - return teardown_test_backupstore(); + TEARDOWN_TEST_BACKUPSTORE(); } bool test_server_commands() { - SETUP(); + SETUP_TEST_BACKUPSTORE(); std::auto_ptr<BackupProtocolLocal2> apProtocol( new BackupProtocolLocal2(0x01234567, "test", @@ -1971,7 +1973,7 @@ bool test_server_commands() TEST_THAT(check_reference_counts()); } - return teardown_test_backupstore(); + TEARDOWN_TEST_BACKUPSTORE(); } int get_object_size(BackupProtocolCallable& protocol, int64_t ObjectID, @@ -2004,7 +2006,7 @@ bool write_dir(BackupStoreDirectory& dir) bool test_directory_parent_entry_tracks_directory_size() { - SETUP(); + SETUP_TEST_BACKUPSTORE(); BackupProtocolLocal2 protocol(0x01234567, "test", "backup/01234567/", 0, false); @@ -2163,12 +2165,12 @@ bool test_directory_parent_entry_tracks_directory_size() BACKUPSTORE_ROOT_DIRECTORY_ID)); protocolReadOnly.QueryFinished(); - return teardown_test_backupstore(); + TEARDOWN_TEST_BACKUPSTORE(); } bool test_cannot_open_multiple_writable_connections() { - SETUP(); + SETUP_TEST_BACKUPSTORE(); // First try a local protocol. This works even on Windows. BackupProtocolLocal2 protocolWritable(0x01234567, "test", @@ -2207,7 +2209,7 @@ bool test_cannot_open_multiple_writable_connections() } protocolWritable.QueryFinished(); - return teardown_test_backupstore(); + TEARDOWN_TEST_BACKUPSTORE(); } bool test_encoding() @@ -2216,7 +2218,7 @@ bool test_encoding() // TODO: This test needs to check failure situations as well as everything working, // but this will be saved for the full implementation. - SETUP(); + SETUP_TEST_BACKUPSTORE(); int encfile[ENCFILE_SIZE]; { @@ -2367,13 +2369,13 @@ bool test_encoding() } } - return teardown_test_backupstore(); + TEARDOWN_TEST_BACKUPSTORE(); } bool test_symlinks() { #ifndef WIN32 // no symlinks on Win32 - SETUP(); + SETUP_TEST_BACKUPSTORE(); // TODO FIXME indentation @@ -2397,12 +2399,12 @@ bool test_symlinks() teardown_test_backupstore(); #endif - return true; + TEARDOWN_TEST_BACKUPSTORE(); } bool test_store_info() { - SETUP(); + SETUP_TEST_BACKUPSTORE(); { RaidFileWrite::CreateDirectory(0, "test-info"); @@ -2451,14 +2453,14 @@ bool test_store_info() TEST_THAT(delfiles[1] == 4); } - return teardown_test_backupstore(); + TEARDOWN_TEST_BACKUPSTORE(); } bool test_login_without_account() { // First, try logging in without an account having been created... just make sure login fails. - SETUP(); + SETUP_TEST_BACKUPSTORE(); delete_account(); TEST_THAT_OR(StartServer(), FAIL); @@ -2482,12 +2484,12 @@ bool test_login_without_account() // Recreate the account so that teardown_test_backupstore() doesn't freak out // TEST_THAT_THROWONFAIL(create_account(10000, 20000)); - return teardown_test_backupstore(); + TEARDOWN_TEST_BACKUPSTORE(); } bool test_bbstoreaccounts_create() { - SETUP(); + SETUP_TEST_BACKUPSTORE(); // Delete the account, and create it again using bbstoreaccounts delete_account(); @@ -2497,12 +2499,12 @@ bool test_bbstoreaccounts_create() "10000B 20000B") == 0, FAIL); TestRemoteProcessMemLeaks("bbstoreaccounts.memleaks"); - return teardown_test_backupstore(); + TEARDOWN_TEST_BACKUPSTORE(); } bool test_bbstoreaccounts_delete() { - SETUP(); + SETUP_TEST_BACKUPSTORE(); TEST_THAT_OR(::system(BBSTOREACCOUNTS " -c testfiles/bbstored.conf -Wwarning delete 01234567 yes") == 0, FAIL); TestRemoteProcessMemLeaks("bbstoreaccounts.memleaks"); @@ -2510,13 +2512,13 @@ bool test_bbstoreaccounts_delete() // Recreate the account so that teardown_test_backupstore() doesn't freak out TEST_THAT(create_account(10000, 20000)); - return teardown_test_backupstore(); + TEARDOWN_TEST_BACKUPSTORE(); } // Test that login fails on a disabled account bool test_login_with_disabled_account() { - SETUP(); + SETUP_TEST_BACKUPSTORE(); TEST_THAT_OR(StartServer(), FAIL); TEST_THAT(TestDirExists("testfiles/0_0/backup/01234567")); @@ -2557,12 +2559,12 @@ bool test_login_with_disabled_account() protocol.QueryFinished(); } - return teardown_test_backupstore(); + TEARDOWN_TEST_BACKUPSTORE(); } bool test_login_with_no_refcount_db() { - SETUP(); + SETUP_TEST_BACKUPSTORE(); // The account is already enabled, but doing it again shouldn't hurt TEST_THAT_OR(::system(BBSTOREACCOUNTS @@ -2612,14 +2614,14 @@ bool test_login_with_no_refcount_db() // And that we can log in afterwards connect_and_login(context)->QueryFinished(); - return teardown_test_backupstore(); + TEARDOWN_TEST_BACKUPSTORE(); } bool test_housekeeping_deletes_files() { // Test the deletion of objects by the housekeeping system - SETUP(); + SETUP_TEST_BACKUPSTORE(); BackupProtocolLocal2 protocolLocal(0x01234567, "test", "backup/01234567/", 0, false); // Not read-only @@ -2669,12 +2671,12 @@ bool test_housekeeping_deletes_files() // catches if we don't delete the account. delete_account(); - return teardown_test_backupstore(); + TEARDOWN_TEST_BACKUPSTORE(); } bool test_account_limits_respected() { - SETUP(); + SETUP_TEST_BACKUPSTORE(); TEST_THAT_OR(StartServer(), FAIL); // Set a really small hard limit @@ -2717,7 +2719,7 @@ bool test_account_limits_respected() apProtocol->QueryFinished(); } - return teardown_test_backupstore(); + TEARDOWN_TEST_BACKUPSTORE(); } int multi_server() @@ -2858,7 +2860,7 @@ void compare_backupstoreinfo_values_to_expected bool test_read_old_backupstoreinfo_files() { - SETUP(); + SETUP_TEST_BACKUPSTORE(); // Create an account for the test client std::auto_ptr<BackupStoreInfo> apInfo = BackupStoreInfo::Load(0x1234567, @@ -3060,7 +3062,7 @@ bool test_read_old_backupstoreinfo_files() apInfo.reset(); TEST_THAT(delete_account()); - return teardown_test_backupstore(); + TEARDOWN_TEST_BACKUPSTORE(); } int test(int argc, const char *argv[]) @@ -3130,9 +3132,6 @@ int test(int argc, const char *argv[]) TEST_THAT(test_multiple_uploads()); TEST_THAT(test_housekeeping_deletes_files()); - TEST_LINE(num_tests_selected > 0, "No tests matched the patterns " - "specified on the command line"); - - return (failures == 0 && num_tests_selected > 0) ? 0 : 1; + return finish_test_suite(); } diff --git a/test/backupstorefix/testbackupstorefix.cpp b/test/backupstorefix/testbackupstorefix.cpp index d13563d9..a39ca60a 100644 --- a/test/backupstorefix/testbackupstorefix.cpp +++ b/test/backupstorefix/testbackupstorefix.cpp @@ -582,8 +582,6 @@ int test(int argc, const char *argv[]) TEST_THAT(dir.FindEntryByID(0x1234567890123456LL) == 0); } - if (failures > 0) return 1; - // Generate a list of all the object IDs TEST_THAT_ABORTONFAIL(::system(BBACKUPQUERY " -Wwarning " "-c testfiles/bbackupd.conf \"list -R\" quit " diff --git a/test/bbackupd/testbbackupd.cpp b/test/bbackupd/testbbackupd.cpp index 496c84f7..69046f0f 100644 --- a/test/bbackupd/testbbackupd.cpp +++ b/test/bbackupd/testbbackupd.cpp @@ -93,16 +93,6 @@ #define SHORT_TIMEOUT 5000 #define BACKUP_ERROR_DELAY_SHORTENED 10 -std::string current_test_name; -std::map<std::string, std::string> s_test_status; - -#define FAIL { \ - std::ostringstream os; \ - os << "failed at " << __FUNCTION__ << ":" << __LINE__; \ - s_test_status[current_test_name] = os.str(); \ - return fail(); \ -} - void wait_for_backup_operation(const char* message) { wait_for_operation(TIME_TO_WAIT_FOR_BACKUP_OPERATION, message); @@ -465,66 +455,32 @@ bool setup_test_bbackupd(BackupDaemon& bbackupd, bool do_unpack_files = true, return true; } -int num_tests_selected = 0; - //! Simplifies calling setUp() with the current function name in each test. -#define SETUP() \ - if (!setUp(__FUNCTION__)) return true; \ - num_tests_selected++; \ - int old_failure_count = failures; \ +#define SETUP_TEST_BBACKUPD() \ + SETUP(); \ TEST_THAT(kill_running_daemons()); \ - try \ - { // left open + TEST_THAT(create_account(10000, 20000)); #define SETUP_WITHOUT_FILES() \ - SETUP() \ + SETUP_TEST_BBACKUPD() \ BackupDaemon bbackupd; \ TEST_THAT_OR(setup_test_bbackupd(bbackupd, false), FAIL); \ TEST_THAT_OR(::mkdir("testfiles/TestDir1", 0755) == 0, FAIL); #define SETUP_WITH_BBSTORED() \ - SETUP() \ + SETUP_TEST_BBACKUPD() \ BackupDaemon bbackupd; \ TEST_THAT_OR(setup_test_bbackupd(bbackupd), FAIL); -//! Checks account for errors and shuts down daemons at end of every test. -bool teardown_test_bbackupd(std::string test_name, int old_failure_count) -{ - if (failures == old_failure_count) - { - BOX_NOTICE(test_name << " passed"); - s_test_status[test_name] = "passed"; - } - else - { - BOX_NOTICE(test_name << " failed"); \ - s_test_status[test_name] = "FAILED"; - } - - if(bbackupd_pid != 0) - { - TEST_THAT(StopClient()); - } - - return tearDown(); -} - -#define TEARDOWN() \ - return teardown_test_bbackupd(__FUNCTION__, old_failure_count); \ - } \ - catch (BoxException &e) \ - { \ - BOX_NOTICE(__FUNCTION__ << " errored: " << e.what()); \ - failures++; \ - bool status = teardown_test_bbackupd(__FUNCTION__, old_failure_count); \ - s_test_status[__FUNCTION__] = "ERRORED"; \ - return status; \ - } - +#define TEARDOWN_TEST_BBACKUPD() \ + TEST_THAT(bbackupd_pid == 0 || StopClient()); \ + TEST_THAT(bbstored_pid == 0 || StopServer()); \ + TEST_THAT(kill_running_daemons()); \ + TEARDOWN(); bool test_basics() { - SETUP(); + SETUP_TEST_BBACKUPD(); TEST_THAT_OR(unpack_files("test_base"), FAIL); // Read attributes from files @@ -644,7 +600,7 @@ bool test_basics() finish_with_write_xattr_test(); #endif // HAVE_SYS_XATTR_H - TEARDOWN(); + TEARDOWN_TEST_BBACKUPD(); } int64_t GetDirID(BackupProtocolCallable &protocol, const char *name, int64_t InDirectory) @@ -1206,7 +1162,7 @@ bool test_readdirectory_on_nonexistent_dir() client->QueryFinished(); } - TEARDOWN(); + TEARDOWN_TEST_BBACKUPD(); } bool test_bbackupquery_parser_escape_slashes() @@ -1246,7 +1202,7 @@ bool test_bbackupquery_parser_escape_slashes() TEST_EQUAL(bar_id, query.FindDirectoryObjectID("\\/bar")); connection.QueryFinished(); - TEARDOWN(); + TEARDOWN_TEST_BBACKUPD(); } bool test_getobject_on_nonexistent_file() @@ -1278,7 +1234,7 @@ bool test_getobject_on_nonexistent_file() } } - TEARDOWN(); + TEARDOWN_TEST_BBACKUPD(); } // ASSERT((mpBlockIndex == 0) || (NumBlocksInIndex != 0)) in @@ -1288,7 +1244,7 @@ bool test_getobject_on_nonexistent_file() bool test_replace_zero_byte_file_with_nonzero_byte_file() { - SETUP(); + SETUP_TEST_BBACKUPD(); TEST_THAT_OR(mkdir("testfiles/TestDir1", 0755) == 0, FAIL); FileStream emptyFile("testfiles/TestDir1/f2", @@ -1310,7 +1266,7 @@ bool test_replace_zero_byte_file_with_nonzero_byte_file() bbackupd.RunSyncNow(); TEST_COMPARE_LOCAL(Compare_Same, client); - TEARDOWN(); + TEARDOWN_TEST_BBACKUPD(); } // This caused the issue reported by Brendon Baumgartner and described in my @@ -1429,7 +1385,7 @@ bool test_backup_disappearing_directory() clientContext.CloseAnyOpenConnection(); TEST_COMPARE(Compare_Same); - TEARDOWN(); + TEARDOWN_TEST_BBACKUPD(); } // TODO FIXME check that directory modtimes are backed up by BackupClientDirectoryRecord. @@ -1441,7 +1397,7 @@ bool test_ssl_keepalives() #ifdef PLATFORM_CLIB_FNS_INTERCEPTION_IMPOSSIBLE BOX_NOTICE("Skipping intercept-based KeepAlive tests on this platform"); #else - // Delete the test_base files unpacked by SETUP() + // Delete the test_base files unpacked by SETUP_TEST_BBACKUPD() TEST_THAT(::system("rm -r testfiles/TestDir1") == 0); // Unpack spacetest files instead TEST_THAT(::mkdir("testfiles/TestDir1", 0755) == 0); @@ -1749,7 +1705,7 @@ bool test_ssl_keepalives() } #endif // PLATFORM_CLIB_FNS_INTERCEPTION_IMPOSSIBLE - TEARDOWN(); + TEARDOWN_TEST_BBACKUPD(); } bool test_backup_hardlinked_files() @@ -1782,7 +1738,7 @@ bool test_backup_hardlinked_files() bbackupd.RunSyncNow(); TEST_COMPARE(Compare_Same); - TEARDOWN(); + TEARDOWN_TEST_BBACKUPD(); } bool test_backup_pauses_when_store_is_full() @@ -1912,7 +1868,7 @@ bool test_backup_pauses_when_store_is_full() wait_for_sync_end(); TEST_COMPARE(Compare_Same); - TEARDOWN(); + TEARDOWN_TEST_BBACKUPD(); } bool test_bbackupd_exclusions() @@ -2145,7 +2101,7 @@ bool test_bbackupd_exclusions() } } - TEARDOWN(); + TEARDOWN_TEST_BBACKUPD(); } bool test_bbackupd_uploads_files() @@ -2164,12 +2120,12 @@ bool test_bbackupd_uploads_files() // Check that no read error has been reported yet TEST_THAT(!TestFileExists("testfiles/notifyran.read-error.1")); - TEARDOWN(); + TEARDOWN_TEST_BBACKUPD(); } bool test_bbackupd_responds_to_connection_failure() { - SETUP(); + SETUP_TEST_BBACKUPD(); TEST_THAT_OR(unpack_files("test_base"), FAIL); #ifdef WIN32 @@ -2262,7 +2218,7 @@ bool test_bbackupd_responds_to_connection_failure() } #endif // !WIN32 - TEARDOWN(); + TEARDOWN_TEST_BBACKUPD(); } bool test_absolute_symlinks_not_followed_during_restore() @@ -2345,7 +2301,7 @@ bool test_absolute_symlinks_not_followed_during_restore() } #endif - TEARDOWN(); + TEARDOWN_TEST_BBACKUPD(); } // Testing that nonexistent locations are backed up if they are created later @@ -2401,7 +2357,7 @@ bool test_initially_missing_locations_are_not_forgotten() // BLOCK TEST_THAT_OR(search_for_file("Test2"), FAIL); - TEARDOWN(); + TEARDOWN_TEST_BBACKUPD(); } bool test_redundant_locations_deleted_on_time() @@ -2447,7 +2403,7 @@ bool test_redundant_locations_deleted_on_time() TEST_THAT(test_entry_deleted(*root_dir, "Test2")); } - TEARDOWN(); + TEARDOWN_TEST_BBACKUPD(); } // Check that read-only directories and their contents can be restored. @@ -2502,7 +2458,7 @@ bool test_read_only_dirs_can_be_restored() } } - TEARDOWN(); + TEARDOWN_TEST_BBACKUPD(); } // Check that filenames in UTF-8 can be backed up @@ -2739,7 +2695,7 @@ bool test_unicode_filenames_can_be_backed_up() } #endif // WIN32 - TEARDOWN(); + TEARDOWN_TEST_BBACKUPD(); } bool test_sync_allow_script_can_pause_backup() @@ -2841,7 +2797,7 @@ bool test_sync_allow_script_can_pause_backup() TEST_THAT(!TestFileExists("testfiles/notifyran.read-error.1")); } - TEARDOWN(); + TEARDOWN_TEST_BBACKUPD(); } // Delete file and update another, create symlink. @@ -2890,7 +2846,7 @@ bool test_delete_update_and_symlink_files() TEST_COMPARE(Compare_Same, "", "-acqQ"); } - TEARDOWN(); + TEARDOWN_TEST_BBACKUPD(); } // Check that store errors are reported neatly. This test uses an independent @@ -3090,7 +3046,7 @@ bool test_store_error_reporting() TEST_THAT(::unlink("testfiles/notifyscript.tag") == 0); } - TEARDOWN(); + TEARDOWN_TEST_BBACKUPD(); } bool test_change_file_to_symlink_and_back() @@ -3194,7 +3150,7 @@ bool test_change_file_to_symlink_and_back() TEST_COMPARE(Compare_Same); } - TEARDOWN(); + TEARDOWN_TEST_BBACKUPD(); } bool test_file_rename_tracking() @@ -3290,7 +3246,7 @@ bool test_file_rename_tracking() TEST_THAT(!TestFileExists("testfiles/notifyran.read-error.1")); } - TEARDOWN(); + TEARDOWN_TEST_BBACKUPD(); } // Files that suddenly appear, with timestamps before the last sync window, @@ -3368,14 +3324,13 @@ bool test_upload_very_old_files() TEST_THAT(!TestFileExists("testfiles/notifyran.read-error.1")); } - TEARDOWN(); + TEARDOWN_TEST_BBACKUPD(); } bool test_excluded_files_are_not_backed_up() { // SETUP_WITH_BBSTORED(); - - SETUP() + SETUP_TEST_BBACKUPD(); BackupProtocolLocal2 client(0x01234567, "test", "backup/01234567/", 0, false); @@ -3439,7 +3394,7 @@ bool test_excluded_files_are_not_backed_up() } } - TEARDOWN(); + TEARDOWN_TEST_BBACKUPD(); } bool test_read_error_reporting() @@ -3499,7 +3454,7 @@ bool test_read_error_reporting() } #endif - TEARDOWN(); + TEARDOWN_TEST_BBACKUPD(); } bool test_continuously_updated_file() @@ -3558,7 +3513,7 @@ bool test_continuously_updated_file() } } - TEARDOWN(); + TEARDOWN_TEST_BBACKUPD(); } bool test_delete_dir_change_attribute() @@ -3584,7 +3539,7 @@ bool test_delete_dir_change_attribute() TEST_COMPARE(Compare_Same); } - TEARDOWN(); + TEARDOWN_TEST_BBACKUPD(); } bool test_restore_files_and_directories() @@ -3673,7 +3628,7 @@ bool test_restore_files_and_directories() TEST_COMPARE(Compare_Same); } - TEARDOWN(); + TEARDOWN_TEST_BBACKUPD(); } bool test_compare_detects_attribute_changes() @@ -3741,7 +3696,7 @@ bool test_compare_detects_attribute_changes() } #endif // WIN32 - TEARDOWN(); + TEARDOWN_TEST_BBACKUPD(); } bool test_sync_new_files() @@ -3770,7 +3725,7 @@ bool test_sync_new_files() TEST_COMPARE(Compare_Same); } - TEARDOWN(); + TEARDOWN_TEST_BBACKUPD(); } bool test_rename_operations() @@ -3804,7 +3759,7 @@ bool test_rename_operations() TEST_COMPARE(Compare_Same); } - TEARDOWN(); + TEARDOWN_TEST_BBACKUPD(); } // Check that modifying files with madly in the future timestamps still get added @@ -3839,7 +3794,7 @@ bool test_sync_files_with_timestamps_in_future() TEST_COMPARE(Compare_Same); } - TEARDOWN(); + TEARDOWN_TEST_BBACKUPD(); } // Check change of store marker pauses daemon @@ -3959,7 +3914,7 @@ bool test_changing_client_store_marker_pauses_daemon() BOX_TRACE("Compare finished, expected no differences"); } - TEARDOWN(); + TEARDOWN_TEST_BBACKUPD(); } bool test_interrupted_restore_can_be_recovered() @@ -4021,7 +3976,7 @@ bool test_interrupted_restore_can_be_recovered() } #endif // !WIN32 - TEARDOWN(); + TEARDOWN_TEST_BBACKUPD(); } bool assert_x1_deleted_or_not(bool expected_deleted) @@ -4099,7 +4054,7 @@ bool test_restore_deleted_files() // should have been undeleted by restore TEST_THAT(assert_x1_deleted_or_not(false)); - TEARDOWN(); + TEARDOWN_TEST_BBACKUPD(); } bool test_locked_file_behaviour() @@ -4158,7 +4113,7 @@ bool test_locked_file_behaviour() } #endif // WIN32 - TEARDOWN(); + TEARDOWN_TEST_BBACKUPD(); } bool test_backup_many_files() @@ -4174,12 +4129,12 @@ bool test_backup_many_files() bbackupd.RunSyncNow(); TEST_COMPARE(Compare_Same); - TEARDOWN(); + TEARDOWN_TEST_BBACKUPD(); } bool test_parse_incomplete_command() { - SETUP(); + SETUP_TEST_BBACKUPD(); { // This is not a complete command, it should not parse! @@ -4189,12 +4144,12 @@ bool test_parse_incomplete_command() TEST_EQUAL(0, cmd.mCompleteArgCount); } - TEARDOWN(); + TEARDOWN_TEST_BBACKUPD(); } bool test_parse_syncallowscript_output() { - SETUP(); + SETUP_TEST_BBACKUPD(); { BackupDaemon daemon; @@ -4209,7 +4164,7 @@ bool test_parse_syncallowscript_output() TEST_EQUAL(0, daemon.GetMaxBandwidthFromSyncAllowScript()); } - TEARDOWN(); + TEARDOWN_TEST_BBACKUPD(); } int test(int argc, const char *argv[]) @@ -4278,12 +4233,7 @@ int test(int argc, const char *argv[]) TEST_THAT(test_parse_incomplete_command()); TEST_THAT(test_parse_syncallowscript_output()); - typedef std::map<std::string, std::string>::iterator s_test_status_iterator; - for(s_test_status_iterator i = s_test_status.begin(); - i != s_test_status.end(); i++) - { - BOX_NOTICE("test result: " << i->second << ": " << i->first); - } + TEST_THAT(kill_running_daemons()); #ifndef WIN32 if(::getuid() == 0) @@ -4292,9 +4242,5 @@ int test(int argc, const char *argv[]) } #endif - TEST_LINE(num_tests_selected > 0, "No tests matched the patterns " - "specified on the command line"); - TEST_THAT(kill_running_daemons()); - - return (failures == 0 && num_tests_selected > 0) ? 0 : 1; + return finish_test_suite(); } |