summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorReinhard Tartler <siretart@tauware.de>2018-02-20 21:50:22 -0500
committerReinhard Tartler <siretart@tauware.de>2018-02-20 21:50:22 -0500
commitf6d7cfd710de1bf9d4f6eabab45570bc91941ee1 (patch)
tree6aed4f8606e47c6ef21c5b1d8bbf7cafa694af6e /test
parentc81b92946b58b90fe9679a476338e2d2dec8df67 (diff)
parentf28f88e5e72ba1499409047a9d6985eb312c0232 (diff)
Merge branch 'upstream'
Diffstat (limited to 'test')
-rw-r--r--test/backupstorefix/testbackupstorefix.cpp68
-rw-r--r--test/backupstorepatch/testbackupstorepatch.cpp19
-rw-r--r--test/basicserver/Makefile.extra6
-rw-r--r--test/basicserver/TestProtocol.txt (renamed from test/basicserver/testprotocol.txt)0
-rw-r--r--test/basicserver/testbasicserver.cpp16
-rw-r--r--test/bbackupd/testbbackupd.cpp71
-rw-r--r--test/common/testcommon.cpp114
-rw-r--r--test/crypto/testcrypto.cpp2
-rw-r--r--test/httpserver/testfiles/httpserver.conf5
-rwxr-xr-xtest/httpserver/testfiles/testrequests.pl9
-rw-r--r--test/raidfile/testraidfile.cpp9
11 files changed, 153 insertions, 166 deletions
diff --git a/test/backupstorefix/testbackupstorefix.cpp b/test/backupstorefix/testbackupstorefix.cpp
index 8e0a2720..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<BackupStoreAccountDatabase> apAccounts(
+ BackupStoreAccountDatabase::Read("testfiles/accounts.txt"));
+ BackupStoreAccounts acc(*apAccounts);
+ NamedLock lock;
+ acc.LockAccount(0x1234567, lock);
+#else
TEST_THAT(StopServer());
#endif
@@ -768,47 +777,15 @@ 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
// 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<BackupProtocolAccountUsage2> usage =
@@ -841,25 +818,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
}
// ------------------------------------------------------------------------------------------------
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");
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
index 5bca9f49..5bca9f49 100644
--- a/test/basicserver/testprotocol.txt
+++ b/test/basicserver/TestProtocol.txt
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<IOStream *> &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
diff --git a/test/bbackupd/testbbackupd.cpp b/test/bbackupd/testbbackupd.cpp
index dd50b862..cc602f22 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<std::string> args;
size_t last_arg_start = 0;
@@ -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();
@@ -3673,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.
@@ -3680,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.
@@ -3746,35 +3749,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");
}
diff --git a/test/common/testcommon.cpp b/test/common/testcommon.cpp
index fbdf8d9c..cba40fe7 100644
--- a/test/common/testcommon.cpp
+++ b/test/common/testcommon.cpp
@@ -312,16 +312,19 @@ 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(Timers::Cleanup(), CommonException,
AssertFailed);
+
+ Timer tim(0, "tim");
+ TEST_CHECK_THROWS(Timers::Add(tim), CommonException, AssertFailed);
+ Timers::Remove(tim);
+
+ TEST_CHECK_THROWS(Timer t1(900, "t1"), CommonException,
+ AssertFailed);
+
+ // TEST_CHECK_THROWS(Timers::Signal(), CommonException, AssertFailed);
+ }
#endif
// Check that we can initialise the timers
@@ -344,47 +347,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.
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
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
{
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:</b> (.+?)</p>~)
{
- 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";
}
}
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: