From 688eda8b55b57b711020148c5b048de7c06d1744 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Thu, 1 Sep 2016 20:46:19 +0100 Subject: Fix case of filenames of "text" files used to generate protocols and docs. --- test/basicserver/Makefile.extra | 6 +++--- test/basicserver/TestProtocol.txt | 42 +++++++++++++++++++++++++++++++++++++++ test/basicserver/testprotocol.txt | 42 --------------------------------------- 3 files changed, 45 insertions(+), 45 deletions(-) create mode 100644 test/basicserver/TestProtocol.txt delete mode 100644 test/basicserver/testprotocol.txt (limited to 'test') diff --git a/test/basicserver/Makefile.extra b/test/basicserver/Makefile.extra index e6a4675e..4b21d37d 100644 --- a/test/basicserver/Makefile.extra +++ b/test/basicserver/Makefile.extra @@ -1,12 +1,12 @@ MAKEPROTOCOL = ../../lib/server/makeprotocol.pl -GEN_CMD = $(MAKEPROTOCOL) testprotocol.txt +GEN_CMD = $(MAKEPROTOCOL) TestProtocol.txt # AUTOGEN SEEDING -autogen_TestProtocol.cpp: $(MAKEPROTOCOL) testprotocol.txt +autogen_TestProtocol.cpp: $(MAKEPROTOCOL) TestProtocol.txt $(_PERL) $(GEN_CMD) -autogen_TestProtocolServer.h: $(MAKEPROTOCOL) testprotocol.txt +autogen_TestProtocolServer.h: $(MAKEPROTOCOL) TestProtocol.txt $(_PERL) $(GEN_CMD) diff --git a/test/basicserver/TestProtocol.txt b/test/basicserver/TestProtocol.txt new file mode 100644 index 00000000..5bca9f49 --- /dev/null +++ b/test/basicserver/TestProtocol.txt @@ -0,0 +1,42 @@ +# test protocol file + +Name Test +IdentString Test-0.00 +ServerContextClass TestContext TestContext.h + +BEGIN_OBJECTS + +Error 0 IsError(Type,SubType) Reply + int32 Type + int32 SubType + +Hello 1 Command(Hello) Reply + int32 Number32 + int16 Number16 + int8 Number8 + string Text + +Lists 2 Command(ListsReply) + vector LotsOfText + +ListsReply 3 Reply + int32 NumberOfStrings + +Quit 4 Command(Quit) Reply EndsConversation + +Simple 5 Command(SimpleReply) + int32 Value + +SimpleReply 6 Reply + int32 ValuePlusOne + +GetStream 7 Command(GetStream) Reply + int32 StartingValue + bool UncertainSize + +SendStream 8 Command(GetStream) StreamWithCommand + int64 Value + +String 9 Command(String) Reply + string Test + diff --git a/test/basicserver/testprotocol.txt b/test/basicserver/testprotocol.txt deleted file mode 100644 index 5bca9f49..00000000 --- a/test/basicserver/testprotocol.txt +++ /dev/null @@ -1,42 +0,0 @@ -# test protocol file - -Name Test -IdentString Test-0.00 -ServerContextClass TestContext TestContext.h - -BEGIN_OBJECTS - -Error 0 IsError(Type,SubType) Reply - int32 Type - int32 SubType - -Hello 1 Command(Hello) Reply - int32 Number32 - int16 Number16 - int8 Number8 - string Text - -Lists 2 Command(ListsReply) - vector LotsOfText - -ListsReply 3 Reply - int32 NumberOfStrings - -Quit 4 Command(Quit) Reply EndsConversation - -Simple 5 Command(SimpleReply) - int32 Value - -SimpleReply 6 Reply - int32 ValuePlusOne - -GetStream 7 Command(GetStream) Reply - int32 StartingValue - bool UncertainSize - -SendStream 8 Command(GetStream) StreamWithCommand - int64 Value - -String 9 Command(String) Reply - string Test - -- cgit v1.2.3 From 11a8c444875d8b7912fa07bdc3854e3adb27aa4e Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Sat, 3 Sep 2016 00:14:08 +0100 Subject: Break dependency on Cygwin commands in Windows tests. Define WIN32 properly when building with CMake, and in this case, use native commands such as attrib.exe instead of Cygwin chmod, so that users don't have to install Cygwin or msys-git. --- test/bbackupd/testbbackupd.cpp | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) (limited to 'test') diff --git a/test/bbackupd/testbbackupd.cpp b/test/bbackupd/testbbackupd.cpp index dd50b862..60ae4e89 100644 --- a/test/bbackupd/testbbackupd.cpp +++ b/test/bbackupd/testbbackupd.cpp @@ -2277,9 +2277,8 @@ bool test_read_only_dirs_can_be_restored() { { #ifdef WIN32 - // Cygwin chmod changes Windows file attributes - TEST_THAT(::system("chmod 0555 testfiles/" - "TestDir1/x1") == 0); + TEST_THAT(::system("attrib +r testfiles\\TestDir1\\x1") + == 0); #else TEST_THAT(chmod("testfiles/TestDir1/x1", 0555) == 0); @@ -2303,12 +2302,12 @@ bool test_read_only_dirs_can_be_restored() // put the permissions back to sensible values #ifdef WIN32 - TEST_THAT(::system("chmod 0755 testfiles/" - "TestDir1/x1") == 0); - TEST_THAT(::system("chmod 0755 testfiles/" - "restore1/x1") == 0); - TEST_THAT(::system("chmod 0755 testfiles/" - "restore-test/Test1/x1") == 0); + TEST_THAT(::system("attrib -r testfiles\\TestDir1\\x1") + == 0); + TEST_THAT(::system("attrib -r testfiles\\restore1\\x1") + == 0); + TEST_THAT(::system("attrib -r testfiles\\restore-test\\" + "Test1\\x1") == 0); #else TEST_THAT(chmod("testfiles/TestDir1/x1", 0755) == 0); @@ -2723,9 +2722,6 @@ bool test_store_error_reporting() // TODO FIXME dedent { - // Check that store errors are reported neatly - TEST_THAT(system("rm -f testfiles/notifyran.backup-error.*") == 0); - // Break the store. We need a write lock on the account // while we do this, otherwise housekeeping might be running // and might rewrite the info files when it finishes, @@ -3146,11 +3142,11 @@ bool test_upload_very_old_files() { // in the archive, it's read only #ifdef WIN32 - TEST_THAT(::system("chmod 0777 testfiles" - "/TestDir1/sub23/rand.h") == 0); + TEST_THAT(::system("attrib -r " + "testfiles\\TestDir\\sub23\\rand.h") == 0); #else - TEST_THAT(chmod("testfiles/TestDir1/sub23" - "/rand.h", 0777) == 0); + TEST_THAT(chmod("testfiles/TestDir1/sub23/rand.h", + 0777) == 0); #endif FILE *f = fopen("testfiles/TestDir1/sub23/rand.h", @@ -3393,7 +3389,7 @@ bool test_delete_dir_change_attribute() #endif // Change attributes on an existing file. #ifdef WIN32 - TEST_EQUAL(0, system("chmod 0423 testfiles/TestDir1/df9834.dsf")); + TEST_EQUAL(0, system("attrib +r testfiles\\TestDir1\\df9834.dsf")); #else TEST_THAT(::chmod("testfiles/TestDir1/df9834.dsf", 0423) == 0); #endif @@ -3578,8 +3574,14 @@ bool test_sync_new_files() // OpenBSD's tar interprets the "-m" option quite differently: // it sets the time to epoch zero (1 Jan 1970) instead of the // current time, which doesn't help us. So reset the timestamp - // on a file with the touch command, so it won't be backed up. - TEST_RETURN(::system("touch testfiles/TestDir1/chsh"), 0); + // on a file by touching it, so it won't be backed up. + { +#ifndef WIN32 + TEST_THAT(chmod("testfiles/TestDir1/chsh", 0755) == 0); +#endif + FileStream fs("testfiles/TestDir1/chsh", O_WRONLY); + fs.Write("a", 1); + } // At least one file is too new to be backed up on the first run. bbackupd.RunSyncNow(); -- cgit v1.2.3 From ba3928734bd20567819b5fc56c93f5d95965bd7a Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Fri, 16 Sep 2016 20:53:28 +0100 Subject: Use IPv4 localhost address to access test httpserver. Fixes test failures on IPv6 enabled hosts where localhost can resolve to an IPv6 address, but the server is only bound to the IPv4 localhost address. --- test/httpserver/testfiles/httpserver.conf | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/httpserver/testfiles/httpserver.conf b/test/httpserver/testfiles/httpserver.conf index 1a1c4644..d8c72a3f 100644 --- a/test/httpserver/testfiles/httpserver.conf +++ b/test/httpserver/testfiles/httpserver.conf @@ -1,5 +1,6 @@ - -AddressPrefix = http://localhost:1080 +# Use 127.0.0.1 instead of localhost to force use of IPv4, as that is what the server +# binds to. Windows tends to use IPv6 instead if possible, breaking the test. +AddressPrefix = http://127.0.0.1:1080 Server { -- cgit v1.2.3 From 480783187d95cc5cce18e0a9737a588328a5d18b Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Fri, 16 Sep 2016 20:55:20 +0100 Subject: Improve error messages in test httpserver perl client script. --- test/httpserver/testfiles/testrequests.pl | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'test') diff --git a/test/httpserver/testfiles/testrequests.pl b/test/httpserver/testfiles/testrequests.pl index 4dd3549f..fd4274b4 100755 --- a/test/httpserver/testfiles/testrequests.pl +++ b/test/httpserver/testfiles/testrequests.pl @@ -49,7 +49,8 @@ if($response3->code() != 200) print "Redirected GET request...\n"; my $response4 = $ua->get("$url_base/redirect?key=value"); -exit 4 unless $response4->is_success(); +die "GET ".$response4->request()->url()." failed: ".$response4->content() + unless $response4->is_success(); my $content4 = $response4->content(); @@ -112,13 +113,11 @@ sub check_url my ($c,$url) = @_; unless($c =~ m~URI: (.+?)

