From 3974cab358e855546227c676b4e36fb96664166e Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Tue, 6 Nov 2007 23:28:13 +0000 Subject: Pass bbackupd_args to the internal daemon (spaces are NOT supported). Stop early if a keepalive test fails, for debugging. --- test/bbackupd/testbbackupd.cpp | 59 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 52 insertions(+), 7 deletions(-) (limited to 'test/bbackupd/testbbackupd.cpp') diff --git a/test/bbackupd/testbbackupd.cpp b/test/bbackupd/testbbackupd.cpp index f6d033df..5e94efc8 100644 --- a/test/bbackupd/testbbackupd.cpp +++ b/test/bbackupd/testbbackupd.cpp @@ -619,8 +619,14 @@ int start_internal_daemon() // ensure that no child processes end up running tests! int own_pid = getpid(); + // this is a quick hack to allow passing some options to the daemon + const char* argv[] = { + "dummy", + bbackupd_args.c_str(), + }; + BackupDaemon daemon; - int result = daemon.Main("testfiles/bbackupd.conf"); + int result = daemon.Main("testfiles/bbackupd.conf", 2, argv); TEST_THAT(result == 0); if (result != 0) @@ -859,10 +865,22 @@ int test_bbackupd() comp = "Send StoreFile(0x3,"; TEST_THAT(line.substr(0, comp.size()) == comp); comp = ",\"f1\")"; - TEST_THAT(line.substr(line.size() - comp.size()) - == comp); + std::string sub = line.substr(line.size() - comp.size()); + + TEST_THAT(sub == comp); + if (sub != comp) + { + printf("Expected <%s> but found <%s> in <%s>\n", + comp.c_str(), sub.c_str(), line.c_str()); + } } + if (failures > 0) + { + // stop early to make debugging easier + return 1; + } + intercept_setup_delay("testfiles/TestDir1/spacetest/f1", 0, 4000, SYS_read, 1); pid = start_internal_daemon(); @@ -912,8 +930,20 @@ int test_bbackupd() comp = "Send StoreFile(0x3,"; TEST_THAT(line.substr(0, comp.size()) == comp); comp = ",0x0,\"f1\")"; - TEST_THAT(line.substr(line.size() - comp.size()) - == comp); + std::string sub = line.substr(line.size() - comp.size()); + + TEST_THAT(sub == comp); + if (sub != comp) + { + printf("Expected <%s> but found <%s> in <%s>\n", + comp.c_str(), sub.c_str(), line.c_str()); + } + } + + if (failures > 0) + { + // stop early to make debugging easier + return 1; } intercept_setup_delay("testfiles/TestDir1/spacetest/f1", @@ -971,6 +1001,9 @@ int test_bbackupd() TEST_THAT(reader.GetLine(line)); TEST_THAT(line == "Receive IsAlive()"); + // should not be a diff, so previous version + // should be 0x0 + TEST_THAT(reader.GetLine(line)); comp = "Send StoreFile(0x3,"; TEST_THAT(line.substr(0, comp.size()) == comp); @@ -980,11 +1013,17 @@ int test_bbackupd() TEST_THAT(sub == comp); if (sub != comp) { - printf("Expected <%s> but found <%s>\n", - comp.c_str(), sub.c_str()); + printf("Expected <%s> but found <%s> in <%s>\n", + comp.c_str(), sub.c_str(), line.c_str()); } } + if (failures > 0) + { + // stop early to make debugging easier + return 1; + } + intercept_setup_readdir_hook("testfiles/TestDir1/spacetest/d1", readdir_test_hook_1); @@ -1057,6 +1096,12 @@ int test_bbackupd() TEST_THAT(line == "Receive IsAlive()"); } + if (failures > 0) + { + // stop early to make debugging easier + return 1; + } + TEST_THAT(unlink(touchfile.c_str()) == 0); // restore timers for rest of tests -- cgit v1.2.3