summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorReinhard Tartler <siretart@tauware.de>2009-04-13 09:37:44 +0200
committerReinhard Tartler <siretart@tauware.de>2009-04-13 09:37:44 +0200
commitd568e4cf1f9c024b88b748fe6b8b4652a7005567 (patch)
tree11b89c14477e69e3c1d9949851008bb48b992f02 /test
parent4775510ebd46f3ba852017549cce54f9714c93c6 (diff)
parentb591c86a418e8d5a0d1c1afd319d9acdad6fd4e3 (diff)
merge new upstream
Diffstat (limited to 'test')
-rw-r--r--test/backupstorepatch/testbackupstorepatch.cpp2
-rw-r--r--test/bbackupd/testbbackupd.cpp159
-rw-r--r--test/httpserver/testhttpserver.cpp3
3 files changed, 104 insertions, 60 deletions
diff --git a/test/backupstorepatch/testbackupstorepatch.cpp b/test/backupstorepatch/testbackupstorepatch.cpp
index 4fbf296a..23b01b15 100644
--- a/test/backupstorepatch/testbackupstorepatch.cpp
+++ b/test/backupstorepatch/testbackupstorepatch.cpp
@@ -578,7 +578,7 @@ int test(int argc, const char *argv[])
#ifdef WIN32
// Cannot signal bbstored to do housekeeping now,
// so just wait until we're sure it's done
- wait_for_operation(12);
+ wait_for_operation(12, "housekeeping to run");
#else
// Send the server a restart signal, so it does
// housekeeping immediately, and wait for it to happen
diff --git a/test/bbackupd/testbbackupd.cpp b/test/bbackupd/testbbackupd.cpp
index 9d82a11b..91c883cc 100644
--- a/test/bbackupd/testbbackupd.cpp
+++ b/test/bbackupd/testbbackupd.cpp
@@ -87,9 +87,9 @@
// two cycles and a bit
#define TIME_TO_WAIT_FOR_BACKUP_OPERATION 12
-void wait_for_backup_operation(int seconds = TIME_TO_WAIT_FOR_BACKUP_OPERATION)
+void wait_for_backup_operation(char* message)
{
- wait_for_operation(seconds);
+ wait_for_operation(TIME_TO_WAIT_FOR_BACKUP_OPERATION, message);
}
int bbstored_pid = 0;
@@ -889,7 +889,7 @@ int test_bbackupd()
TEST_THAT(close(fd) == 0);
int pid = start_internal_daemon();
- wait_for_backup_operation();
+ wait_for_backup_operation("internal daemon to run a sync");
TEST_THAT(stop_internal_daemon(pid));
// two-second delay on the first read() of f1
@@ -910,7 +910,8 @@ int test_bbackupd()
"Buffer write");
TEST_THAT(close(fd) == 0);
- wait_for_backup_operation();
+ wait_for_backup_operation("internal daemon to sync "
+ "spacetest/f1");
// can't test whether intercept was triggered, because
// it's in a different process.
// TEST_THAT(intercept_triggered());
@@ -985,7 +986,8 @@ int test_bbackupd()
"Buffer write");
TEST_THAT(close(fd) == 0);
- wait_for_backup_operation();
+ wait_for_backup_operation("internal daemon to sync "
+ "spacetest/f1 again");
// can't test whether intercept was triggered, because
// it's in a different process.
// TEST_THAT(intercept_triggered());
@@ -1050,7 +1052,8 @@ int test_bbackupd()
"Buffer write");
TEST_THAT(close(fd) == 0);
- wait_for_backup_operation();
+ wait_for_backup_operation("internal daemon to sync "
+ "spacetest/f1 again");
// can't test whether intercept was triggered, because
// it's in a different process.
// TEST_THAT(intercept_triggered());
@@ -1139,7 +1142,8 @@ int test_bbackupd()
"Buffer write");
TEST_THAT(close(fd) == 0);
- wait_for_backup_operation();
+ wait_for_backup_operation("internal daemon to scan "
+ "spacetest/d1");
// can't test whether intercept was triggered, because
// it's in a different process.
// TEST_THAT(intercept_triggered());
@@ -1284,10 +1288,10 @@ int test_bbackupd()
// housekeeping deleted them, the backup cannot complete
// if the limit is 20 blocks.
- BOX_TRACE("Waiting for bbackupd to notice that the "
+ BOX_TRACE("Waiting for sync for bbackupd to notice that the "
"store is full");
wait_for_sync_end();
- BOX_TRACE("done.");
+ BOX_TRACE("Sync finished.");
BOX_TRACE("Compare to check that there are differences");
int compareReturnValue = ::system(BBACKUPQUERY " "
@@ -1297,7 +1301,7 @@ int test_bbackupd()
TEST_RETURN(compareReturnValue,
BackupQueries::ReturnCode::Compare_Different);
TestRemoteProcessMemLeaks("bbackupquery.memleaks");
- BOX_TRACE("done.");
+ BOX_TRACE("Compare finished.");
// Check that the notify script was run
TEST_THAT(TestFileExists("testfiles/notifyran.store-full.1"));
@@ -1307,9 +1311,8 @@ int test_bbackupd()
// Kill the daemon
terminate_bbackupd(bbackupd_pid);
- BOX_TRACE("Wait for housekeeping to remove the deleted files");
- wait_for_backup_operation(5);
- BOX_TRACE("done.");
+ wait_for_operation(5, "housekeeping to remove the "
+ "deleted files");
// This removes f1 and d7, which were previously marked
// as deleted, so total usage drops by 4 blocks to 24.
@@ -1470,9 +1473,8 @@ int test_bbackupd()
return 1;
}
- BOX_TRACE("Wait for housekeeping to remove the deleted files");
- wait_for_backup_operation(5);
- BOX_TRACE("done.");
+ wait_for_operation(5, "housekeeping to remove the "
+ "deleted files");
BOX_TRACE("Check that the files were removed");
{
@@ -1606,9 +1608,7 @@ int test_bbackupd()
"| ( cd testfiles && tar xf - )") == 0);
#endif
- BOX_TRACE("Wait for bbackupd to upload more files");
- wait_for_backup_operation();
- BOX_TRACE("done.");
+ wait_for_backup_operation("bbackupd to upload more files");
// Check that the contents of the store are the same
// as the contents of the disc
@@ -1755,7 +1755,7 @@ int test_bbackupd()
return 1;
}
- test_run_bbstored();
+ TEST_THAT(test_run_bbstored() == 0);
cmd = BBACKUPD " " + bbackupd_args +
" testfiles/bbackupd.conf";
@@ -1803,8 +1803,8 @@ int test_bbackupd()
// also test symlink-to-self loop does not break restore
TEST_THAT(symlink("self", SYM_DIR "/self") == 0);
- ::wait_for_operation(4);
- ::sync_and_wait();
+ wait_for_operation(4, "symlinks to be old enough");
+ sync_and_wait();
// Check that the backup was successful, i.e. no differences
int compareReturnValue = ::system(BBACKUPQUERY " "
@@ -2207,7 +2207,8 @@ int test_bbackupd()
fs.Close();
}
- wait_for_backup_operation();
+ wait_for_backup_operation("upload of file with unicode name");
+
// Compare to check that the file was uploaded
compareReturnValue = ::system(BBACKUPQUERY " -Wwarning "
"-c testfiles/bbackupd.conf \"compare -acQ\" quit");
@@ -2540,8 +2541,13 @@ int test_bbackupd()
> 1024);
}
- // wait for backup daemon to do it's stuff, and compare again
- wait_for_backup_operation();
+ // wait long enough for new files to be old enough to backup
+ wait_for_operation(5, "new files to be old enough");
+
+ // wait for backup daemon to do it's stuff
+ sync_and_wait();
+
+ // compare to make sure that it worked
compareReturnValue = ::system(BBACKUPQUERY " -Wwarning "
"-c testfiles/bbackupd.conf "
"-l testfiles/query2.log "
@@ -2586,7 +2592,8 @@ int test_bbackupd()
TEST_THAT(close(fd1) == 0);
}
- wait_for_backup_operation(4);
+ wait_for_operation(4, "bbackupd to try to access the store");
+
// Check that an error was reported just once
TEST_THAT(TestFileExists("testfiles/notifyran.backup-error.1"));
TEST_THAT(!TestFileExists("testfiles/notifyran.backup-error.2"));
@@ -2644,9 +2651,11 @@ int test_bbackupd()
TEST_THAT(close(fd1) == 0);
}
- // bbackupd should pause for about 90 seconds from store_fixed_time,
- // so check that it hasn't run after 85 seconds from store_fixed_time
- wait_for_backup_operation(85 - time(NULL) + store_fixed_time);
+ // bbackupd should pause for about 90 seconds from
+ // store_fixed_time, so check that it hasn't run after
+ // 85 seconds after store_fixed_time
+ wait_for_operation(85 - time(NULL) + store_fixed_time,
+ "just before bbackupd recovers");
TEST_THAT(!TestFileExists("testfiles/"
"notifyran.backup-start.wait-snapshot.1"));
@@ -2660,7 +2669,7 @@ int test_bbackupd()
TestRemoteProcessMemLeaks("bbackupquery.memleaks");
// wait another 10 seconds, bbackup should have run
- wait_for_backup_operation(10);
+ wait_for_operation(10, "bbackupd to recover");
TEST_THAT(TestFileExists("testfiles/"
"notifyran.backup-start.wait-snapshot.1"));
@@ -2742,9 +2751,11 @@ int test_bbackupd()
TEST_THAT(close(fd1) == 0);
}
- // bbackupd should pause for about 90 seconds from store_fixed_time,
- // so check that it hasn't run after 85 seconds from store_fixed_time
- wait_for_backup_operation(85 - time(NULL) + store_fixed_time);
+ // bbackupd should pause for about 90 seconds from
+ // store_fixed_time, so check that it hasn't run after
+ // 85 seconds from store_fixed_time
+ wait_for_operation(85 - time(NULL) + store_fixed_time,
+ "just before bbackupd recovers");
TEST_THAT(!TestFileExists("testfiles/"
"notifyran.backup-start.wait-automatic.1"));
@@ -2758,7 +2769,7 @@ int test_bbackupd()
TestRemoteProcessMemLeaks("bbackupquery.memleaks");
// wait another 10 seconds, bbackup should have run
- wait_for_backup_operation(10);
+ wait_for_operation(10, "bbackupd to recover");
TEST_THAT(TestFileExists("testfiles/"
"notifyran.backup-start.wait-automatic.1"));
@@ -2801,7 +2812,7 @@ int test_bbackupd()
== 0);
#endif
- wait_for_backup_operation();
+ wait_for_backup_operation("bbackupd to sync the changes");
compareReturnValue = ::system(BBACKUPQUERY " "
"-c testfiles/bbackupd.conf "
"-l testfiles/query3c.log "
@@ -2830,7 +2841,8 @@ int test_bbackupd()
"testfiles/TestDir1/x1/dir-to-file") == 0);
#endif
- wait_for_backup_operation();
+ wait_for_backup_operation("bbackupd to sync the changes");
+
compareReturnValue = ::system(BBACKUPQUERY " "
"-c testfiles/bbackupd.conf "
"-l testfiles/query3d.log "
@@ -2862,7 +2874,8 @@ int test_bbackupd()
== 0);
#endif
- wait_for_backup_operation();
+ wait_for_backup_operation("bbackupd to sync the changes");
+
compareReturnValue = ::system(BBACKUPQUERY " "
"-c testfiles/bbackupd.conf "
"-l testfiles/query3e.log "
@@ -2894,7 +2907,8 @@ int test_bbackupd()
"testfiles/TestDir1/x1/dir-to-file") == 0);
#endif
- wait_for_backup_operation();
+ wait_for_backup_operation("bbackupd to sync the changes");
+
compareReturnValue = ::system(BBACKUPQUERY " "
"-c testfiles/bbackupd.conf "
"-l testfiles/query3f.log "
@@ -2924,9 +2938,12 @@ int test_bbackupd()
TEST_THAT(close(fd2) == 0);
TEST_THAT(TestFileExists("testfiles/TestDir1/untracked-1"));
TEST_THAT(TestFileExists("testfiles/TestDir1/untracked-2"));
- wait_for_operation(5);
+
// back up both files
- wait_for_backup_operation();
+ wait_for_operation(5, "untracked files to be old enough");
+ wait_for_backup_operation("bbackupd to sync the "
+ "untracked files");
+
compareReturnValue = ::system(BBACKUPQUERY " "
"-c testfiles/bbackupd.conf "
"-l testfiles/query3g.log "
@@ -2944,7 +2961,10 @@ int test_bbackupd()
"testfiles/TestDir1/untracked-2") == 0);
TEST_THAT(!TestFileExists("testfiles/TestDir1/untracked-1"));
TEST_THAT( TestFileExists("testfiles/TestDir1/untracked-2"));
- wait_for_backup_operation();
+
+ wait_for_backup_operation("bbackupd to sync the untracked "
+ "files again");
+
compareReturnValue = ::system(BBACKUPQUERY " "
"-c testfiles/bbackupd.conf "
"-l testfiles/query3g.log "
@@ -2977,9 +2997,14 @@ int test_bbackupd()
TEST_THAT(close(fd2) == 0);
TEST_THAT(TestFileExists("testfiles/TestDir1/tracked-1"));
TEST_THAT(TestFileExists("testfiles/TestDir1/tracked-2"));
- wait_for_operation(5);
+
+ // wait for them to be old enough to back up
+ wait_for_operation(5, "tracked files to be old enough");
+
// back up both files
- wait_for_backup_operation();
+ sync_and_wait();
+
+ // compare to make sure that it worked
compareReturnValue = ::system(BBACKUPQUERY " "
"-c testfiles/bbackupd.conf "
"-l testfiles/query3h.log "
@@ -2997,7 +3022,10 @@ int test_bbackupd()
"testfiles/TestDir1/tracked-2") == 0);
TEST_THAT(!TestFileExists("testfiles/TestDir1/tracked-1"));
TEST_THAT( TestFileExists("testfiles/TestDir1/tracked-2"));
- wait_for_backup_operation();
+
+ wait_for_backup_operation("bbackupd to sync the tracked "
+ "files again");
+
compareReturnValue = ::system(BBACKUPQUERY " "
"-c testfiles/bbackupd.conf "
"-l testfiles/query3i.log "
@@ -3018,7 +3046,8 @@ int test_bbackupd()
TEST_THAT(::rename("testfiles/TestDir1/df9834.dsf",
"testfiles/TestDir1/x1/dsfdsfs98.fd") == 0);
- wait_for_backup_operation();
+ wait_for_backup_operation("bbackupd to sync");
+
compareReturnValue = ::system(BBACKUPQUERY " "
"-c testfiles/bbackupd.conf "
"-l testfiles/query3j.log "
@@ -3056,7 +3085,8 @@ int test_bbackupd()
#endif
// Wait and test
- wait_for_backup_operation();
+ wait_for_backup_operation("bbackupd to sync old files");
+
compareReturnValue = ::system(BBACKUPQUERY " "
"-c testfiles/bbackupd.conf "
"-l testfiles/query3k.log "
@@ -3239,7 +3269,8 @@ int test_bbackupd()
}
// Wait and test...
- wait_for_backup_operation();
+ wait_for_backup_operation("bbackupd to try to sync "
+ "unreadable file");
compareReturnValue = ::system(BBACKUPQUERY " "
"-c testfiles/bbackupd.conf "
"-l testfiles/query3o.log "
@@ -3343,7 +3374,9 @@ int test_bbackupd()
::chmod("testfiles/TestDir1/df9834.dsf", 0423);
// Wait and test
- wait_for_backup_operation();
+ wait_for_backup_operation("bbackupd to sync deletion "
+ "of directory");
+
compareReturnValue = ::system(BBACKUPQUERY " "
"-c testfiles/bbackupd.conf "
"-l testfiles/query4.log "
@@ -3544,7 +3577,8 @@ int test_bbackupd()
#endif
// Wait and test
- wait_for_backup_operation();
+ wait_for_backup_operation("bbackupd to sync new files");
+
compareReturnValue = ::system(BBACKUPQUERY " "
"-c testfiles/bbackupd.conf "
"-l testfiles/query5.log "
@@ -3562,7 +3596,9 @@ int test_bbackupd()
printf("\n==== Rename directory\n");
TEST_THAT(rename("testfiles/TestDir1/sub23/dhsfdss",
"testfiles/TestDir1/renamed-dir") == 0);
- wait_for_backup_operation();
+
+ wait_for_backup_operation("bbackupd to sync renamed directory");
+
compareReturnValue = ::system(BBACKUPQUERY " "
"-c testfiles/bbackupd.conf "
"-l testfiles/query6.log "
@@ -3588,7 +3624,9 @@ int test_bbackupd()
"testfiles/TestDir1/df324-ren") == 0);
TEST_THAT(rename("testfiles/TestDir1/sub23/find2perl",
"testfiles/TestDir1/find2perl-ren") == 0);
- wait_for_backup_operation();
+
+ wait_for_backup_operation("bbackupd to sync renamed files");
+
compareReturnValue = ::system(BBACKUPQUERY " "
"-c testfiles/bbackupd.conf "
"-l testfiles/query6.log "
@@ -3631,7 +3669,7 @@ int test_bbackupd()
}
// Wait and test
- wait_for_backup_operation();
+ wait_for_backup_operation("bbackup to sync future file");
compareReturnValue = ::system(BBACKUPQUERY " "
"-c testfiles/bbackupd.conf "
"-l testfiles/query3e.log "
@@ -3698,9 +3736,11 @@ int test_bbackupd()
::fclose(f);
}
- // Wait and test that there *are* differences
- wait_for_backup_operation((TIME_TO_WAIT_FOR_BACKUP_OPERATION *
- 3) / 2); // little bit longer than usual
+ // Wait a little bit longer than usual
+ wait_for_operation((TIME_TO_WAIT_FOR_BACKUP_OPERATION *
+ 3) / 2, "bbackupd to detect changed store marker");
+
+ // Test that there *are* differences
compareReturnValue = ::system(BBACKUPQUERY " "
"-c testfiles/bbackupd.conf "
"-l testfiles/query6.log "
@@ -3714,9 +3754,8 @@ int test_bbackupd()
if (!ServerIsAlive(bbackupd_pid)) return 1;
if (!ServerIsAlive(bbstored_pid)) return 1;
- printf("\n==== Waiting for bbackupd to recover\n");
// 100 seconds - (12*3/2)
- wait_for_operation(82);
+ wait_for_operation(82, "bbackupd to recover");
TEST_THAT(ServerIsAlive(bbackupd_pid));
TEST_THAT(ServerIsAlive(bbstored_pid));
@@ -3947,8 +3986,9 @@ int test_bbackupd()
if(bbackupd_pid != -1 && bbackupd_pid != 0)
{
// Wait and compare (a little bit longer than usual)
- wait_for_backup_operation(
- (TIME_TO_WAIT_FOR_BACKUP_OPERATION*3) / 2);
+ wait_for_operation(
+ (TIME_TO_WAIT_FOR_BACKUP_OPERATION*3) / 2,
+ "bbackupd to sync everything");
compareReturnValue = ::system(BBACKUPQUERY " "
"-c testfiles/bbackupd.conf "
"-l testfiles/query4a.log "
@@ -4006,6 +4046,7 @@ int test(int argc, const char *argv[])
if(r != 0) return r;
r = test_run_bbstored();
+ TEST_THAT(r == 0);
if(r != 0) return r;
r = test_bbackupd();
diff --git a/test/httpserver/testhttpserver.cpp b/test/httpserver/testhttpserver.cpp
index c38ef8fe..6c0de9a9 100644
--- a/test/httpserver/testhttpserver.cpp
+++ b/test/httpserver/testhttpserver.cpp
@@ -9,6 +9,7 @@
#include "Box.h"
+#include <algorithm>
#include <cstdio>
#include <cstring>
#include <ctime>
@@ -358,7 +359,9 @@ int test(int argc, const char *argv[])
// Run the request script
TEST_THAT(::system("perl testfiles/testrequests.pl") == 0);
+ #ifndef WIN32
signal(SIGPIPE, SIG_IGN);
+ #endif
SocketStream sock;
sock.Open(Socket::TypeINET, "localhost", 1080);