~) { - print "URI not found\n"; - exit(1); + die "URI not found in response: '$c'\n"; } if($url ne $1) { - print "Wrong URI in content\n"; - exit(1); + die "Wrong URI in content: expected '$url' but found '$1'\n"; } } -- cgit v1.2.3 From 519a2a37c575777c1301c64b489fdf95e5a97f69 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Fri, 16 Sep 2016 20:56:32 +0100 Subject: Speed up testbackupstorepatch on Windows. Detect when housekeeping has run and account is unlocked, and stop the loop early, so that we don't have to wait for 32 iterations of the loop. --- test/backupstorepatch/testbackupstorepatch.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'test') diff --git a/test/backupstorepatch/testbackupstorepatch.cpp b/test/backupstorepatch/testbackupstorepatch.cpp index e149a041..46f278ad 100644 --- a/test/backupstorepatch/testbackupstorepatch.cpp +++ b/test/backupstorepatch/testbackupstorepatch.cpp @@ -610,10 +610,13 @@ int test(int argc, const char *argv[]) writedir.Commit(true); } + // Get the revision number of the root directory, before housekeeping makes any changes. + int64_t first_revision = 0; + RaidFileRead::FileExists(0, "backup/01234567/o01", &first_revision); + #ifdef WIN32 - // Cannot signal bbstored to do housekeeping now, - // so just wait until we're sure it's done - wait_for_operation(12, "housekeeping to run"); + // Cannot signal bbstored to do housekeeping now, and we don't need to, as we will + // wait up to 32 seconds and detect automatically when it has finished. #else // Send the server a restart signal, so it does // housekeeping immediately, and wait for it to happen @@ -622,10 +625,8 @@ int test(int argc, const char *argv[]) ::kill(pid, SIGHUP); #endif - // Get the revision number of the info file - int64_t first_revision = 0; - RaidFileRead::FileExists(0, "backup/01234567/o01", &first_revision); - for(int l = 0; l < 32; ++l) + // Wait for changes to be written back to the root directory. + for(int secs_remaining = 32; secs_remaining >= 0; secs_remaining--) { // Sleep a while, and print a dot ::sleep(1); @@ -633,7 +634,7 @@ int test(int argc, const char *argv[]) ::fflush(stdout); // Early end? - if(l > 2) + if(!TestFileExists("testfiles/0_0/backup/01234567/write.lock")) { int64_t revid = 0; RaidFileRead::FileExists(0, "backup/01234567/o01", &revid); @@ -642,6 +643,8 @@ int test(int argc, const char *argv[]) break; } } + + TEST_LINE(secs_remaining != 0, "No changes detected to root directory after 32 seconds"); } ::printf("\n"); -- cgit v1.2.3 From 4f01448abd4a748d6d3a86b3bfacf20621ce701c Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Fri, 16 Sep 2016 21:56:31 +0100 Subject: Remove deletion of random files in testbackupstorefix. Deleting random files tends to cause random test failures. The results are not predictable and depend on the order in which files are uploaded and directories created. --- test/backupstorefix/testbackupstorefix.cpp | 54 ------------------------------ 1 file changed, 54 deletions(-) (limited to 'test') diff --git a/test/backupstorefix/testbackupstorefix.cpp b/test/backupstorefix/testbackupstorefix.cpp index 8e0a2720..369c78ba 100644 --- a/test/backupstorefix/testbackupstorefix.cpp +++ b/test/backupstorefix/testbackupstorefix.cpp @@ -768,41 +768,6 @@ int test(int argc, const char *argv[]) f.Commit(true /* write now! */); } -#ifndef BOX_RELEASE_BUILD - // Delete two of the three raidfiles and their parent - // directories. This used to crash bbstoreaccounts check. - // We can only do this, without destroying the entire store, - // in debug mode, where the store has a far deeper - // structure. - // This will destroy or damage objects 18-1b and 58-5b, - // some repairably. - TEST_THAT(rename("testfiles/0_0/backup/01234567/02/01/o00.rf", - "testfiles/0_0/backup/01234567/02/01/o00.rfw") == 0); // 0x18 - TEST_THAT(rename("testfiles/0_1/backup/01234567/02/01/o01.rf", - "testfiles/0_1/backup/01234567/02/01/o01.rfw") == 0); // 0x19 - //RUN("mv testfiles/0_2/backup/01234567/02/01/o02.rf " - // "testfiles/0_0/backup/01234567/02/01/o02.rfw"); // 0x1a - TEST_THAT(rename("testfiles/0_0/backup/01234567/02/01/o03.rf", - "testfiles/0_0/backup/01234567/02/01/o03.rfw") == 0); // 0x1b - TEST_THAT(rename("testfiles/0_0/backup/01234567/02/01/01/o00.rf", - "testfiles/0_0/backup/01234567/02/01/01/o00.rfw") == 0); // 0x58 - TEST_THAT(rename("testfiles/0_1/backup/01234567/02/01/01/o01.rf", - "testfiles/0_1/backup/01234567/02/01/01/o01.rfw") == 0); // 0x59 - //RUN("mv testfiles/0_2/backup/01234567/02/01/01/o02.rf " - // "testfiles/0_0/backup/01234567/02/01/01/o02.rfw"); // 0x5a - TEST_THAT(rename("testfiles/0_0/backup/01234567/02/01/01/o03.rf", - "testfiles/0_0/backup/01234567/02/01/01/o03.rfw") == 0); // 0x5b - // RUN("rm -r testfiles/0_1/backup/01234567/02/01"); - -# define RUN(x) TEST_THAT(system(x) == 0); -# ifdef WIN32 - RUN("rd /s/q testfiles\\0_2\\backup\\01234567\\02\\01"); -# else // !WIN32 - RUN("rm -r testfiles/0_2/backup/01234567/02/01"); -# endif // WIN32 -# undef RUN -#endif // !BOX_RELEASE_BUILD - // Fix it // ERROR: Object 0x44 is unattached. // ERROR: BlocksUsed changed from 284 to 282 @@ -841,25 +806,6 @@ int test(int argc, const char *argv[]) // file, so checking for AsRaid excludes this possibility. RaidFileController &rcontroller(RaidFileController::GetController()); RaidFileDiscSet rdiscSet(rcontroller.GetDiscSet(discSetNum)); - -#ifndef BOX_RELEASE_BUILD // Only if we destroyed these particular files, above. - TEST_EQUAL(RaidFileUtil::AsRaid, RaidFileUtil::RaidFileExists( - rdiscSet, "backup/01234567/02/01/o00")); - TEST_EQUAL(RaidFileUtil::AsRaid, RaidFileUtil::RaidFileExists( - rdiscSet, "backup/01234567/02/01/o01")); - TEST_EQUAL(RaidFileUtil::AsRaid, RaidFileUtil::RaidFileExists( - rdiscSet, "backup/01234567/02/01/o02")); - TEST_EQUAL(RaidFileUtil::AsRaid, RaidFileUtil::RaidFileExists( - rdiscSet, "backup/01234567/02/01/o03")); - TEST_EQUAL(RaidFileUtil::AsRaid, RaidFileUtil::RaidFileExists( - rdiscSet, "backup/01234567/02/01/01/o00")); - TEST_EQUAL(RaidFileUtil::AsRaid, RaidFileUtil::RaidFileExists( - rdiscSet, "backup/01234567/02/01/01/o01")); - TEST_EQUAL(RaidFileUtil::AsRaid, RaidFileUtil::RaidFileExists( - rdiscSet, "backup/01234567/02/01/01/o02")); - TEST_EQUAL(RaidFileUtil::AsRaid, RaidFileUtil::RaidFileExists( - rdiscSet, "backup/01234567/02/01/01/o03")); -#endif } // ------------------------------------------------------------------------------------------------ -- cgit v1.2.3 From 4ea58036a39c529a10cd69ee92390c10b61473ba Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Mon, 19 Sep 2016 23:55:20 +0100 Subject: Lock account before modifying in backupstorefix. Hopefully this will fix intermittent test failures on AppVeyor. --- test/backupstorefix/testbackupstorefix.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/backupstorefix/testbackupstorefix.cpp b/test/backupstorefix/testbackupstorefix.cpp index 369c78ba..38492bd1 100644 --- a/test/backupstorefix/testbackupstorefix.cpp +++ b/test/backupstorefix/testbackupstorefix.cpp @@ -19,6 +19,7 @@ #include "Test.h" #include "BackupClientCryptoKeys.h" #include "BackupProtocol.h" +#include "BackupStoreAccounts.h" #include "BackupStoreCheck.h" #include "BackupStoreConstants.h" #include "BackupStoreDirectory.h" @@ -716,7 +717,15 @@ int test(int argc, const char *argv[]) // Temporarily stop the server, so it doesn't repair the refcount error. Except // on win32, where hard-killing the server can leave a lockfile in place, // breaking the rest of the test. -#ifndef WIN32 +#ifdef WIN32 + // Wait for the server to finish housekeeping first, by getting a lock on + // the account. + std::auto_ptr apAccounts( + BackupStoreAccountDatabase::Read("testfiles/accounts.txt")); + BackupStoreAccounts acc(*apAccounts); + NamedLock lock; + acc.LockAccount(0x1234567, lock); +#else TEST_THAT(StopServer()); #endif @@ -774,6 +783,9 @@ int test(int argc, const char *argv[]) // ERROR: BlocksInCurrentFiles changed from 228 to 226 // ERROR: NumCurrentFiles changed from 114 to 113 // WARNING: Reference count of object 0x44 changed from 1 to 0 +#ifdef WIN32 + lock.ReleaseLock(); +#endif TEST_EQUAL(5, check_account_for_errors()); { std::auto_ptr usage = -- cgit v1.2.3 From 48d9965a72434b64c8416bc1b873b90ffba4d62c Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Thu, 29 Sep 2016 19:30:48 +0100 Subject: Extend timeout in test/basicserver for slow machines. --- test/basicserver/testbasicserver.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/basicserver/testbasicserver.cpp b/test/basicserver/testbasicserver.cpp index 6a1e15ad..6f2def54 100644 --- a/test/basicserver/testbasicserver.cpp +++ b/test/basicserver/testbasicserver.cpp @@ -35,7 +35,10 @@ // in ms #define COMMS_READ_TIMEOUT 4 #define COMMS_SERVER_WAIT_BEFORE_REPLYING 40 -#define SHORT_TIMEOUT 5000 +// Use a longer timeout to give Srv2TestConversations time to write 20 MB to each of +// three child processes before starting to read it back again, without the children +// timing out and aborting. +#define SHORT_TIMEOUT 30000 class basicdaemon : public Daemon { @@ -103,6 +106,12 @@ void testservers_connection(SocketStream &rStream) } if(line == "LARGEDATA") { + // This part of the test is timing-sensitive, because we write + // 20 MB to the test and then have to wait while it reads 20 MB + // from the other two children before writing anything back to us. + // We could timeout waiting for it to talk to us again. So we + // increased the SHORT_TIMEOUT from 5 seconds to 30 to allow + // more time. { // Send lots of data char data[LARGE_DATA_BLOCK_SIZE]; @@ -339,6 +348,11 @@ void Srv2TestConversations(const std::vector &conns) { conns[c]->Write("LARGEDATA\n", 10, SHORT_TIMEOUT); } + // This part of the test is timing-sensitive, because we read 20 MB from each of + // three daemon processes, then write 20 MB to each of them, then read back + // another 20 MB from each of them. Each child could timeout waiting for us to + // read from it, or write to it, while we're servicing another child. So we + // increased the SHORT_TIMEOUT from 5 seconds to 30 to allow enough time. for(unsigned int c = 0; c < conns.size(); ++c) { // Receive lots of data -- cgit v1.2.3 From 3a3fc72cd3b3c98870028f6d968b9cde64341ccd Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Mon, 22 May 2017 21:54:06 +0100 Subject: Relax timings on test_changing_client_store_marker_pauses_daemon Also increase test verbosity to help debug the test if it fails again. (cherry picked from commit 00c2127e9832591c248fa6eea05dfaf785b8380d) --- test/bbackupd/testbbackupd.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'test') diff --git a/test/bbackupd/testbbackupd.cpp b/test/bbackupd/testbbackupd.cpp index 60ae4e89..7113880d 100644 --- a/test/bbackupd/testbbackupd.cpp +++ b/test/bbackupd/testbbackupd.cpp @@ -361,8 +361,8 @@ bool configure_bbackupd(BackupDaemon& bbackupd, const std::string& config_file) // Stop bbackupd initialisation from changing the console logging level // and the program name tag. Logger& console(Logging::GetConsole()); - Logger::LevelGuard guard(console, console.GetLevel()); - Logging::Tagger(); + Logger::LevelGuard undo_log_level_change(console, console.GetLevel()); + Logging::Tagger undo_program_name_change; std::vector args; size_t last_arg_start = 0; @@ -3748,35 +3748,35 @@ bool test_changing_client_store_marker_pauses_daemon() // Test that there *are* differences still, i.e. that bbackupd // didn't successfully run a backup during that time. - BOX_TRACE("Compare starting, expecting differences"); + BOX_INFO("Compare starting, expecting differences"); TEST_COMPARE(Compare_Different); BOX_TRACE("Compare finished, expected differences"); // Wait out the expected delay in bbackupd. This is quite // time-sensitive, so we use sub-second precision. - box_time_t wait = + box_time_t wait = SecondsToBoxTime(BACKUP_ERROR_DELAY_SHORTENED - 1) - compare_time * 2; - BOX_TRACE("Waiting for " << BOX_FORMAT_MICROSECONDS(wait) << - " (plus another compare taking " << - BOX_FORMAT_MICROSECONDS(compare_time) << ") until " - "just before bbackupd recovers"); + BOX_INFO("Waiting for " << BOX_FORMAT_MICROSECONDS(wait) << " " + "until just before bbackupd recovers"); ShortSleep(wait, true); // bbackupd should not have recovered yet, so there should // still be differences. - BOX_TRACE("Compare starting, expecting differences"); + BOX_INFO("Compare starting, expecting differences"); TEST_COMPARE(Compare_Different); BOX_TRACE("Compare finished, expected differences"); - // Now wait for it to recover and finish a sync, and check - // that the differences are gone (successful backup). - wait = sync_time + SecondsToBoxTime(2); - BOX_TRACE("Waiting for " << BOX_FORMAT_MICROSECONDS(wait) << + // Now wait for it to recover and finish a sync, and check that + // the differences are gone (successful backup). Wait until ~2 + // seconds after we expect the sync to have finished, to reduce + // the risk of random failure on AppVeyor when heavily loaded. + wait = sync_time + SecondsToBoxTime(6); + BOX_INFO("Waiting for " << BOX_FORMAT_MICROSECONDS(wait) << " until just after bbackupd recovers and finishes a sync"); ShortSleep(wait, true); - BOX_TRACE("Compare starting, expecting no differences"); + BOX_INFO("Compare starting, expecting no differences"); TEST_COMPARE(Compare_Same); BOX_TRACE("Compare finished, expected no differences"); } -- cgit v1.2.3 From 6a04b0abd728da5211e6702b1d42aef95c02d8da Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Sun, 18 Jun 2017 18:56:08 +0000 Subject: Fix intercept of SYS_open on platforms that only have SYS_openat (e.g. arm64) --- test/raidfile/testraidfile.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'test') diff --git a/test/raidfile/testraidfile.cpp b/test/raidfile/testraidfile.cpp index c8150387..d771f23d 100644 --- a/test/raidfile/testraidfile.cpp +++ b/test/raidfile/testraidfile.cpp @@ -25,6 +25,7 @@ #include "RaidFileException.h" #include "RaidFileRead.h" #include "Guards.h" +#include "intercept.h" #include "MemLeakFindOn.h" @@ -37,14 +38,6 @@ #define TRF_CAN_INTERCEPT #endif - -#ifdef TRF_CAN_INTERCEPT -// function in intercept.cpp for setting up errors -void intercept_setup_error(const char *filename, unsigned int errorafter, int errortoreturn, int syscalltoerror); -bool intercept_triggered(); -void intercept_clear_setup(); -#endif - // Nice random data for testing written files class R250 { public: -- cgit v1.2.3 From 105f2620b98bfd4e5d7ed576b5cc4b2317dcf634 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Tue, 20 Jun 2017 21:02:42 +0100 Subject: Reduce precision of common timer test Ideally timers would be perfectly accurate and we could sleep for 1.0 seconds, but on OSX in particular they could fire 50-100 ms late (I've seen 4 ms in practice) and we don't want the tests to fail because of this, because we don't really need that kind of precision in practice. So we reduce the timer intervals by 100ms to be safe. Increase logging level and add timestamps in testcommon. Should help to debug frequent test failures such as Condition [t2.HasExpired()] on OSX hosts on Travis. Add a SettingsGuard to the Console logger for its specific settings, such as showing times and microseconds. (cherry picked from commit a5e6cff1d435329b0121417ed9509e315ce0edd5) (cherry picked from commit 8d02eebce553ed822e0fcd60d6e319384e15ba4b) --- test/common/testcommon.cpp | 95 ++++++++++++++++++++++++++-------------------- 1 file changed, 54 insertions(+), 41 deletions(-) (limited to 'test') diff --git a/test/common/testcommon.cpp b/test/common/testcommon.cpp index fbdf8d9c..bd75ac37 100644 --- a/test/common/testcommon.cpp +++ b/test/common/testcommon.cpp @@ -344,47 +344,60 @@ int test(int argc, const char *argv[]) Timers::Init(); - Timer t0(0, "t0"); // should never expire - Timer t1(1000, "t1"); - Timer t2(2000, "t2"); - Timer t3(3000, "t3"); - - TEST_THAT(!t0.HasExpired()); - TEST_THAT(!t1.HasExpired()); - TEST_THAT(!t2.HasExpired()); - TEST_THAT(!t3.HasExpired()); - - safe_sleep(1); - TEST_THAT(!t0.HasExpired()); - TEST_THAT(t1.HasExpired()); - TEST_THAT(!t2.HasExpired()); - TEST_THAT(!t3.HasExpired()); - - safe_sleep(1); - TEST_THAT(!t0.HasExpired()); - TEST_THAT(t1.HasExpired()); - TEST_THAT(t2.HasExpired()); - TEST_THAT(!t3.HasExpired()); - - // Try both ways of resetting an existing timer. - t1 = Timer(1000, "t1a"); - t2.Reset(2000); - TEST_THAT(!t0.HasExpired()); - TEST_THAT(!t1.HasExpired()); - TEST_THAT(!t2.HasExpired()); - TEST_THAT(!t3.HasExpired()); - - safe_sleep(1); - TEST_THAT(!t0.HasExpired()); - TEST_THAT(t1.HasExpired()); - TEST_THAT(!t2.HasExpired()); - TEST_THAT(t3.HasExpired()); - - safe_sleep(1); - TEST_THAT(!t0.HasExpired()); - TEST_THAT(t1.HasExpired()); - TEST_THAT(t2.HasExpired()); - TEST_THAT(t3.HasExpired()); + // Ideally timers would be perfectly accurate and we could sleep for 1.0 seconds, but + // on OSX in particular they could fire 50-100 ms late (I've seen 4 ms in practice) + // and we don't want the tests to fail because of this, because we don't really need + // that kind of precision in practice. So we reduce the timer intervals by 100ms to + // be safe. + + { + Logger::LevelGuard temporary_verbosity(Logging::GetConsole(), Log::TRACE); + Console::SettingsGuard save_old_settings; + Console::SetShowTime(true); + Console::SetShowTimeMicros(true); + + Timer t0(0, "t0"); // should never expire + Timer t1(900, "t1"); + Timer t2(1900, "t2"); + Timer t3(2900, "t3"); + + TEST_THAT(!t0.HasExpired()); + TEST_THAT(!t1.HasExpired()); + TEST_THAT(!t2.HasExpired()); + TEST_THAT(!t3.HasExpired()); + safe_sleep(1); + + TEST_THAT(!t0.HasExpired()); + TEST_THAT(t1.HasExpired()); + TEST_THAT(!t2.HasExpired()); + TEST_THAT(!t3.HasExpired()); + + safe_sleep(1); + TEST_THAT(!t0.HasExpired()); + TEST_THAT(t1.HasExpired()); + TEST_THAT(t2.HasExpired()); + TEST_THAT(!t3.HasExpired()); + + // Try both ways of resetting an existing timer. + t1 = Timer(900, "t1a"); + t2.Reset(1900); + TEST_THAT(!t0.HasExpired()); + TEST_THAT(!t1.HasExpired()); + TEST_THAT(!t2.HasExpired()); + TEST_THAT(!t3.HasExpired()); + + safe_sleep(1); + TEST_THAT(!t0.HasExpired()); + TEST_THAT(t1.HasExpired()); + TEST_THAT(!t2.HasExpired()); + TEST_THAT(t3.HasExpired()); + + safe_sleep(1); + TEST_THAT(!t0.HasExpired()); + TEST_THAT(t1.HasExpired()); + TEST_THAT(t2.HasExpired()); + TEST_THAT(t3.HasExpired()); + } // Leave timers initialised for rest of test. // Test main() will cleanup after test finishes. -- cgit v1.2.3 From 809d9ebacc409c4a86edb6077f489da67a2653d4 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Thu, 11 May 2017 20:50:26 +0100 Subject: Increase precision of timing on Windows. Should hopefully reduce random failures of timing-dependent tests which rely on subsecond precision for accuracy. (cherry picked from commit c845b2e39fffeb560983a301d810616a6495469d) --- test/bbackupd/testbbackupd.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/bbackupd/testbbackupd.cpp b/test/bbackupd/testbbackupd.cpp index 7113880d..cc602f22 100644 --- a/test/bbackupd/testbbackupd.cpp +++ b/test/bbackupd/testbbackupd.cpp @@ -3675,6 +3675,7 @@ bool test_changing_client_store_marker_pauses_daemon() box_time_t sync_start_time = GetCurrentBoxTime(); sync_and_wait(); box_time_t sync_time = GetCurrentBoxTime() - sync_start_time; + BOX_INFO("Sync takes " << BOX_FORMAT_MICROSECONDS(sync_time)); // Time how long a compare takes. On NetBSD it's 3 seconds, and that // interferes with test timing unless we account for it. @@ -3682,7 +3683,7 @@ bool test_changing_client_store_marker_pauses_daemon() // There should be no differences right now (yet). TEST_COMPARE(Compare_Same); box_time_t compare_time = GetCurrentBoxTime() - compare_start_time; - BOX_TRACE("Compare takes " << BOX_FORMAT_MICROSECONDS(compare_time)); + BOX_INFO("Compare takes " << BOX_FORMAT_MICROSECONDS(compare_time)); // Wait for the end of another sync, to give us ~3 seconds to change // the client store marker. -- cgit v1.2.3 From a631c82882b039f8467a2ef9abeb343f2ec5b3da Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Thu, 12 Oct 2017 21:27:54 +0100 Subject: Fix -Wundefined-bool-conversion compile failure of master branch Master build fails with: lib/common/Timer.cpp:171:10: error: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Werror,-Wundefined-bool-conversion]. Cannot get regtests to pass on this feature branch without fixing this. Also remove unused code from Timers. --- test/common/testcommon.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'test') diff --git a/test/common/testcommon.cpp b/test/common/testcommon.cpp index bd75ac37..bcfc92e1 100644 --- a/test/common/testcommon.cpp +++ b/test/common/testcommon.cpp @@ -312,14 +312,8 @@ int test(int argc, const char *argv[]) // Check that using timer methods without initialisation // throws an assertion failure. Can only do this in debug mode #ifndef BOX_RELEASE_BUILD - TEST_CHECK_THROWS(Timers::Add(*(Timer*)NULL), - CommonException, AssertFailed); - TEST_CHECK_THROWS(Timers::Remove(*(Timer*)NULL), - CommonException, AssertFailed); - #endif - - // TEST_CHECK_THROWS(Timers::Signal(), CommonException, AssertFailed); - #ifndef BOX_RELEASE_BUILD + TEST_CHECK_THROWS(Timer t1(900, "t1"), CommonException, + AssertFailed); TEST_CHECK_THROWS(Timers::Cleanup(), CommonException, AssertFailed); #endif -- cgit v1.2.3 From 447c2cd3d6884b8383884dbbfe65db845ea5c04d Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Mon, 20 Nov 2017 21:56:37 +0000 Subject: Remove invalid use of null references (undefined behaviour) Enable the relevant compiler warning as an error, if supported (-Werror=undefined-bool-conversion). http://www.gotw.ca/conv/002.htm http://stackoverflow.com/questions/2165078/a-reference-can-not-be-null-or-it-can-be-null (cherry picked from commit f2911acac0c8375a08ecc0a55f853a5a59c4d511) (cherry picked from commit 5a50b98401302a5ba89366e4c0f8cccdd88d8722) --- test/common/testcommon.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/common/testcommon.cpp b/test/common/testcommon.cpp index bd75ac37..3de7da1d 100644 --- a/test/common/testcommon.cpp +++ b/test/common/testcommon.cpp @@ -312,10 +312,11 @@ int test(int argc, const char *argv[]) // Check that using timer methods without initialisation // throws an assertion failure. Can only do this in debug mode #ifndef BOX_RELEASE_BUILD - TEST_CHECK_THROWS(Timers::Add(*(Timer*)NULL), - CommonException, AssertFailed); - TEST_CHECK_THROWS(Timers::Remove(*(Timer*)NULL), - CommonException, AssertFailed); + { + Timer tim(0, "tim"); + TEST_CHECK_THROWS(Timers::Add(tim), CommonException, AssertFailed); + Timers::Remove(tim); + } #endif // TEST_CHECK_THROWS(Timers::Signal(), CommonException, AssertFailed); -- cgit v1.2.3 From 85e7efc3fa0477f60318d2cd2144503a9ea8feb9 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Sat, 3 Jun 2017 12:13:42 +0100 Subject: Add support for OpenSSL 1.1 and replace deprecated function calls See https://github.com/boxbackup/boxbackup/issues/16 for details. Thanks to Chris West @FauxFaux for the initial patch! Use OpenSSL 1.1.0g for Windows superbuild. Fix Windows build by removing calls to obsolete do_ms.bat . Workaround for incorrect library suffixes searched by FindOpenSSL . Link OpenSSL statically and fix missing dependency on crypt32.lib. (cherry picked from commit edd3687f067c68b131822e0064cdeff5bf7a3835) (cherry picked from commit b003e009d1fccadf55a0f59a01c66f7b80f9b3e5) (cherry picked from commit cc6e20466b857f7e20d816a2c20cb36f112398ab) (cherry picked from commit 303c6405e3bc1e673dbc691792e0633742c01f4e) (cherry picked from commit 4e24006f75142a254f1a7db76cf9da1e752d9283) (cherry picked from commit 448ac48a89538f67f508f8d21931c5e6e90472c0) (cherry picked from commit 00b3bb0697219ef8c742698dd43d53b538e362b1) --- test/crypto/testcrypto.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/crypto/testcrypto.cpp b/test/crypto/testcrypto.cpp index 4e623cc2..32d2efb8 100644 --- a/test/crypto/testcrypto.cpp +++ b/test/crypto/testcrypto.cpp @@ -266,7 +266,7 @@ int test(int argc, const char *argv[]) // Check rolling checksums uint8_t *checkdata_blk = (uint8_t *)malloc(CHECKSUM_DATA_SIZE); uint8_t *checkdata = checkdata_blk; - RAND_pseudo_bytes(checkdata, CHECKSUM_DATA_SIZE); + RAND_bytes(checkdata, CHECKSUM_DATA_SIZE); for(int size = CHECKSUM_BLOCK_SIZE_BASE; size <= CHECKSUM_BLOCK_SIZE_LAST; ++size) { // Test skip-roll code -- cgit v1.2.3