diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/backupstore/testbackupstore.cpp | 8 | ||||
-rw-r--r-- | test/backupstorefix/testbackupstorefix.cpp | 2 | ||||
-rw-r--r-- | test/backupstorepatch/testbackupstorepatch.cpp | 2 | ||||
-rw-r--r-- | test/basicserver/testbasicserver.cpp | 2 | ||||
-rw-r--r-- | test/bbackupd/testbbackupd.cpp | 56 | ||||
-rw-r--r-- | test/httpserver/testhttpserver.cpp | 7 | ||||
-rw-r--r-- | test/raidfile/testraidfile.cpp | 10 |
7 files changed, 47 insertions, 40 deletions
diff --git a/test/backupstore/testbackupstore.cpp b/test/backupstore/testbackupstore.cpp index 891d1461..3330bf67 100644 --- a/test/backupstore/testbackupstore.cpp +++ b/test/backupstore/testbackupstore.cpp @@ -139,7 +139,7 @@ static const char *uploads_filenames[] = {"49587fds", "cvhjhj324", "sdfcscs324", #define UPLOAD_FILE_TO_MOVE 8 #define UNLINK_IF_EXISTS(filename) \ - if (FileExists(filename)) { TEST_THAT(unlink(filename) == 0); } + if (FileExists(filename)) { TEST_THAT(EMU_UNLINK(filename) == 0); } //! Simplifies calling setUp() with the current function name in each test. #define SETUP_TEST_BACKUPSTORE() \ @@ -496,7 +496,7 @@ void test_test_file(int t, IOStream &rStream) free(data); in.Close(); - TEST_THAT(unlink("testfiles/test_download") == 0); + TEST_THAT(EMU_UNLINK("testfiles/test_download") == 0); } void assert_everything_deleted(BackupProtocolCallable &protocol, int64_t DirID) @@ -2665,7 +2665,7 @@ bool test_login_with_no_refcount_db() // Delete the refcount database and try to log in again. Check that // we're locked out of the account until housekeeping has recreated // the refcount db. - TEST_EQUAL(0, ::unlink("testfiles/0_0/backup/01234567/refcount.rdb.rfw")); + TEST_EQUAL(0, EMU_UNLINK("testfiles/0_0/backup/01234567/refcount.rdb.rfw")); TEST_CHECK_THROWS(BackupProtocolLocal2 protocolLocal(0x01234567, "test", "backup/01234567/", 0, false), // Not read-only BackupStoreException, CorruptReferenceCountDatabase); @@ -2690,7 +2690,7 @@ bool test_login_with_no_refcount_db() // because housekeeping may fix the refcount database while we're // stepping through. TEST_THAT_THROWONFAIL(StartServer()); - TEST_EQUAL(0, ::unlink("testfiles/0_0/backup/01234567/refcount.rdb.rfw")); + TEST_EQUAL(0, EMU_UNLINK("testfiles/0_0/backup/01234567/refcount.rdb.rfw")); TEST_CHECK_THROWS(connect_and_login(context), ConnectionException, Protocol_UnexpectedReply); diff --git a/test/backupstorefix/testbackupstorefix.cpp b/test/backupstorefix/testbackupstorefix.cpp index ac1d0c14..79fd68e1 100644 --- a/test/backupstorefix/testbackupstorefix.cpp +++ b/test/backupstorefix/testbackupstorefix.cpp @@ -1013,7 +1013,7 @@ int test(int argc, const char *argv[]) TEST_THAT(KillServer(bbstored_pid)); #ifdef WIN32 - TEST_THAT(unlink("testfiles/bbstored.pid") == 0); + TEST_THAT(EMU_UNLINK("testfiles/bbstored.pid") == 0); #else TestRemoteProcessMemLeaks("bbstored.memleaks"); #endif diff --git a/test/backupstorepatch/testbackupstorepatch.cpp b/test/backupstorepatch/testbackupstorepatch.cpp index 46f278ad..c26788dc 100644 --- a/test/backupstorepatch/testbackupstorepatch.cpp +++ b/test/backupstorepatch/testbackupstorepatch.cpp @@ -559,7 +559,7 @@ int test(int argc, const char *argv[]) char filename[64], filename_fetched[64]; ::sprintf(filename, "testfiles/%d.test", f); ::sprintf(filename_fetched, "testfiles/%d.test.fetched", f); - ::unlink(filename_fetched); + EMU_UNLINK(filename_fetched); // Fetch the file { diff --git a/test/basicserver/testbasicserver.cpp b/test/basicserver/testbasicserver.cpp index 9285dfc9..b940b30f 100644 --- a/test/basicserver/testbasicserver.cpp +++ b/test/basicserver/testbasicserver.cpp @@ -663,7 +663,7 @@ int test(int argc, const char *argv[]) // Move the config file over #ifdef WIN32 - TEST_THAT(::unlink("testfiles" + TEST_THAT(EMU_UNLINK("testfiles" DIRECTORY_SEPARATOR "srv1.conf") != -1); #endif diff --git a/test/bbackupd/testbbackupd.cpp b/test/bbackupd/testbbackupd.cpp index deff53e2..b2264b14 100644 --- a/test/bbackupd/testbbackupd.cpp +++ b/test/bbackupd/testbbackupd.cpp @@ -1272,6 +1272,13 @@ bool test_getobject_on_nonexistent_file() TEARDOWN_TEST_BBACKUPD(); } +void run_bbackupd_sync_with_logging(BackupDaemon& bbackupd) +{ + Logging::Tagger bbackupd_tagger("bbackupd", true); // replace + Logging::ShowTagOnConsole temp_enable_tags; + bbackupd.RunSyncNow(); +} + // ASSERT((mpBlockIndex == 0) || (NumBlocksInIndex != 0)) in // BackupStoreFileEncodeStream::Recipe::Recipe once failed, apparently because // a zero byte file had a block index but no entries in it. But this test @@ -1556,30 +1563,31 @@ bool test_backup_hardlinked_files() { SETUP_WITH_BBSTORED(); + run_bbackupd_sync_with_logging(bbackupd); bbackupd.RunSyncNow(); TEST_COMPARE(Compare_Same); // Create some hard links. First in the same directory: - TEST_THAT(link("testfiles/TestDir1/x1/dsfdsfs98.fd", + TEST_THAT(EMU_LINK("testfiles/TestDir1/x1/dsfdsfs98.fd", "testfiles/TestDir1/x1/hardlink1") == 0); - bbackupd.RunSyncNow(); + run_bbackupd_sync_with_logging(bbackupd); TEST_COMPARE(Compare_Same); - // Now in a different directory + BOX_NOTICE("Creating a hard-linked file in a different directory (x2/hardlink2)"); TEST_THAT(mkdir("testfiles/TestDir1/x2", 0755) == 0); - TEST_THAT(link("testfiles/TestDir1/x1/dsfdsfs98.fd", + TEST_THAT(EMU_LINK("testfiles/TestDir1/x1/dsfdsfs98.fd", "testfiles/TestDir1/x2/hardlink2") == 0); - bbackupd.RunSyncNow(); + run_bbackupd_sync_with_logging(bbackupd); TEST_COMPARE(Compare_Same); // Now delete one of them - TEST_THAT(unlink("testfiles/TestDir1/x1/dsfdsfs98.fd") == 0); + TEST_THAT(EMU_UNLINK("testfiles/TestDir1/x1/dsfdsfs98.fd") == 0); bbackupd.RunSyncNow(); TEST_COMPARE(Compare_Same); // And another. - TEST_THAT(unlink("testfiles/TestDir1/x1/hardlink1") == 0); - bbackupd.RunSyncNow(); + TEST_THAT(EMU_UNLINK("testfiles/TestDir1/x1/hardlink1") == 0); + run_bbackupd_sync_with_logging(bbackupd); TEST_COMPARE(Compare_Same); TEARDOWN_TEST_BBACKUPD(); @@ -1618,7 +1626,7 @@ bool test_backup_pauses_when_store_is_full() unpack_files("spacetest2", "testfiles/TestDir1"); // Delete a file and a directory - TEST_THAT(::unlink("testfiles/TestDir1/spacetest/f1") == 0); + TEST_THAT(EMU_UNLINK("testfiles/TestDir1/spacetest/f1") == 0); #ifdef WIN32 TEST_THAT(::system("rd /s/q testfiles\\TestDir1\\spacetest\\d7") == 0); #else @@ -1733,7 +1741,7 @@ bool test_bbackupd_exclusions() TEST_THAT(unpack_files("spacetest1", "testfiles/TestDir1")); // Delete a file and a directory - TEST_THAT(::unlink("testfiles/TestDir1/spacetest/f1") == 0); + TEST_THAT(EMU_UNLINK("testfiles/TestDir1/spacetest/f1") == 0); #ifdef WIN32 TEST_THAT(::system("rd /s/q testfiles\\TestDir1\\spacetest\\d7") == 0); @@ -2520,7 +2528,7 @@ bool test_unicode_filenames_can_be_backed_up() std::string fileToUnlink = "testfiles/restore-" + dirname + "/" + filename; - TEST_THAT(::unlink(fileToUnlink.c_str()) == 0); + TEST_THAT(EMU_UNLINK(fileToUnlink.c_str()) == 0); // Check that bbackupquery can get the file when given // on the command line in system encoding. @@ -2536,7 +2544,7 @@ bool test_unicode_filenames_can_be_backed_up() // cannot overwrite a file that exists, so delete it std::string tmp = "testfiles/" + filename; - TEST_THAT(::unlink(tmp.c_str()) == 0); + TEST_THAT(EMU_UNLINK(tmp.c_str()) == 0); // And after changing directory to an absolute path TEST_THAT(bbackupquery( @@ -2632,7 +2640,7 @@ bool test_sync_allow_script_can_pause_backup() // check that no backup has run (compare fails) TEST_COMPARE(Compare_Different); - TEST_THAT(unlink(sync_control_file) == 0); + TEST_THAT(EMU_UNLINK(sync_control_file) == 0); wait_for_sync_start(); long end_time = time(NULL); long wait_time = end_time - start_time + 2; @@ -2670,7 +2678,7 @@ bool test_delete_update_and_symlink_files() // TODO FIXME dedent { // Delete a file - TEST_THAT(::unlink("testfiles/TestDir1/x1/dsfdsfs98.fd") == 0); + TEST_THAT(EMU_UNLINK("testfiles/TestDir1/x1/dsfdsfs98.fd") == 0); #ifndef WIN32 // New symlink @@ -2825,7 +2833,7 @@ bool test_store_error_reporting() // Check that it did get uploaded, and we have no more errors TEST_COMPARE(Compare_Same); - TEST_THAT(::unlink("testfiles/notifyscript.tag") == 0); + TEST_THAT(EMU_UNLINK("testfiles/notifyscript.tag") == 0); // Stop the snapshot bbackupd TEST_THAT(StopClient()); @@ -2900,7 +2908,7 @@ bool test_store_error_reporting() // Check that it did get uploaded, and we have no more errors TEST_COMPARE(Compare_Same); - TEST_THAT(::unlink("testfiles/notifyscript.tag") == 0); + TEST_THAT(EMU_UNLINK("testfiles/notifyscript.tag") == 0); } TEARDOWN_TEST_BBACKUPD(); @@ -2924,7 +2932,7 @@ bool test_change_file_to_symlink_and_back() // Replace symlink with directory, add new directory. #ifndef WIN32 - TEST_THAT(::unlink("testfiles/TestDir1/symlink-to-dir") + TEST_THAT(EMU_UNLINK("testfiles/TestDir1/symlink-to-dir") == 0); #endif @@ -2949,7 +2957,7 @@ bool test_change_file_to_symlink_and_back() // And the inverse, replace a directory with a file/symlink #ifndef WIN32 - TEST_THAT(::unlink("testfiles/TestDir1/x1/dir-to-file" + TEST_THAT(EMU_UNLINK("testfiles/TestDir1/x1/dir-to-file" "/contents") == 0); #endif @@ -2968,7 +2976,7 @@ bool test_change_file_to_symlink_and_back() BOX_INFO("Replace symlink with directory (which was a symlink)"); #ifndef WIN32 - TEST_THAT(::unlink("testfiles/TestDir1/x1" + TEST_THAT(EMU_UNLINK("testfiles/TestDir1/x1" "/dir-to-file") == 0); #endif @@ -2991,7 +2999,7 @@ bool test_change_file_to_symlink_and_back() // directories over other old directories. #ifndef WIN32 - TEST_THAT(::unlink("testfiles/TestDir1/x1/dir-to-file" + TEST_THAT(EMU_UNLINK("testfiles/TestDir1/x1/dir-to-file" "/contents2") == 0); #endif @@ -3039,7 +3047,7 @@ bool test_file_rename_tracking() TEST_COMPARE(Compare_Same); #ifdef WIN32 - TEST_THAT(::unlink("testfiles/TestDir1/untracked-2") + TEST_THAT(EMU_UNLINK("testfiles/TestDir1/untracked-2") == 0); #endif @@ -3077,7 +3085,7 @@ bool test_file_rename_tracking() TEST_COMPARE(Compare_Same); #ifdef WIN32 - TEST_THAT(::unlink("testfiles/TestDir1/tracked-2") + TEST_THAT(EMU_UNLINK("testfiles/TestDir1/tracked-2") == 0); #endif @@ -3092,7 +3100,7 @@ bool test_file_rename_tracking() // case which went wrong: rename a tracked file // over a deleted file BOX_INFO("Rename an existing file over a deleted file"); - TEST_THAT(::unlink("testfiles/TestDir1/x1/dsfdsfs98.fd") == 0); + TEST_THAT(EMU_UNLINK("testfiles/TestDir1/x1/dsfdsfs98.fd") == 0); TEST_THAT(::rename("testfiles/TestDir1/df9834.dsf", "testfiles/TestDir1/x1/dsfdsfs98.fd") == 0); @@ -3872,7 +3880,7 @@ bool test_restore_deleted_files() bbackupd.RunSyncNow(); TEST_COMPARE(Compare_Same); - TEST_THAT(::unlink("testfiles/TestDir1/f1.dat") == 0); + TEST_THAT(EMU_UNLINK("testfiles/TestDir1/f1.dat") == 0); #ifdef WIN32 TEST_THAT(::system("rd /s/q testfiles\\TestDir1\\x1") == 0); #else diff --git a/test/httpserver/testhttpserver.cpp b/test/httpserver/testhttpserver.cpp index 469fa383..a28d387d 100644 --- a/test/httpserver/testhttpserver.cpp +++ b/test/httpserver/testhttpserver.cpp @@ -377,7 +377,7 @@ int test(int argc, const char *argv[]) FileStream f1("testfiles/testrequests.pl"); FileStream f2("testfiles/newfile"); TEST_THAT(f1.CompareWith(f2)); - TEST_EQUAL(0, ::unlink("testfiles/newfile")); + TEST_EQUAL(0, EMU_UNLINK("testfiles/newfile")); } // Start the S3Simulator server @@ -458,8 +458,7 @@ int test(int argc, const char *argv[]) SocketStream sock; sock.Open(Socket::TypeINET, "localhost", 1080); - HTTPRequest request(HTTPRequest::Method_PUT, - "/newfile"); + HTTPRequest request(HTTPRequest::Method_PUT, "/newfile"); request.SetHostName("quotes.s3.amazonaws.com"); request.AddHeader("Date", "Wed, 01 Mar 2006 12:00:00 GMT"); request.AddHeader("Authorization", "AWS 0PN5J17HBGZHT7JJ3X82:kfY1m6V3zTufRy2kj92FpQGKz4M="); @@ -481,9 +480,9 @@ int test(int argc, const char *argv[]) FileStream f1("testfiles/testrequests.pl"); FileStream f2("testfiles/newfile"); TEST_THAT(f1.CompareWith(f2)); + TEST_THAT(EMU_UNLINK("testfiles/newfile") == 0); } - // Kill it TEST_THAT(StopDaemon(pid, "testfiles/s3simulator.pid", "s3simulator.memleaks", true)); diff --git a/test/raidfile/testraidfile.cpp b/test/raidfile/testraidfile.cpp index 2314d376..06580204 100644 --- a/test/raidfile/testraidfile.cpp +++ b/test/raidfile/testraidfile.cpp @@ -822,7 +822,7 @@ int test(int argc, const char *argv[]) TEST_THAT(::rename("testfiles" DIRECTORY_SEPARATOR "0_0" DIRECTORY_SEPARATOR "damage.rf-NT", "testfiles" DIRECTORY_SEPARATOR "0_0" DIRECTORY_SEPARATOR "damage.rf") == 0); // Delete one of the files - TEST_THAT(::unlink("testfiles" DIRECTORY_SEPARATOR "0_1" DIRECTORY_SEPARATOR "damage.rf") == 0); // stripe 1 + TEST_THAT(EMU_UNLINK("testfiles" DIRECTORY_SEPARATOR "0_1" DIRECTORY_SEPARATOR "damage.rf") == 0); // stripe 1 #ifdef TRF_CAN_INTERCEPT // Open it and read... @@ -839,7 +839,7 @@ int test(int argc, const char *argv[]) #endif //TRF_CAN_INTERCEPT // Delete another - TEST_THAT(::unlink("testfiles" DIRECTORY_SEPARATOR "0_0" DIRECTORY_SEPARATOR "damage.rf") == 0); // parity + TEST_THAT(EMU_UNLINK("testfiles" DIRECTORY_SEPARATOR "0_0" DIRECTORY_SEPARATOR "damage.rf") == 0); // parity TEST_CHECK_THROWS( std::auto_ptr<RaidFileRead> pread2 = RaidFileRead::Open(0, "damage"), @@ -881,15 +881,15 @@ int test(int argc, const char *argv[]) TEST_THAT(true == RaidFileRead::ReadDirectoryContents(0, std::string("dirread"), RaidFileRead::DirReadType_DirsOnly, names)); TEST_THAT(list_matches(names, dir_list1)); // Delete things - TEST_THAT(::unlink("testfiles" DIRECTORY_SEPARATOR "0_0" DIRECTORY_SEPARATOR "dirread" DIRECTORY_SEPARATOR "sdf9873241.rf") == 0); + TEST_THAT(EMU_UNLINK("testfiles" DIRECTORY_SEPARATOR "0_0" DIRECTORY_SEPARATOR "dirread" DIRECTORY_SEPARATOR "sdf9873241.rf") == 0); TEST_THAT(true == RaidFileRead::ReadDirectoryContents(0, std::string("dirread"), RaidFileRead::DirReadType_FilesOnly, names)); TEST_THAT(list_matches(names, file_list1)); // Delete something else so that it's not recoverable - TEST_THAT(::unlink("testfiles" DIRECTORY_SEPARATOR "0_1" DIRECTORY_SEPARATOR "dirread" DIRECTORY_SEPARATOR "sdf9873241.rf") == 0); + TEST_THAT(EMU_UNLINK("testfiles" DIRECTORY_SEPARATOR "0_1" DIRECTORY_SEPARATOR "dirread" DIRECTORY_SEPARATOR "sdf9873241.rf") == 0); TEST_THAT(false == RaidFileRead::ReadDirectoryContents(0, std::string("dirread"), RaidFileRead::DirReadType_FilesOnly, names)); TEST_THAT(list_matches(names, file_list1)); // And finally... - TEST_THAT(::unlink("testfiles" DIRECTORY_SEPARATOR "0_2" DIRECTORY_SEPARATOR "dirread" DIRECTORY_SEPARATOR "sdf9873241.rf") == 0); + TEST_THAT(EMU_UNLINK("testfiles" DIRECTORY_SEPARATOR "0_2" DIRECTORY_SEPARATOR "dirread" DIRECTORY_SEPARATOR "sdf9873241.rf") == 0); TEST_THAT(true == RaidFileRead::ReadDirectoryContents(0, std::string("dirread"), RaidFileRead::DirReadType_FilesOnly, names)); TEST_THAT(list_matches(names, file_list2)); } |