Changeset 2184
- Timestamp:
- 28/05/2008 16:35:42 (4 years ago)
- Location:
- box/trunk
- Files:
-
- 6 edited
-
bin/bbackupquery/bbackupquery.cpp (modified) (5 diffs)
-
test/backupstorefix/testbackupstorefix.cpp (modified) (1 diff)
-
test/backupstorefix/testfiles/testbackupstorefix.pl.in (modified) (2 diffs)
-
test/bbackupd/testbbackupd.cpp (modified) (83 diffs)
-
test/bbackupd/testfiles/extcheck1.pl.in (modified) (1 diff)
-
test/bbackupd/testfiles/extcheck2.pl.in (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
box/trunk/bin/bbackupquery/bbackupquery.cpp
r2149 r2184 108 108 109 109 // Flags 110 bool quiet = false;111 110 bool readWrite = false; 112 111 … … 120 119 121 120 #ifdef WIN32 122 const char* validOpts = "qvwuc:l: ";121 const char* validOpts = "qvwuc:l:W:"; 123 122 bool unicodeConsole = false; 124 123 #else 125 const char* validOpts = "qvwc:l: ";124 const char* validOpts = "qvwc:l:W:"; 126 125 #endif 127 126 … … 134 133 case 'q': 135 134 { 136 // Quiet mode137 quiet = true;138 139 135 if(masterLevel == Log::NOTHING) 140 136 { … … 161 157 break; 162 158 159 case 'W': 160 { 161 masterLevel = Logging::GetNamedLevel(optarg); 162 if (masterLevel == Log::INVALID) 163 { 164 BOX_FATAL("Invalid logging level"); 165 return 2; 166 } 167 } 168 break; 169 163 170 case 'w': 164 171 // Read/write mode … … 198 205 Logging::SetGlobalLevel((Log::Level)masterLevel); 199 206 207 bool quiet = false; 208 if (masterLevel < Log::NOTICE) 209 { 210 // Quiet mode 211 quiet = true; 212 } 213 200 214 // Print banner? 201 215 if(!quiet) -
box/trunk/test/backupstorefix/testbackupstorefix.cpp
r2096 r2184 339 339 340 340 // Generate a list of all the object IDs 341 TEST_THAT_ABORTONFAIL(::system(BBACKUPQUERY " - q"341 TEST_THAT_ABORTONFAIL(::system(BBACKUPQUERY " -Wwarning " 342 342 "-c testfiles/bbackupd.conf \"list -r\" quit " 343 343 "> testfiles/initial-listing.txt") == 0); -
box/trunk/test/backupstorefix/testfiles/testbackupstorefix.pl.in
r930 r2184 94 94 95 95 # read in the new listing, and compare 96 open LISTING,"../../bin/bbackupquery/bbackupquery -q -c testfiles/bbackupd.conf \"list -r\" quit |" or die "Can't open list utility"; 97 open LISTING_COPY,'>testfiles/listing'.$ARGV[1].'.txt' or die "can't open copy listing file"; 96 open LISTING,"../../bin/bbackupquery/bbackupquery -Wwarning " . 97 "-c testfiles/bbackupd.conf " . 98 "\"list -r\" quit |" 99 or die "Can't open list utility"; 100 open LISTING_COPY,'>testfiles/listing'.$ARGV[1].'.txt' 101 or die "can't open copy listing file"; 98 102 my $err = 0; 99 103 while(<LISTING>) … … 126 130 elsif($ARGV[0] eq 'reroot') 127 131 { 128 open LISTING,"../../bin/bbackupquery/bbackupquery -q -c testfiles/bbackupd.conf \"list -r\" quit |" or die "Can't open list utility"; 129 open LISTING_COPY,'>testfiles/listing'.$ARGV[1].'.txt' or die "can't open copy listing file"; 132 open LISTING,"../../bin/bbackupquery/bbackupquery -Wwarning " . 133 "-c testfiles/bbackupd.conf " . 134 "\"list -r\" quit |" 135 or die "Can't open list utility"; 136 open LISTING_COPY,'>testfiles/listing'.$ARGV[1].'.txt' 137 or die "can't open copy listing file"; 130 138 my $err = 0; 131 139 my $count = 0; -
box/trunk/test/bbackupd/testbbackupd.cpp
r2127 r2184 44 44 #include "BackupDaemon.h" 45 45 #include "BackupDaemonConfigVerify.h" 46 #include "BackupQueries.h" 46 47 #include "BackupStoreConstants.h" 47 48 #include "BackupStoreDirectory.h" … … 83 84 #define TEST_EQUAL(expected, found, line) \ 84 85 { \ 85 std::string exp_str = expected; \ 86 std::string found_str = found; \ 86 std::ostringstream _oss1; \ 87 _oss1 << expected; \ 88 std::string exp_str = _oss1.str(); \ 89 \ 90 std::ostringstream _oss2; \ 91 _oss2 << found; \ 92 std::string found_str = _oss2.str(); \ 93 \ 87 94 TEST_THAT(exp_str == found_str); \ 95 std::string _line = line; \ 96 \ 88 97 if(exp_str != found_str) \ 89 98 { \ 90 99 printf("Expected <%s> but found <%s> in <%s>\n", \ 91 exp_str.c_str(), found_str.c_str(), line.c_str()); \100 exp_str.c_str(), found_str.c_str(), _line.c_str()); \ 92 101 } \ 93 102 } … … 337 346 338 347 BackupClientFileAttributes t3; 339 TEST_CHECK_THROWS(t3.ReadAttributes("doesn't exist"), CommonException, OSFileError); 348 { 349 Logging::Guard guard(Log::ERROR); 350 TEST_CHECK_THROWS(t3.ReadAttributes("doesn't exist"), 351 CommonException, OSFileError); 352 } 340 353 341 354 // Create some more files … … 354 367 355 368 #ifndef WIN32 356 TEST_CHECK_THROWS(t1.WriteAttributes("testfiles/test1_nXX"), CommonException, OSFileError); 357 TEST_CHECK_THROWS(t3.WriteAttributes("doesn't exist"), BackupStoreException, AttributesNotLoaded); 369 { 370 Logging::Guard guard(Log::ERROR); 371 TEST_CHECK_THROWS(t1.WriteAttributes("testfiles/test1_nXX"), 372 CommonException, OSFileError); 373 TEST_CHECK_THROWS(t3.WriteAttributes("doesn't exist"), 374 BackupStoreException, AttributesNotLoaded); 375 } 358 376 359 377 // Test that attributes are vaguely similar … … 651 669 // ensure that no child processes end up running tests! 652 670 int own_pid = getpid(); 671 BOX_TRACE("Test PID is " << own_pid); 653 672 654 673 // this is a quick hack to allow passing some options to the daemon … … 670 689 } 671 690 672 TEST_THAT(result == 0); 673 if (result != 0) 674 { 675 printf("Daemon exited with code %d\n", result); 676 } 691 TEST_EQUAL(0, result, "Daemon exit code"); 677 692 678 693 // ensure that no child processes end up running tests! 679 TEST_ THAT(getpid() == own_pid);694 TEST_EQUAL(own_pid, getpid(), "Forking test problem"); 680 695 if (getpid() != own_pid) 681 696 { … … 800 815 #endif 801 816 { 802 // TRACE1("lstat hook triggered for %s", file_name); 817 // TRACE1("lstat hook triggered for %s", file_name); 803 818 memset(buf, 0, sizeof(*buf)); 804 819 buf->st_mode = S_IFREG; 805 820 return 0; 821 } 822 823 // Simulate a symlink that is on a different device than the file 824 // that it points to. 825 int lstat_test_post_hook(int old_ret, const char *file_name, struct stat *buf) 826 { 827 BOX_TRACE("lstat post hook triggered for " << file_name); 828 if (old_ret == 0 && 829 strcmp(file_name, "testfiles/symlink-to-TestDir1") == 0) 830 { 831 buf->st_dev ^= 0xFFFF; 832 } 833 return old_ret; 834 } 835 836 bool test_entry_deleted(BackupStoreDirectory& rDir, 837 const std::string& rName) 838 { 839 BackupStoreDirectory::Iterator i(rDir); 840 841 BackupStoreDirectory::Entry *en = i.FindMatchingClearName( 842 BackupStoreFilenameClear(rName)); 843 TEST_THAT(en != 0); 844 if (en == 0) return false; 845 846 int16_t flags = en->GetFlags(); 847 TEST_THAT(flags && BackupStoreDirectory::Entry::Flags_Deleted); 848 return flags && BackupStoreDirectory::Entry::Flags_Deleted; 806 849 } 807 850 … … 818 861 "testfiles/clientPrivKey.pem", 819 862 "testfiles/clientTrustedCAs.pem"); 863 864 printf("\n==== Testing that ReadDirectory on nonexistent directory " 865 "does not crash\n"); 866 { 867 std::auto_ptr<BackupProtocolClient> client = ConnectAndLogin( 868 context, 0 /* read-write */); 869 870 { 871 Logging::Guard guard(Log::ERROR); 872 TEST_CHECK_THROWS(ReadDirectory(*client, 0x12345678), 873 ConnectionException, 874 Conn_Protocol_UnexpectedReply); 875 } 876 877 client->QueryFinished(); 878 sSocket.Close(); 879 } 820 880 821 881 // unpack the files for the initial test … … 853 913 memset(buffer, 0, sizeof(buffer)); 854 914 855 TEST_THAT(write(fd, buffer, sizeof(buffer)) == sizeof(buffer)); 915 TEST_EQUAL(sizeof(buffer), write(fd, buffer, sizeof(buffer)), 916 "Buffer write"); 856 917 TEST_THAT(close(fd) == 0); 857 918 … … 868 929 869 930 pid = start_internal_daemon(); 931 intercept_clear_setup(); 870 932 871 933 fd = open("testfiles/TestDir1/spacetest/f1", O_WRONLY); 872 934 TEST_THAT(fd > 0); 873 935 // write again, to update the file's timestamp 874 TEST_THAT(write(fd, buffer, sizeof(buffer)) == sizeof(buffer)); 936 TEST_EQUAL(sizeof(buffer), write(fd, buffer, sizeof(buffer)), 937 "Buffer write"); 875 938 TEST_THAT(close(fd) == 0); 876 939 … … 938 1001 0, 4000, SYS_read, 1); 939 1002 pid = start_internal_daemon(); 1003 intercept_clear_setup(); 940 1004 941 1005 fd = open("testfiles/TestDir1/spacetest/f1", O_WRONLY); 942 1006 TEST_THAT(fd > 0); 943 1007 // write again, to update the file's timestamp 944 TEST_THAT(write(fd, buffer, sizeof(buffer)) == sizeof(buffer)); 1008 TEST_EQUAL(sizeof(buffer), write(fd, buffer, sizeof(buffer)), 1009 "Buffer write"); 945 1010 TEST_THAT(close(fd) == 0); 946 1011 … … 971 1036 TEST_THAT(reader.GetLine(line)); 972 1037 std::string comp = "Receive Success(0x"; 973 TEST_ THAT(line.substr(0, comp.size()) == comp);1038 TEST_EQUAL(comp, line.substr(0, comp.size()), line); 974 1039 TEST_THAT(reader.GetLine(line)); 975 TEST_ THAT(line == "Receiving stream, size 124");1040 TEST_EQUAL("Receiving stream, size 124", line, line); 976 1041 977 1042 // delaying for 4 seconds in one step means that … … 998 1063 0, 1000, SYS_read, 3); 999 1064 pid = start_internal_daemon(); 1065 intercept_clear_setup(); 1000 1066 1001 1067 fd = open("testfiles/TestDir1/spacetest/f1", O_WRONLY); 1002 1068 TEST_THAT(fd > 0); 1003 1069 // write again, to update the file's timestamp 1004 TEST_THAT(write(fd, buffer, sizeof(buffer)) == sizeof(buffer)); 1070 TEST_EQUAL(sizeof(buffer), write(fd, buffer, sizeof(buffer)), 1071 "Buffer write"); 1005 1072 TEST_THAT(close(fd) == 0); 1006 1073 … … 1031 1098 TEST_THAT(reader.GetLine(line)); 1032 1099 std::string comp = "Receive Success(0x"; 1033 TEST_ THAT(line.substr(0, comp.size()) == comp);1100 TEST_EQUAL(comp, line.substr(0, comp.size()), line); 1034 1101 TEST_THAT(reader.GetLine(line)); 1035 TEST_ THAT(line == "Receiving stream, size 124");1102 TEST_EQUAL("Receiving stream, size 124", line, line); 1036 1103 1037 1104 // delaying for 3 seconds in steps of 1 second … … 1042 1109 1043 1110 TEST_THAT(reader.GetLine(line)); 1044 TEST_ THAT(line == "Send GetIsAlive()");1111 TEST_EQUAL("Send GetIsAlive()", line, line); 1045 1112 TEST_THAT(reader.GetLine(line)); 1046 TEST_ THAT(line == "Receive IsAlive()");1113 TEST_EQUAL("Receive IsAlive()", line, line); 1047 1114 TEST_THAT(reader.GetLine(line)); 1048 TEST_ THAT(line == "Send GetIsAlive()");1115 TEST_EQUAL("Send GetIsAlive()", line, line); 1049 1116 TEST_THAT(reader.GetLine(line)); 1050 TEST_ THAT(line == "Receive IsAlive()");1117 TEST_EQUAL("Receive IsAlive()", line, line); 1051 1118 1052 1119 // but two matching blocks should have been found … … 1079 1146 1080 1147 pid = start_internal_daemon(); 1148 intercept_clear_setup(); 1081 1149 1082 1150 std::string touchfile = … … 1086 1154 TEST_THAT(fd > 0); 1087 1155 // write again, to update the file's timestamp 1088 TEST_THAT(write(fd, buffer, sizeof(buffer)) == sizeof(buffer)); 1156 TEST_EQUAL(sizeof(buffer), write(fd, buffer, sizeof(buffer)), 1157 "Buffer write"); 1089 1158 TEST_THAT(close(fd) == 0); 1090 1159 … … 1159 1228 1160 1229 std::string cmd = BBACKUPD " " + bbackupd_args + 1161 " testfiles/bbackupd -temploc.conf";1230 " testfiles/bbackupd.conf"; 1162 1231 1163 1232 bbackupd_pid = LaunchServer(cmd, "testfiles/bbackupd.pid"); … … 1169 1238 if (!ServerIsAlive(bbackupd_pid)) return 1; 1170 1239 if (!ServerIsAlive(bbstored_pid)) return 1; 1240 1241 if(bbackupd_pid > 0) 1242 { 1243 printf("\n==== Testing that backup pauses when " 1244 "store is full\n"); 1245 1246 // wait for files to be uploaded 1247 BOX_TRACE("Waiting for all outstanding files to be uploaded") 1248 wait_for_sync_end(); 1249 BOX_TRACE("done.") 1250 1251 // Set limit to something very small 1252 // 26 blocks will be used at this point. 1253 // (12 files + location * 2 for raidfile) 1254 // 20 is what we'll need in a minute 1255 // set soft limit to 0 to ensure that all deleted files 1256 // are deleted immediately by housekeeping 1257 TEST_THAT_ABORTONFAIL(::system(BBSTOREACCOUNTS " -c " 1258 "testfiles/bbstored.conf setlimit 01234567 0B 20B") 1259 == 0); 1260 TestRemoteProcessMemLeaks("bbstoreaccounts.memleaks"); 1261 1262 // Unpack some more files 1263 #ifdef WIN32 1264 TEST_THAT(::system("tar xzvf testfiles/spacetest2.tgz " 1265 "-C testfiles/TestDir1") == 0); 1266 #else 1267 TEST_THAT(::system("gzip -d < testfiles/spacetest2.tgz " 1268 "| ( cd testfiles/TestDir1 && tar xf - )") == 0); 1269 #endif 1270 1271 // Delete a file and a directory 1272 TEST_THAT(::unlink("testfiles/TestDir1/spacetest/f1") == 0); 1273 TEST_THAT(::system("rm -rf testfiles/TestDir1/spacetest/d7") == 0); 1274 1275 // The following files should be on the server: 1276 // 00000001 -d---- 00002 (root) 1277 // 00000002 -d---- 00002 Test1 1278 // 00000003 -d---- 00002 Test1/spacetest 1279 // 00000004 f-X--- 00002 Test1/spacetest/f1 1280 // 00000005 f----- 00002 Test1/spacetest/f2 1281 // 00000006 -d---- 00002 Test1/spacetest/d1 1282 // 00000007 f----- 00002 Test1/spacetest/d1/f3 1283 // 00000008 f----- 00002 Test1/spacetest/d1/f4 1284 // 00000009 -d---- 00002 Test1/spacetest/d2 1285 // 0000000a -d---- 00002 Test1/spacetest/d3 1286 // 0000000b -d---- 00002 Test1/spacetest/d3/d4 1287 // 0000000c f----- 00002 Test1/spacetest/d3/d4/f5 1288 // 0000000d -d---- 00002 Test1/spacetest/d6 1289 // 0000000e -dX--- 00002 Test1/spacetest/d7 1290 // This is 28 blocks total, of which 2 in deleted files 1291 // and 18 in directories. Note that f1 and d7 may or may 1292 // not be deleted yet. 1293 // 1294 // spacetest1 + spacetest2 = 16 files = 32 blocks with raidfile 1295 // minus one file and one dir is 28 blocks 1296 // 1297 // d2/f6, d6/d8 and d6/d8/f7 are new 1298 // even if the client marks f1 and d7 as deleted, and 1299 // housekeeping deleted them, the backup cannot complete 1300 // if the limit is 20 blocks. 1301 1302 BOX_TRACE("Waiting for bbackupd to notice that the " 1303 "store is full"); 1304 wait_for_sync_end(); 1305 BOX_TRACE("done."); 1306 1307 BOX_TRACE("Compare to check that there are differences"); 1308 int compareReturnValue = ::system(BBACKUPQUERY " " 1309 "-c testfiles/bbackupd.conf " 1310 "-l testfiles/query0a.log " 1311 "-Werror \"compare -acQ\" quit"); 1312 TEST_RETURN(compareReturnValue, 1313 BackupQueries::ReturnCode::Compare_Different); 1314 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 1315 BOX_TRACE("done."); 1316 1317 // Check that the notify script was run 1318 TEST_THAT(TestFileExists("testfiles/notifyran.store-full.1")); 1319 // But only once! 1320 TEST_THAT(!TestFileExists("testfiles/notifyran.store-full.2")); 1321 1322 // Kill the daemon 1323 terminate_bbackupd(bbackupd_pid); 1324 1325 BOX_TRACE("Wait for housekeeping to remove the deleted files"); 1326 wait_for_backup_operation(5); 1327 BOX_TRACE("done."); 1328 1329 // This removes f1 and d7, which were previously marked 1330 // as deleted, so total usage drops by 4 blocks to 24. 1331 1332 // BLOCK 1333 { 1334 std::auto_ptr<BackupProtocolClient> client = 1335 ConnectAndLogin(context, 0 /* read-write */); 1336 1337 std::auto_ptr<BackupProtocolClientAccountUsage> usage( 1338 client->QueryGetAccountUsage()); 1339 TEST_EQUAL(24, usage->GetBlocksUsed(), "blocks used"); 1340 TEST_EQUAL(0, usage->GetBlocksInDeletedFiles(), 1341 "deleted blocks"); 1342 TEST_EQUAL(16, usage->GetBlocksInDirectories(), 1343 "directory blocks"); 1344 1345 client->QueryFinished(); 1346 sSocket.Close(); 1347 } 1348 1349 BOX_TRACE("Restart bbackupd with more exclusions"); 1350 // Start again with a new config that excludes d3 and f2, 1351 // and hence also d3/d4 and d3/d4/f5. bbackupd should mark 1352 // them as deleted and housekeeping should clean up, 1353 // making space to upload the new files. 1354 // total required: (13-2-4+3)*2 = 20 blocks 1355 /* 1356 cmd = BBACKUPD " " + bbackupd_args + 1357 " testfiles/bbackupd-exclude.conf"; 1358 bbackupd_pid = LaunchServer(cmd, "testfiles/bbackupd.pid"); 1359 TEST_THAT(bbackupd_pid != -1 && bbackupd_pid != 0); 1360 ::safe_sleep(1); 1361 TEST_THAT(ServerIsAlive(bbackupd_pid)); 1362 TEST_THAT(ServerIsAlive(bbstored_pid)); 1363 if (!ServerIsAlive(bbackupd_pid)) return 1; 1364 if (!ServerIsAlive(bbstored_pid)) return 1; 1365 */ 1366 BackupDaemon bbackupd; 1367 bbackupd.Configure("testfiles/bbackupd-exclude.conf"); 1368 bbackupd.InitCrypto(); 1369 BOX_TRACE("done."); 1370 1371 // Should be marked as deleted by this run 1372 // wait_for_sync_end(); 1373 { 1374 Logging::Guard guard(Log::ERROR); 1375 bbackupd.RunSyncNow(); 1376 } 1377 1378 TEST_THAT(bbackupd.StorageLimitExceeded()); 1379 1380 // Check that the notify script was run 1381 // TEST_THAT(TestFileExists("testfiles/notifyran.store-full.2")); 1382 // But only twice! 1383 // TEST_THAT(!TestFileExists("testfiles/notifyran.store-full.3")); 1384 1385 // All these should be marked as deleted but hopefully 1386 // not removed by housekeeping yet: 1387 // f1 deleted 1388 // f2 excluded 1389 // d1 excluded (why?) 1390 // d1/f3 excluded (why?) 1391 // d3 excluded 1392 // d3/d4 excluded 1393 // d3/d4/f5 excluded 1394 // d7 deleted 1395 // Careful with timing here, these files can already be 1396 // deleted by housekeeping. 1397 1398 BOX_TRACE("Find out whether bbackupd marked files as deleted"); 1399 { 1400 std::auto_ptr<BackupProtocolClient> client = 1401 ConnectAndLogin(context, 0 /* read-write */); 1402 1403 std::auto_ptr<BackupStoreDirectory> rootDir = 1404 ReadDirectory(*client, 1405 BackupProtocolClientListDirectory::RootDirectory); 1406 1407 int64_t testDirId = SearchDir(*rootDir, "Test1"); 1408 TEST_THAT(testDirId != 0); 1409 1410 std::auto_ptr<BackupStoreDirectory> Test1_dir = 1411 ReadDirectory(*client, testDirId); 1412 1413 int64_t spacetestDirId = SearchDir(*Test1_dir, 1414 "spacetest"); 1415 TEST_THAT(spacetestDirId != 0); 1416 1417 std::auto_ptr<BackupStoreDirectory> spacetest_dir = 1418 ReadDirectory(*client, spacetestDirId); 1419 1420 TEST_THAT(SearchDir(*spacetest_dir, "f1") == 0); 1421 TEST_THAT(test_entry_deleted(*spacetest_dir, "f2")); 1422 TEST_THAT(test_entry_deleted(*spacetest_dir, "d3")); 1423 TEST_THAT(SearchDir(*spacetest_dir, "d7") == 0); 1424 1425 int64_t d3_id = SearchDir(*spacetest_dir, "d3"); 1426 TEST_THAT(d3_id != 0); 1427 1428 std::auto_ptr<BackupStoreDirectory> d3_dir = 1429 ReadDirectory(*client, d3_id); 1430 TEST_THAT(test_entry_deleted(*d3_dir, "d4")); 1431 1432 int64_t d4_id = SearchDir(*d3_dir, "d4"); 1433 TEST_THAT(d4_id != 0); 1434 1435 std::auto_ptr<BackupStoreDirectory> d4_dir = 1436 ReadDirectory(*client, d4_id); 1437 TEST_THAT(test_entry_deleted(*d4_dir, "f5")); 1438 1439 std::auto_ptr<BackupProtocolClientAccountUsage> usage( 1440 client->QueryGetAccountUsage()); 1441 TEST_EQUAL(24, usage->GetBlocksUsed(), "blocks used"); 1442 TEST_EQUAL(4, usage->GetBlocksInDeletedFiles(), 1443 "deleted blocks"); 1444 TEST_EQUAL(16, usage->GetBlocksInDirectories(), 1445 "directory blocks"); 1446 // d1/f3 and d1/f4 are the only two files on the 1447 // server which are not deleted, they use 2 blocks 1448 // each, the rest is directories and 2 deleted files 1449 // (f1 and d3/d4/f5) 1450 1451 // Log out. 1452 client->QueryFinished(); 1453 sSocket.Close(); 1454 } 1455 BOX_TRACE("done."); 1456 1457 // Wait for housekeeping to run 1458 BOX_TRACE("Wait for housekeeping to remove the deleted files"); 1459 wait_for_backup_operation(5); 1460 BOX_TRACE("done."); 1461 1462 BOX_TRACE("Check that the files were removed"); 1463 { 1464 std::auto_ptr<BackupProtocolClient> client = 1465 ConnectAndLogin(context, 0 /* read-write */); 1466 1467 std::auto_ptr<BackupStoreDirectory> rootDir = 1468 ReadDirectory(*client, 1469 BackupProtocolClientListDirectory::RootDirectory); 1470 1471 int64_t testDirId = SearchDir(*rootDir, "Test1"); 1472 TEST_THAT(testDirId != 0); 1473 1474 std::auto_ptr<BackupStoreDirectory> Test1_dir = 1475 ReadDirectory(*client, testDirId); 1476 1477 int64_t spacetestDirId = SearchDir(*Test1_dir, 1478 "spacetest"); 1479 TEST_THAT(spacetestDirId != 0); 1480 1481 std::auto_ptr<BackupStoreDirectory> spacetest_dir = 1482 ReadDirectory(*client, spacetestDirId); 1483 1484 TEST_THAT(SearchDir(*spacetest_dir, "f1") == 0); 1485 TEST_THAT(SearchDir(*spacetest_dir, "f2") == 0); 1486 TEST_THAT(SearchDir(*spacetest_dir, "d3") == 0); 1487 TEST_THAT(SearchDir(*spacetest_dir, "d7") == 0); 1488 1489 std::auto_ptr<BackupProtocolClientAccountUsage> usage( 1490 client->QueryGetAccountUsage()); 1491 TEST_EQUAL(16, usage->GetBlocksUsed(), "blocks used"); 1492 TEST_EQUAL(0, usage->GetBlocksInDeletedFiles(), 1493 "deleted blocks"); 1494 TEST_EQUAL(12, usage->GetBlocksInDirectories(), 1495 "directory blocks"); 1496 // d1/f3 and d1/f4 are the only two files on the 1497 // server, they use 2 blocks each, the rest is 1498 // directories. 1499 1500 // Log out. 1501 client->QueryFinished(); 1502 sSocket.Close(); 1503 } 1504 1505 // Need 22 blocks free to upload everything 1506 TEST_THAT_ABORTONFAIL(::system(BBSTOREACCOUNTS " -c " 1507 "testfiles/bbstored.conf setlimit 01234567 0B 22B") 1508 == 0); 1509 TestRemoteProcessMemLeaks("bbstoreaccounts.memleaks"); 1510 1511 // Run another backup, now there should be enough space 1512 // for everything we want to upload. 1513 { 1514 Logging::Guard guard(Log::ERROR); 1515 bbackupd.RunSyncNow(); 1516 } 1517 TEST_THAT(!bbackupd.StorageLimitExceeded()); 1518 1519 // Check that the contents of the store are the same 1520 // as the contents of the disc 1521 // (-a = all, -c = give result in return code) 1522 BOX_TRACE("Check that all files were uploaded successfully"); 1523 compareReturnValue = ::system(BBACKUPQUERY " " 1524 "-c testfiles/bbackupd-exclude.conf " 1525 "-l testfiles/query1.log " 1526 "-Wwarning \"compare -acQ\" quit"); 1527 TEST_RETURN(compareReturnValue, 1528 BackupQueries::ReturnCode::Compare_Same); 1529 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 1530 BOX_TRACE("done."); 1531 1532 // BLOCK 1533 { 1534 std::auto_ptr<BackupProtocolClient> client = 1535 ConnectAndLogin(context, 0 /* read-write */); 1536 1537 std::auto_ptr<BackupProtocolClientAccountUsage> usage( 1538 client->QueryGetAccountUsage()); 1539 TEST_EQUAL(22, usage->GetBlocksUsed(), "blocks used"); 1540 TEST_EQUAL(0, usage->GetBlocksInDeletedFiles(), 1541 "deleted blocks"); 1542 TEST_EQUAL(14, usage->GetBlocksInDirectories(), 1543 "directory blocks"); 1544 // d2/f6, d6/d8 and d6/d8/f7 are new 1545 // i.e. 2 new files, 1 new directory 1546 1547 client->QueryFinished(); 1548 sSocket.Close(); 1549 } 1550 1551 // Put the limit back 1552 TEST_THAT_ABORTONFAIL(::system(BBSTOREACCOUNTS " -c " 1553 "testfiles/bbstored.conf setlimit 01234567 " 1554 "1000B 2000B") == 0); 1555 TestRemoteProcessMemLeaks("bbstoreaccounts.memleaks"); 1556 1557 // Start again with the old config 1558 BOX_TRACE("Restart bbackupd with original configuration"); 1559 // terminate_bbackupd(); 1560 cmd = BBACKUPD " " + bbackupd_args + 1561 " testfiles/bbackupd.conf"; 1562 bbackupd_pid = LaunchServer(cmd, "testfiles/bbackupd.pid"); 1563 TEST_THAT(bbackupd_pid != -1 && bbackupd_pid != 0); 1564 ::safe_sleep(1); 1565 TEST_THAT(ServerIsAlive(bbackupd_pid)); 1566 TEST_THAT(ServerIsAlive(bbstored_pid)); 1567 if (!ServerIsAlive(bbackupd_pid)) return 1; 1568 if (!ServerIsAlive(bbstored_pid)) return 1; 1569 BOX_TRACE("done."); 1570 1571 // unpack the initial files again 1572 #ifdef WIN32 1573 TEST_THAT(::system("tar xzvf testfiles/test_base.tgz " 1574 "-C testfiles") == 0); 1575 #else 1576 TEST_THAT(::system("gzip -d < testfiles/test_base.tgz " 1577 "| ( cd testfiles && tar xf - )") == 0); 1578 #endif 1579 1580 BOX_TRACE("Wait for bbackupd to upload more files"); 1581 wait_for_backup_operation(); 1582 BOX_TRACE("done."); 1583 1584 // Check that the contents of the store are the same 1585 // as the contents of the disc 1586 // (-a = all, -c = give result in return code) 1587 BOX_TRACE("Check that all files were uploaded successfully"); 1588 compareReturnValue = ::system(BBACKUPQUERY " " 1589 "-c testfiles/bbackupd.conf " 1590 "-l testfiles/query1.log " 1591 "-Wwarning \"compare -acQ\" quit"); 1592 TEST_RETURN(compareReturnValue, 1593 BackupQueries::ReturnCode::Compare_Same); 1594 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 1595 BOX_TRACE("done."); 1596 1597 TEST_THAT(ServerIsAlive(bbackupd_pid)); 1598 TEST_THAT(ServerIsAlive(bbstored_pid)); 1599 if (!ServerIsAlive(bbackupd_pid)) return 1; 1600 if (!ServerIsAlive(bbstored_pid)) return 1; 1601 } 1171 1602 1172 1603 #ifndef WIN32 … … 1205 1636 1206 1637 // Check that the backup was successful, i.e. no differences 1207 int compareReturnValue = ::system(BBACKUPQUERY " -q"1638 int compareReturnValue = ::system(BBACKUPQUERY " " 1208 1639 "-c testfiles/bbackupd.conf " 1209 1640 "-l testfiles/query1.log " 1210 "\"compare -acQ\" quit"); 1211 TEST_RETURN(compareReturnValue, 1); 1641 "-Wwarning \"compare -acQ\" quit"); 1642 TEST_RETURN(compareReturnValue, 1643 BackupQueries::ReturnCode::Compare_Same); 1212 1644 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 1213 1645 … … 1228 1660 compareReturnValue = ::system(BBACKUPQUERY " " 1229 1661 "-c testfiles/bbackupd.conf " 1230 "- q\"restore Test1 testfiles/restore-symlink\" "1662 "-Wwarning \"restore Test1 testfiles/restore-symlink\" " 1231 1663 "quit"); 1232 TEST_RETURN(compareReturnValue, 0); 1664 TEST_RETURN(compareReturnValue, 1665 BackupQueries::ReturnCode::Command_OK); 1233 1666 1234 1667 // make it accessible again … … 1241 1674 TEST_THAT(gl.GetLine(line)); 1242 1675 TEST_THAT(line != "before"); 1243 TEST_ THAT(line == "after");1676 TEST_EQUAL("after", line, line); 1244 1677 1245 1678 #undef SYM_DIR 1679 1680 /* 1681 // This is not worth testing or fixing. 1682 // 1683 #ifndef PLATFORM_CLIB_FNS_INTERCEPTION_IMPOSSIBLE 1684 printf("\n==== Testing that symlinks to other filesystems " 1685 "can be backed up as roots\n"); 1686 1687 intercept_setup_lstat_post_hook(lstat_test_post_hook); 1688 TEST_THAT(symlink("TestDir1", "testfiles/symlink-to-TestDir1") 1689 == 0); 1690 1691 struct stat stat_st, lstat_st; 1692 TEST_THAT(stat("testfiles/symlink-to-TestDir1", &stat_st) == 0); 1693 TEST_THAT(lstat("testfiles/symlink-to-TestDir1", &lstat_st) == 0); 1694 TEST_EQUAL((stat_st.st_dev ^ 0xFFFF), lstat_st.st_dev, 1695 "stat vs lstat"); 1696 1697 BackupDaemon bbackupd; 1698 bbackupd.Configure("testfiles/bbackupd-symlink.conf"); 1699 bbackupd.InitCrypto(); 1700 bbackupd.RunSyncNow(); 1701 intercept_clear_setup(); 1702 1703 compareReturnValue = ::system(BBACKUPQUERY " " 1704 "-c testfiles/bbackupd.conf " 1705 "-l testfiles/query0a.log " 1706 "-Wwarning \"compare -acQ\" quit"); 1707 TEST_RETURN(compareReturnValue, 1708 BackupQueries::ReturnCode::Compare_Same); 1709 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 1710 1711 // and again using the symlink during compare 1712 compareReturnValue = ::system(BBACKUPQUERY " " 1713 "-c testfiles/bbackupd-symlink.conf " 1714 "-l testfiles/query0a.log " 1715 "-Wwarning \"compare -acQ\" quit"); 1716 TEST_RETURN(compareReturnValue, 1717 BackupQueries::ReturnCode::Compare_Same); 1718 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 1719 #endif 1720 */ 1246 1721 1247 1722 bbackupd_pid = LaunchServer(cmd, "testfiles/bbackupd.pid"); … … 1258 1733 printf("\n==== Testing that redundant locations are deleted on time\n"); 1259 1734 1735 // BLOCK 1260 1736 { 1261 {1262 std::auto_ptr<BackupProtocolClient> client =1263 ConnectAndLogin(context,1264 BackupProtocolClientLogin::Flags_ReadOnly);1265 1266 std::auto_ptr<BackupStoreDirectory> dir =1267 ReadDirectory(*client,1268 BackupProtocolClientListDirectory::RootDirectory);1269 1270 // int64_t testDirId = SearchDir(*dir, "Test2");1271 // TEST_THAT(testDirId == 0);1272 1273 sync_and_wait();1274 1275 dir = ReadDirectory(*client,1276 BackupProtocolClientListDirectory::RootDirectory);1277 int64_t testDirId = SearchDir(*dir, "Test2");1278 TEST_THAT(testDirId != 0);1279 client->QueryFinished();1280 sSocket.Close();1281 }1282 1283 1737 // Kill the daemon 1284 1738 terminate_bbackupd(bbackupd_pid); 1285 1739 1286 cmd = BBACKUPD " " + bbackupd_args + 1287 " testfiles/bbackupd.conf"; 1740 // Start it with a config that has a temporary location 1741 // that will be created on the server 1742 std::string cmd = BBACKUPD " " + bbackupd_args + 1743 " testfiles/bbackupd-temploc.conf"; 1744 1288 1745 bbackupd_pid = LaunchServer(cmd, "testfiles/bbackupd.pid"); 1289 1290 1746 TEST_THAT(bbackupd_pid != -1 && bbackupd_pid != 0); 1291 1292 1747 ::safe_sleep(1); 1293 1748 … … 1297 1752 if (!ServerIsAlive(bbstored_pid)) return 1; 1298 1753 1299 // Test2 should be deleted after 10 seconds (4 runs) 1300 wait_for_sync_end(); 1301 wait_for_sync_end(); 1302 wait_for_sync_end(); 1754 sync_and_wait(); 1303 1755 1304 1756 { … … 1312 1764 int64_t testDirId = SearchDir(*dir, "Test2"); 1313 1765 TEST_THAT(testDirId != 0); 1766 1314 1767 client->QueryFinished(); 1315 1768 sSocket.Close(); 1316 1769 } 1317 1770 1771 // Kill the daemon 1772 terminate_bbackupd(bbackupd_pid); 1773 1774 // Start it again with the normal config (no Test2) 1775 cmd = BBACKUPD " " + bbackupd_args + 1776 " testfiles/bbackupd.conf"; 1777 bbackupd_pid = LaunchServer(cmd, "testfiles/bbackupd.pid"); 1778 1779 TEST_THAT(bbackupd_pid != -1 && bbackupd_pid != 0); 1780 1781 ::safe_sleep(1); 1782 1783 TEST_THAT(ServerIsAlive(bbackupd_pid)); 1784 TEST_THAT(ServerIsAlive(bbstored_pid)); 1785 if (!ServerIsAlive(bbackupd_pid)) return 1; 1786 if (!ServerIsAlive(bbstored_pid)) return 1; 1787 1788 // Test2 should be deleted after 10 seconds (4 runs) 1318 1789 wait_for_sync_end(); 1790 wait_for_sync_end(); 1791 wait_for_sync_end(); 1792 1793 // not yet! should still be there 1319 1794 1320 1795 { … … 1329 1804 TEST_THAT(testDirId != 0); 1330 1805 1331 BackupStoreDirectory::Iterator i(*dir); 1332 BackupStoreFilenameClear dirname("Test2"); 1333 BackupStoreDirectory::Entry *en = 1334 i.FindMatchingClearName(dirname); 1335 TEST_THAT(en != 0); 1336 int16_t en_flags = en->GetFlags(); 1337 TEST_THAT(en_flags && BackupStoreDirectory::Entry::Flags_Deleted); 1806 client->QueryFinished(); 1807 sSocket.Close(); 1808 } 1809 1810 wait_for_sync_end(); 1811 1812 // NOW it should be gone 1813 1814 { 1815 std::auto_ptr<BackupProtocolClient> client = 1816 ConnectAndLogin(context, 1817 BackupProtocolClientLogin::Flags_ReadOnly); 1818 1819 std::auto_ptr<BackupStoreDirectory> root_dir = 1820 ReadDirectory(*client, 1821 BackupProtocolClientListDirectory::RootDirectory); 1822 1823 TEST_THAT(test_entry_deleted(*root_dir, "Test2")); 1824 1338 1825 client->QueryFinished(); 1339 1826 sSocket.Close(); … … 1348 1835 if(bbackupd_pid > 0) 1349 1836 { 1350 printf("\n==== Testing that backup pauses when store is full\n");1351 1352 // wait for files to be uploaded1353 wait_for_backup_operation();1354 1355 // Set limit to something very small1356 // About 28 blocks will be used at this point. bbackupd1357 // will only pause if the size used is greater than1358 // soft limit + 1/3 of (hard - soft). Set small values1359 // for limits accordingly.1360 TEST_THAT_ABORTONFAIL(::system(BBSTOREACCOUNTS " -c "1361 "testfiles/bbstored.conf setlimit 01234567 9B 10B")1362 == 0);1363 TestRemoteProcessMemLeaks("bbstoreaccounts.memleaks");1364 1365 // Unpack some more files1366 #ifdef WIN321367 TEST_THAT(::system("tar xzvf testfiles/spacetest2.tgz "1368 "-C testfiles/TestDir1") == 0);1369 #else1370 TEST_THAT(::system("gzip -d < testfiles/spacetest2.tgz "1371 "| ( cd testfiles/TestDir1 && tar xf - )") == 0);1372 #endif1373 1374 // Delete a file and a directory1375 TEST_THAT(::unlink("testfiles/TestDir1/spacetest/d1/f3") == 0);1376 TEST_THAT(::system("rm -rf testfiles/TestDir1/spacetest/d3/d4") == 0);1377 wait_for_backup_operation();1378 1379 // Make sure there are some differences1380 int compareReturnValue = ::system(BBACKUPQUERY " -q "1381 "-c testfiles/bbackupd.conf "1382 "-l testfiles/query0a.log "1383 "\"compare -acQ\" quit");1384 TEST_RETURN(compareReturnValue, 2);1385 TestRemoteProcessMemLeaks("bbackupquery.memleaks");1386 1387 // Put the limit back1388 TEST_THAT_ABORTONFAIL(::system(BBSTOREACCOUNTS " -c "1389 "testfiles/bbstored.conf setlimit 01234567 "1390 "1000B 2000B") == 0);1391 TestRemoteProcessMemLeaks("bbstoreaccounts.memleaks");1392 1393 // Check that the notify script was run1394 TEST_THAT(TestFileExists("testfiles/notifyran.store-full.1"));1395 // But only once!1396 TEST_THAT(!TestFileExists("testfiles/notifyran.store-full.2"));1397 1398 // unpack the initial files again1399 #ifdef WIN321400 TEST_THAT(::system("tar xzvf testfiles/test_base.tgz "1401 "-C testfiles") == 0);1402 #else1403 TEST_THAT(::system("gzip -d < testfiles/test_base.tgz "1404 "| ( cd testfiles && tar xf - )") == 0);1405 #endif1406 1407 // wait for it to do it's stuff1408 wait_for_backup_operation();1409 1410 // Check that the contents of the store are the same1411 // as the contents of the disc1412 // (-a = all, -c = give result in return code)1413 compareReturnValue = ::system(BBACKUPQUERY " -q "1414 "-c testfiles/bbackupd.conf "1415 "-l testfiles/query1.log "1416 "\"compare -acQ\" quit");1417 TEST_RETURN(compareReturnValue, 1);1418 TestRemoteProcessMemLeaks("bbackupquery.memleaks");1419 1420 TEST_THAT(ServerIsAlive(bbackupd_pid));1421 TEST_THAT(ServerIsAlive(bbstored_pid));1422 if (!ServerIsAlive(bbackupd_pid)) return 1;1423 if (!ServerIsAlive(bbstored_pid)) return 1;1424 1425 1426 1837 printf("\n==== Check that read-only directories and " 1427 1838 "their contents can be restored.\n"); … … 1439 1850 wait_for_sync_end(); // should be backed up now 1440 1851 1441 compareReturnValue = ::system(BBACKUPQUERY " " 1852 int compareReturnValue = ::system(BBACKUPQUERY " " 1853 "-Wwarning " 1442 1854 "-c testfiles/bbackupd.conf " 1443 " -q\"compare -cEQ Test1 testfiles/TestDir1\" "1855 "\"compare -cEQ Test1 testfiles/TestDir1\" " 1444 1856 "quit"); 1445 TEST_RETURN(compareReturnValue, 1); 1857 TEST_RETURN(compareReturnValue, 1858 BackupQueries::ReturnCode::Compare_Same); 1446 1859 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 1447 1860 1448 1861 // check that we can restore it 1449 1862 compareReturnValue = ::system(BBACKUPQUERY " " 1863 "-Wwarning " 1450 1864 "-c testfiles/bbackupd.conf " 1451 " -q\"restore Test1 testfiles/restore1\" "1865 "\"restore Test1 testfiles/restore1\" " 1452 1866 "quit"); 1453 TEST_RETURN(compareReturnValue, 0); 1867 TEST_RETURN(compareReturnValue, 1868 BackupQueries::ReturnCode::Command_OK); 1454 1869 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 1455 1870 1456 1871 // check that it restored properly 1457 1872 compareReturnValue = ::system(BBACKUPQUERY " " 1873 "-Wwarning " 1458 1874 "-c testfiles/bbackupd.conf " 1459 " -q\"compare -cEQ Test1 testfiles/restore1\" "1875 "\"compare -cEQ Test1 testfiles/restore1\" " 1460 1876 "quit"); 1461 TEST_RETURN(compareReturnValue, 1); 1877 TEST_RETURN(compareReturnValue, 1878 BackupQueries::ReturnCode::Compare_Same); 1462 1879 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 1463 1880 … … 1514 1931 1515 1932 char cwdbuf[1024]; 1516 TEST_ THAT(getcwd(cwdbuf, sizeof(cwdbuf)) == cwdbuf);1933 TEST_EQUAL(cwdbuf, getcwd(cwdbuf, sizeof(cwdbuf)), "getcwd"); 1517 1934 std::string cwd = cwdbuf; 1518 1935 … … 1545 1962 // test that bbackupd will let us lcd into the local 1546 1963 // directory using a relative path 1547 std::string command = BBACKUPQUERY " -q " 1964 std::string command = BBACKUPQUERY " " 1965 "-Wwarning " 1548 1966 "-c testfiles/bbackupd.conf " 1549 1967 "\"lcd testfiles/TestDir1/" + systemDirName + "\" " 1550 1968 "quit"; 1551 1969 compareReturnValue = ::system(command.c_str()); 1552 TEST_RETURN(compareReturnValue, 0); 1970 TEST_RETURN(compareReturnValue, 1971 BackupQueries::ReturnCode::Command_OK); 1553 1972 1554 1973 // and back out again 1555 command = BBACKUPQUERY " -q " 1974 command = BBACKUPQUERY " " 1975 "-Wwarning " 1556 1976 "-c testfiles/bbackupd.conf " 1557 1977 "\"lcd testfiles/TestDir1/" + systemDirName + "\" " 1558 1978 "\"lcd ..\" quit"; 1559 1979 compareReturnValue = ::system(command.c_str()); 1560 TEST_RETURN(compareReturnValue, 0); 1980 TEST_RETURN(compareReturnValue, 1981 BackupQueries::ReturnCode::Command_OK); 1561 1982 1562 1983 // and using an absolute path 1563 command = BBACKUPQUERY " -q " 1984 command = BBACKUPQUERY " " 1985 "-Wwarning " 1564 1986 "-c testfiles/bbackupd.conf " 1565 1987 "\"lcd " + cwd + "/testfiles/TestDir1/" + 1566 1988 systemDirName + "\" quit"; 1567 1989 compareReturnValue = ::system(command.c_str()); 1568 TEST_RETURN(compareReturnValue, 0); 1990 TEST_RETURN(compareReturnValue, 1991 BackupQueries::ReturnCode::Command_OK); 1569 1992 1570 1993 // and back out again 1571 command = BBACKUPQUERY " -q " 1994 command = BBACKUPQUERY " " 1995 "-Wwarning " 1572 1996 "-c testfiles/bbackupd.conf " 1573 1997 "\"lcd " + cwd + "/testfiles/TestDir1/" + … … 1575 1999 "\"lcd ..\" quit"; 1576 2000 compareReturnValue = ::system(command.c_str()); 1577 TEST_RETURN(compareReturnValue, 0); 2001 TEST_RETURN(compareReturnValue, 2002 BackupQueries::ReturnCode::Command_OK); 1578 2003 1579 2004 { … … 1582 2007 std::string data("hello world\n"); 1583 2008 fs.Write(data.c_str(), data.size()); 1584 TEST_ THAT(fs.GetPosition() == 12);2009 TEST_EQUAL(12, fs.GetPosition(), "FileStream position"); 1585 2010 fs.Close(); 1586 2011 } … … 1588 2013 wait_for_backup_operation(); 1589 2014 // Compare to check that the file was uploaded 1590 compareReturnValue = ::system(BBACKUPQUERY " - q"2015 compareReturnValue = ::system(BBACKUPQUERY " -Wwarning " 1591 2016 "-c testfiles/bbackupd.conf \"compare -acQ\" quit"); 1592 TEST_RETURN(compareReturnValue, 1); 2017 TEST_RETURN(compareReturnValue, 2018 BackupQueries::ReturnCode::Compare_Same); 1593 2019 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 1594 2020 … … 1616 2042 } 1617 2043 1618 1619 2044 // Check that bbackupquery shows the dir in console encoding 1620 command = BBACKUPQUERY " - q"2045 command = BBACKUPQUERY " -Wwarning " 1621 2046 "-c testfiles/bbackupd.conf " 1622 2047 "-q \"list Test1\" quit"; … … 1648 2073 // the file in console encoding 1649 2074 command = BBACKUPQUERY " -c testfiles/bbackupd.conf " 1650 "- q\"list Test1/" + systemDirName + "\" quit";2075 "-Wwarning \"list Test1/" + systemDirName + "\" quit"; 1651 2076 queryout = LocalProcessStream(command.c_str(), 1652 2077 bbackupquery_pid); … … 1672 2097 // on the command line in system encoding. 1673 2098 command = BBACKUPQUERY " -c testfiles/bbackupd.conf " 1674 "- q\"compare -cEQ Test1/" + systemDirName +2099 "-Wwarning \"compare -cEQ Test1/" + systemDirName + 1675 2100 " testfiles/TestDir1/" + systemDirName + "\" quit"; 1676 2101 1677 2102 compareReturnValue = ::system(command.c_str()); 1678 2103 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 1679 TEST_RETURN(compareReturnValue, 1); 2104 TEST_RETURN(compareReturnValue, 2105 BackupQueries:ReturnCode::Compare_Same); 1680 2106 1681 2107 // Check that bbackupquery can restore the dir when given 1682 2108 // on the command line in system encoding. 1683 2109 command = BBACKUPQUERY " -c testfiles/bbackupd.conf " 1684 "- q\"restore Test1/" + systemDirName +2110 "-Wwarning \"restore Test1/" + systemDirName + 1685 2111 " testfiles/restore-" + systemDirName + "\" quit"; 1686 2112 1687 2113 compareReturnValue = ::system(command.c_str()); 1688 2114 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 1689 TEST_RETURN(compareReturnValue, 0); 2115 TEST_RETURN(compareReturnValue, 2116 BackupQueries:ReturnCode::Command_OK); 1690 2117 1691 2118 // Compare to make sure it was restored properly. 1692 2119 command = BBACKUPQUERY " -c testfiles/bbackupd.conf " 1693 "- q\"compare -cEQ Test1/" + systemDirName +2120 "-Wwarning \"compare -cEQ Test1/" + systemDirName + 1694 2121 " testfiles/restore-" + systemDirName + "\" quit"; 1695 2122 1696 2123 compareReturnValue = ::system(command.c_str()); 1697 2124 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 1698 TEST_RETURN(compareReturnValue, 1); 2125 TEST_RETURN(compareReturnValue, 2126 BackupQueries::ReturnCode::Compare_Same); 1699 2127 1700 2128 std::string fileToUnlink = "testfiles/restore-" + … … 1705 2133 // on the command line in system encoding. 1706 2134 command = BBACKUPQUERY " -c testfiles/bbackupd.conf " 1707 "- q\"get Test1/" + systemDirName + "/" +2135 "-Wwarning \"get Test1/" + systemDirName + "/" + 1708 2136 systemFileName + " " + "testfiles/restore-" + 1709 2137 systemDirName + "/" + systemFileName + "\" quit"; 1710 2138 1711 2139 compareReturnValue = ::system(command.c_str()); 1712 TEST_RETURN(compareReturnValue, 0); 2140 TEST_RETURN(compareReturnValue, 2141 BackupQueries:ReturnCode::Command_OK); 1713 2142 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 1714 2143 1715 2144 // And after changing directory to a relative path 1716 command = BBACKUPQUERY " -c testfiles/bbackupd.conf -q " 2145 command = BBACKUPQUERY " -c testfiles/bbackupd.conf " 2146 "-Wwarning " 1717 2147 "\"lcd testfiles\" " 1718 2148 "\"cd Test1/" + systemDirName + "\" " + … … 1720 2150 1721 2151 compareReturnValue = ::system(command.c_str()); 1722 TEST_RETURN(compareReturnValue, 0); 2152 TEST_RETURN(compareReturnValue, 2153 BackupQueries:ReturnCode::Command_OK); 1723 2154 TestRemoteProcessMemLeaks("testfiles/bbackupquery.memleaks"); 1724 2155 … … 1728 2159 1729 2160 // And after changing directory to an absolute path 1730 command = BBACKUPQUERY " -c testfiles/bbackupd.conf - q"2161 command = BBACKUPQUERY " -c testfiles/bbackupd.conf -Wwarning " 1731 2162 "\"lcd " + cwd + "/testfiles\" " 1732 2163 "\"cd Test1/" + systemDirName + "\" " + … … 1734 2165 1735 2166 compareReturnValue = ::system(command.c_str()); 1736 TEST_RETURN(compareReturnValue, 0); 2167 TEST_RETURN(compareReturnValue, 2168 BackupQueries:ReturnCode::Command_OK); 1737 2169 TestRemoteProcessMemLeaks("testfiles/bbackupquery.memleaks"); 1738 2170 … … 1740 2172 // The Get command does not restore attributes, so 1741 2173 // we must compare without them (-A) to succeed. 1742 command = BBACKUPQUERY " -c testfiles/bbackupd.conf " 1743 "-q \"compare -cAEQ Test1/" + systemDirName + 2174 command = BBACKUPQUERY " " 2175 "-c testfiles/bbackupd.conf " 2176 "-Wwarning \"compare -cAEQ Test1/" + systemDirName + 1744 2177 " testfiles/restore-" + systemDirName + "\" quit"; 1745 2178 1746 2179 compareReturnValue = ::system(command.c_str()); 1747 2180 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 1748 TEST_RETURN(compareReturnValue, 1); 2181 TEST_RETURN(compareReturnValue, 2182 BackupQueries:ReturnCode::Compare_Same); 1749 2183 1750 2184 // Compare without attributes. This should fail. 1751 command = BBACKUPQUERY " -c testfiles/bbackupd.conf " 1752 "-q \"compare -cEQ Test1/" + systemDirName + 2185 command = BBACKUPQUERY " " 2186 "-c testfiles/bbackupd.conf " 2187 "-Werror \"compare -cEQ Test1/" + systemDirName + 1753 2188 " testfiles/restore-" + systemDirName + "\" quit"; 1754 1755 2189 compareReturnValue = ::system(command.c_str()); 1756 2190 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 1757 TEST_RETURN(compareReturnValue, 2); 2191 TEST_RETURN(compareReturnValue, 2192 BackupQueries::ReturnCode::Compare_Different); 1758 2193 #endif // WIN32 1759 2194 … … 1832 2267 1833 2268 // check that no backup has run (compare fails) 1834 compareReturnValue = ::system(BBACKUPQUERY " -q " 2269 int compareReturnValue = ::system(BBACKUPQUERY " " 2270 "-Werror " 1835 2271 "-c testfiles/bbackupd.conf " 1836 2272 "-l testfiles/query3.log " 1837 2273 "\"compare -acQ\" quit"); 1838 TEST_RETURN(compareReturnValue, 2); 2274 TEST_RETURN(compareReturnValue, 2275 BackupQueries::ReturnCode::Compare_Different); 1839 2276 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 1840 2277 … … 1852 2289 wait_for_sync_end(); 1853 2290 // check that backup has run (compare succeeds) 1854 compareReturnValue = ::system(BBACKUPQUERY " -q " 2291 compareReturnValue = ::system(BBACKUPQUERY " " 2292 "-Wwarning " 1855 2293 "-c testfiles/bbackupd.conf " 1856 2294 "-l testfiles/query3a.log " 1857 2295 "\"compare -acQ\" quit"); 1858 TEST_RETURN(compareReturnValue, 1); 2296 TEST_RETURN(compareReturnValue, 2297 BackupQueries::ReturnCode::Compare_Same); 1859 2298 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 1860 2299 … … 1901 2340 // wait for backup daemon to do it's stuff, and compare again 1902 2341 wait_for_backup_operation(); 1903 compareReturnValue = ::system(BBACKUPQUERY " -q"2342 int compareReturnValue = ::system(BBACKUPQUERY " -Wwarning " 1904 2343 "-c testfiles/bbackupd.conf " 1905 2344 "-l testfiles/query2.log " 1906 2345 "\"compare -acQ\" quit"); 1907 TEST_RETURN(compareReturnValue, 1); 2346 TEST_RETURN(compareReturnValue, 2347 BackupQueries::ReturnCode::Compare_Same); 1908 2348 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 1909 2349 1910 2350 // Try a quick compare, just for fun 1911 compareReturnValue = ::system(BBACKUPQUERY " -q"2351 compareReturnValue = ::system(BBACKUPQUERY " " 1912 2352 "-c testfiles/bbackupd.conf " 1913 2353 "-l testfiles/query2q.log " 1914 "\"compare -acqQ\" quit"); 1915 TEST_RETURN(compareReturnValue, 1); 2354 "-Wwarning \"compare -acqQ\" quit"); 2355 TEST_RETURN(compareReturnValue, 2356 BackupQueries::ReturnCode::Compare_Same); 1916 2357 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 1917 2358 … … 1923 2364 // Check that store errors are reported neatly 1924 2365 printf("\n==== Create store error\n"); 2366 2367 // break the store 1925 2368 TEST_THAT(::rename("testfiles/0_0/backup/01234567/info.rf", 1926 2369 "testfiles/0_0/backup/01234567/info.rf.bak") == 0); … … 1929 2372 TEST_THAT(::rename("testfiles/0_2/backup/01234567/info.rf", 1930 2373 "testfiles/0_2/backup/01234567/info.rf.bak") == 0); 2374 1931 2375 // Create a file to trigger an upload 1932 2376 { … … 1936 2380 TEST_THAT(write(fd1, "just do it", 10) == 10); 1937 2381 TEST_THAT(close(fd1) == 0); 1938 wait_for_backup_operation(4); 1939 } 1940 // Wait and test... 1941 wait_for_backup_operation(); 1942 // Check that it was reported correctly 2382 } 2383 2384 wait_for_backup_operation(4); 2385 // Check that an error was reported just once 1943 2386 TEST_THAT(TestFileExists("testfiles/notifyran.backup-error.1")); 1944 // Check that the error was only reported once1945 2387 TEST_THAT(!TestFileExists("testfiles/notifyran.backup-error.2")); 1946 // Fix the store 2388 // Now kill bbackupd and start one that's running in 2389 // snapshot mode, check that it automatically syncs after 2390 // an error, without waiting for another sync command. 2391 terminate_bbackupd(bbackupd_pid); 2392 std::string cmd = BBACKUPD " " + bbackupd_args + 2393 " testfiles/bbackupd-snapshot.conf"; 2394 bbackupd_pid = LaunchServer(cmd, "testfiles/bbackupd.pid"); 2395 TEST_THAT(bbackupd_pid != -1 && bbackupd_pid != 0); 2396 ::safe_sleep(1); 2397 TEST_THAT(ServerIsAlive(bbackupd_pid)); 2398 TEST_THAT(ServerIsAlive(bbstored_pid)); 2399 if (!ServerIsAlive(bbackupd_pid)) return 1; 2400 if (!ServerIsAlive(bbstored_pid)) return 1; 2401 2402 sync_and_wait(); 2403 2404 // Check that the error was reported once more 2405 TEST_THAT(TestFileExists("testfiles/notifyran.backup-error.1")); 2406 TEST_THAT(TestFileExists("testfiles/notifyran.backup-error.2")); 2407 TEST_THAT(!TestFileExists("testfiles/notifyran.backup-error.3")); 2408 // Fix the store (so that bbackupquery compare works) 1947 2409 TEST_THAT(::rename("testfiles/0_0/backup/01234567/info.rf.bak", 1948 2410 "testfiles/0_0/backup/01234567/info.rf") == 0); … … 1951 2413 TEST_THAT(::rename("testfiles/0_2/backup/01234567/info.rf.bak", 1952 2414 "testfiles/0_2/backup/01234567/info.rf") == 0); 2415 2416 // Check that we DO get errors on compare (cannot do this 2417 // until after we fix the store, which creates a race) 2418 compareReturnValue = ::system(BBACKUPQUERY " " 2419 "-c testfiles/bbackupd.conf " 2420 "-l testfiles/query3b.log " 2421 "-Werror \"compare -acQ\" quit"); 2422 TEST_RETURN(compareReturnValue, 2423 BackupQueries::ReturnCode::Compare_Different); 2424 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 2425 2426 // Test initial state 2427 TEST_THAT(!TestFileExists("testfiles/" 2428 "notifyran.backup-start.wait-snapshot.1")); 2429 2430 // Set a tag for the notify script to distinguist from 2431 // previous runs. 2432 { 2433 int fd1 = open("testfiles/notifyscript.tag", 2434 O_CREAT | O_EXCL | O_WRONLY, 0700); 2435 TEST_THAT(fd1 > 0); 2436 TEST_THAT(write(fd1, "wait-snapshot", 13) == 13); 2437 TEST_THAT(close(fd1) == 0); 2438 } 2439 2440 // bbackupd should pause for about 90 seconds 2441 wait_for_backup_operation(85); 2442 TEST_THAT(!TestFileExists("testfiles/" 2443 "notifyran.backup-start.wait-snapshot.1")); 2444 2445 // Should not have backed up, should still get errors 2446 compareReturnValue = ::system(BBACKUPQUERY " " 2447 "-c testfiles/bbackupd.conf " 2448 "-l testfiles/query3b.log " 2449 "-Werror \"compare -acQ\" quit"); 2450 TEST_RETURN(compareReturnValue, 2451 BackupQueries::ReturnCode::Compare_Different); 2452 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 2453 2454 // wait another 10 seconds, bbackup should have run 2455 wait_for_backup_operation(10); 2456 TEST_THAT(TestFileExists("testfiles/" 2457 "notifyran.backup-start.wait-snapshot.1")); 1953 2458 1954 // Check that we DO get errors on compare1955 compareReturnValue = ::system(BBACKUPQUERY " -q"2459 // Check that it did get uploaded, and we have no more errors 2460 compareReturnValue = ::system(BBACKUPQUERY " " 1956 2461 "-c testfiles/bbackupd.conf " 1957 2462 "-l testfiles/query3b.log " 1958 "\"compare -acQ\" quit"); 1959 TEST_RETURN(compareReturnValue, 2); 2463 "-Wwarning \"compare -acQ\" quit"); 2464 TEST_RETURN(compareReturnValue, 2465 BackupQueries::ReturnCode::Compare_Same); 1960 2466 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 1961 2467 2468 TEST_THAT(::unlink("testfiles/notifyscript.tag") == 0); 2469 2470 // Stop the snapshot bbackupd 2471 terminate_bbackupd(bbackupd_pid); 2472 2473 // Break the store again 2474 TEST_THAT(::rename("testfiles/0_0/backup/01234567/info.rf", 2475 "testfiles/0_0/backup/01234567/info.rf.bak") == 0); 2476 TEST_THAT(::rename("testfiles/0_1/backup/01234567/info.rf", 2477 "testfiles/0_1/backup/01234567/info.rf.bak") == 0); 2478 TEST_THAT(::rename("testfiles/0_2/backup/01234567/info.rf", 2479 "testfiles/0_2/backup/01234567/info.rf.bak") == 0); 2480 2481 // Modify a file to trigger an upload 2482 { 2483 int fd1 = open("testfiles/TestDir1/force-upload", 2484 O_WRONLY, 0700); 2485 TEST_THAT(fd1 > 0); 2486 TEST_THAT(write(fd1, "and again", 9) == 9); 2487 TEST_THAT(close(fd1) == 0); 2488 } 2489 2490 // Restart the old bbackupd, in automatic mode 2491 cmd = BBACKUPD " " + bbackupd_args + 2492 " testfiles/bbackupd.conf"; 2493 bbackupd_pid = LaunchServer(cmd, "testfiles/bbackupd.pid"); 2494 TEST_THAT(bbackupd_pid != -1 && bbackupd_pid != 0); 2495 ::safe_sleep(1); 1962 2496 TEST_THAT(ServerIsAlive(bbackupd_pid)); 1963 2497 TEST_THAT(ServerIsAlive(bbstored_pid)); … … 1965 2499 if (!ServerIsAlive(bbstored_pid)) return 1; 1966 2500 1967 // Wait until bbackupd recovers from the exception1968 wait_for_backup_operation(100);1969 1970 // Ensure that the force-upload file gets uploaded,1971 // meaning that bbackupd recovered1972 2501 sync_and_wait(); 1973 2502 2503 // Fix the store again 2504 TEST_THAT(::rename("testfiles/0_0/backup/01234567/info.rf.bak", 2505 "testfiles/0_0/backup/01234567/info.rf") == 0); 2506 TEST_THAT(::rename("testfiles/0_1/backup/01234567/info.rf.bak", 2507 "testfiles/0_1/backup/01234567/info.rf") == 0); 2508 TEST_THAT(::rename("testfiles/0_2/backup/01234567/info.rf.bak", 2509 "testfiles/0_2/backup/01234567/info.rf") == 0); 2510 2511 // Check that we DO get errors on compare (cannot do this 2512 // until after we fix the store, which creates a race) 2513 compareReturnValue = ::system(BBACKUPQUERY " " 2514 "-c testfiles/bbackupd.conf " 2515 "-l testfiles/query3b.log " 2516 "-Werror \"compare -acQ\" quit"); 2517 TEST_RETURN(compareReturnValue, 2518 BackupQueries::ReturnCode::Compare_Different); 2519 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 2520 2521 // Test initial state 2522 TEST_THAT(!TestFileExists("testfiles/" 2523 "notifyran.backup-start.wait-automatic.1")); 2524 2525 // Set a tag for the notify script to distinguist from 2526 // previous runs. 2527 { 2528 int fd1 = open("testfiles/notifyscript.tag", 2529 O_CREAT | O_EXCL | O_WRONLY, 0700); 2530 TEST_THAT(fd1 > 0); 2531 TEST_THAT(write(fd1, "wait-automatic", 14) == 14); 2532 TEST_THAT(close(fd1) == 0); 2533 } 2534 2535 // bbackupd should pause for at least 90 seconds 2536 wait_for_backup_operation(85); 2537 TEST_THAT(!TestFileExists("testfiles/" 2538 "notifyran.backup-start.wait-automatic.1")); 2539 2540 // Should not have backed up, should still get errors 2541 compareReturnValue = ::system(BBACKUPQUERY " " 2542 "-c testfiles/bbackupd.conf " 2543 "-l testfiles/query3b.log " 2544 "-Werror \"compare -acQ\" quit"); 2545 TEST_RETURN(compareReturnValue, 2546 BackupQueries::ReturnCode::Compare_Different); 2547 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 2548 2549 // wait another 10 seconds, bbackup should have run 2550 wait_for_backup_operation(10); 2551 TEST_THAT(TestFileExists("testfiles/" 2552 "notifyran.backup-start.wait-automatic.1")); 2553 1974 2554 // Check that it did get uploaded, and we have no more errors 1975 compareReturnValue = ::system(BBACKUPQUERY " -q"2555 compareReturnValue = ::system(BBACKUPQUERY " " 1976 2556 "-c testfiles/bbackupd.conf " 1977 2557 "-l testfiles/query3b.log " 1978 "\"compare -acQ\" quit"); 1979 TEST_RETURN(compareReturnValue, 1); 2558 "-Wwarning \"compare -acQ\" quit"); 2559 TEST_RETURN(compareReturnValue, 2560 BackupQueries::ReturnCode::Compare_Same); 1980 2561 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 2562 2563 TEST_THAT(::unlink("testfiles/notifyscript.tag") == 0); 1981 2564 1982 2565 TEST_THAT(ServerIsAlive(bbackupd_pid)); … … 2009 2592 2010 2593 wait_for_backup_operation(); 2011 compareReturnValue = ::system(BBACKUPQUERY " -q"2594 compareReturnValue = ::system(BBACKUPQUERY " " 2012 2595 "-c testfiles/bbackupd.conf " 2013 2596 "-l testfiles/query3c.log " 2014 "\"compare -acQ\" quit"); 2015 TEST_RETURN(compareReturnValue, 1); 2597 "-Wwarning \"compare -acQ\" quit"); 2598 TEST_RETURN(compareReturnValue, 2599 BackupQueries::ReturnCode::Compare_Same); 2016 2600 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 2017 2601 … … 2037 2621 2038 2622 wait_for_backup_operation(); 2039 compareReturnValue = ::system(BBACKUPQUERY " -q"2623 compareReturnValue = ::system(BBACKUPQUERY " " 2040 2624 "-c testfiles/bbackupd.conf " 2041 2625 "-l testfiles/query3d.log " 2042 "\"compare -acQ\" quit"); 2043 TEST_RETURN(compareReturnValue, 1); 2626 "-Wwarning \"compare -acQ\" quit"); 2627 TEST_RETURN(compareReturnValue, 2628 BackupQueries::ReturnCode::Compare_Same); 2044 2629 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 2045 2630 … … 2068 2653 2069 2654 wait_for_backup_operation(); 2070 compareReturnValue = ::system(BBACKUPQUERY " -q"2655 compareReturnValue = ::system(BBACKUPQUERY " " 2071 2656 "-c testfiles/bbackupd.conf " 2072 2657 "-l testfiles/query3e.log " 2073 "\"compare -acQ\" quit"); 2074 TEST_RETURN(compareReturnValue, 1); 2658 "-Wwarning \"compare -acQ\" quit"); 2659 TEST_RETURN(compareReturnValue, 2660 BackupQueries::ReturnCode::Compare_Same); 2075 2661 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 2076 2662 … … 2099 2685 2100 2686 wait_for_backup_operation(); 2101 compareReturnValue = ::system(BBACKUPQUERY " -q"2687 compareReturnValue = ::system(BBACKUPQUERY " " 2102 2688 "-c testfiles/bbackupd.conf " 2103 2689 "-l testfiles/query3f.log " 2104 "\"compare -acQ\" quit"); 2105 TEST_RETURN(compareReturnValue, 1); 2690 "-Wwarning \"compare -acQ\" quit"); 2691 TEST_RETURN(compareReturnValue, 2692 BackupQueries::ReturnCode::Compare_Same); 2106 2693 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 2107 2694 … … 2130 2717 // back up both files 2131 2718 wait_for_backup_operation(); 2132 compareReturnValue = ::system(BBACKUPQUERY " -q"2719 compareReturnValue = ::system(BBACKUPQUERY " " 2133 2720 "-c testfiles/bbackupd.conf " 2134 2721 "-l testfiles/query3g.log " 2135 "\"compare -acQ\" quit"); 2136 TEST_RETURN(compareReturnValue, 1); 2722 "-Wwarning \"compare -acQ\" quit"); 2723 TEST_RETURN(compareReturnValue, 2724 BackupQueries::ReturnCode::Compare_Same); 2137 2725 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 2138 2726 … … 2147 2735 TEST_THAT( TestFileExists("testfiles/TestDir1/untracked-2")); 2148 2736 wait_for_backup_operation(); 2149 compareReturnValue = ::system(BBACKUPQUERY " -q"2737 compareReturnValue = ::system(BBACKUPQUERY " " 2150 2738 "-c testfiles/bbackupd.conf " 2151 2739 "-l testfiles/query3g.log " 2152 "\"compare -acQ\" quit"); 2153 TEST_RETURN(compareReturnValue, 1); 2740 "-Wwarning \"compare -acQ\" quit"); 2741 TEST_RETURN(compareReturnValue, 2742 BackupQueries::ReturnCode::Compare_Same); 2154 2743 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 2155 2744 … … 2181 2770 // back up both files 2182 2771 wait_for_backup_operation(); 2183 compareReturnValue = ::system(BBACKUPQUERY " -q"2772 compareReturnValue = ::system(BBACKUPQUERY " " 2184 2773 "-c testfiles/bbackupd.conf " 2185 2774 "-l testfiles/query3h.log " 2186 "\"compare -acQ\" quit"); 2187 TEST_RETURN(compareReturnValue, 1); 2775 "-Wwarning \"compare -acQ\" quit"); 2776 TEST_RETURN(compareReturnValue, 2777 BackupQueries::ReturnCode::Compare_Same); 2188 2778 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 2189 2779 … … 2198 2788 TEST_THAT( TestFileExists("testfiles/TestDir1/tracked-2")); 2199 2789 wait_for_backup_operation(); 2200 compareReturnValue = ::system(BBACKUPQUERY " -q"2790 compareReturnValue = ::system(BBACKUPQUERY " " 2201 2791 "-c testfiles/bbackupd.conf " 2202 2792 "-l testfiles/query3i.log " 2203 "\"compare -acQ\" quit"); 2204 TEST_RETURN(compareReturnValue, 1); 2793 "-Wwarning \"compare -acQ\" quit"); 2794 TEST_RETURN(compareReturnValue, 2795 BackupQueries::ReturnCode::Compare_Same); 2205 2796 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 2206 2797 … … 2218 2809 2219 2810 wait_for_backup_operation(); 2220 compareReturnValue = ::system(BBACKUPQUERY " -q"2811 compareReturnValue = ::system(BBACKUPQUERY " " 2221 2812 "-c testfiles/bbackupd.conf " 2222 2813 "-l testfiles/query3j.log " 2223 "\"compare -acQ\" quit"); 2224 TEST_RETURN(compareReturnValue, 1); 2814 "-Wwarning \"compare -acQ\" quit"); 2815 TEST_RETURN(compareReturnValue, 2816 BackupQueries::ReturnCode::Compare_Same); 2225 2817 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 2226 2818 … … 2252 2844 // Wait and test 2253 2845 wait_for_backup_operation(); 2254 compareReturnValue = ::system(BBACKUPQUERY " -q"2846 compareReturnValue = ::system(BBACKUPQUERY " " 2255 2847 "-c testfiles/bbackupd.conf " 2256 2848 "-l testfiles/query3k.log " 2257 "\"compare -acQ\" quit"); 2258 TEST_RETURN(compareReturnValue, 1); 2849 "-Wwarning \"compare -acQ\" quit"); 2850 TEST_RETURN(compareReturnValue, 2851 BackupQueries::ReturnCode::Compare_Same); 2259 2852 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 2260 2853 … … 2310 2903 wait_for_sync_end(); // should (not) be backed up this time 2311 2904 2312 compareReturnValue = ::system(BBACKUPQUERY " -q"2905 compareReturnValue = ::system(BBACKUPQUERY " " 2313 2906 "-c testfiles/bbackupd.conf " 2314 2907 "-l testfiles/query3l.log " 2315 "\"compare -acQ\" quit"); 2316 TEST_RETURN(compareReturnValue, 1); 2908 "-Wwarning \"compare -acQ\" quit"); 2909 TEST_RETURN(compareReturnValue, 2910 BackupQueries::ReturnCode::Compare_Same); 2317 2911 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 2318 2912 … … 2338 2932 2339 2933 // compare with exclusions, should not find differences 2340 compareReturnValue = ::system(BBACKUPQUERY " -q"2934 compareReturnValue = ::system(BBACKUPQUERY " " 2341 2935 "-c testfiles/bbackupd.conf " 2342 2936 "-l testfiles/query3m.log " 2343 "\"compare -acQ\" quit"); 2344 TEST_RETURN(compareReturnValue, 1); 2937 "-Wwarning \"compare -acQ\" quit"); 2938 TEST_RETURN(compareReturnValue, 2939 BackupQueries::ReturnCode::Compare_Same); 2345 2940 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 2346 2941 2347 2942 // compare without exclusions, should find differences 2348 compareReturnValue = ::system(BBACKUPQUERY " -q"2943 compareReturnValue = ::system(BBACKUPQUERY " " 2349 2944 "-c testfiles/bbackupd.conf " 2350 2945 "-l testfiles/query3n.log " 2351 "\"compare -acEQ\" quit"); 2352 TEST_RETURN(compareReturnValue, 2); 2946 "-Werror \"compare -acEQ\" quit"); 2947 TEST_RETURN(compareReturnValue, 2948 BackupQueries::ReturnCode::Compare_Different); 2353 2949 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 2354 2950 … … 2422 3018 // Wait and test... 2423 3019 wait_for_backup_operation(); 2424 compareReturnValue = ::system(BBACKUPQUERY " -q"3020 compareReturnValue = ::system(BBACKUPQUERY " " 2425 3021 "-c testfiles/bbackupd.conf " 2426 3022 "-l testfiles/query3o.log " 2427 " \"compare -acQ\" quit");3023 "-Werror \"compare -acQ\" quit"); 2428 3024 2429 3025 // should find differences 2430 TEST_RETURN(compareReturnValue, 3); 3026 TEST_RETURN(compareReturnValue, 3027 BackupQueries::ReturnCode::Compare_Error); 2431 3028 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 2432 3029 … … 2525 3122 // Wait and test 2526 3123 wait_for_backup_operation(); 2527 compareReturnValue = ::system(BBACKUPQUERY " -q"3124 compareReturnValue = ::system(BBACKUPQUERY " " 2528 3125 "-c testfiles/bbackupd.conf " 2529 3126 "-l testfiles/query4.log " 2530 "\"compare -acQ\" quit"); 2531 TEST_RETURN(compareReturnValue, 1); 3127 "-Werror \"compare -acQ\" quit"); 3128 TEST_RETURN(compareReturnValue, 3129 BackupQueries::ReturnCode::Compare_Same); 2532 3130 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 2533 3131 … … 2574 3172 2575 3173 // Make sure you can't restore to a nonexistant path 2576 printf("\n \n==== Try to restore to a path "3174 printf("\n==== Try to restore to a path " 2577 3175 "that doesn't exist\n"); 2578 3176 fflush(stdout); 2579 TEST_THAT(BackupClientRestore(*client, restoredirid, 2580 "testfiles/no-such-path/subdir", 2581 true /* print progress dots */) 2582 == Restore_TargetPathNotFound); 3177 3178 { 3179 Logging::Guard guard(Log::FATAL); 3180 TEST_THAT(BackupClientRestore(*client, 3181 restoredirid, 3182 "testfiles/no-such-path/subdir", 3183 true /* print progress dots */) 3184 == Restore_TargetPathNotFound); 3185 } 2583 3186 2584 3187 // Log out … … 2588 3191 2589 3192 // Compare the restored files 2590 compareReturnValue = ::system(BBACKUPQUERY " -q"3193 compareReturnValue = ::system(BBACKUPQUERY " " 2591 3194 "-c testfiles/bbackupd.conf " 2592 3195 "-l testfiles/query10.log " 3196 "-Wwarning " 2593 3197 "\"compare -cEQ Test1 testfiles/restore-Test1\" " 2594 3198 "quit"); 2595 TEST_RETURN(compareReturnValue, 1); 3199 TEST_RETURN(compareReturnValue, 3200 BackupQueries::ReturnCode::Compare_Same); 2596 3201 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 2597 3202 … … 2607 3212 TEST_RETURN(compareReturnValue, 0); 2608 3213 2609 compareReturnValue = ::system(BBACKUPQUERY " -q"3214 compareReturnValue = ::system(BBACKUPQUERY " " 2610 3215 "-c testfiles/bbackupd.conf " 2611 3216 "-l testfiles/query10a.log " 3217 "-Werror " 2612 3218 "\"compare -cEQ Test1 testfiles/restore-Test1\" " 2613 3219 "quit"); 2614 TEST_RETURN(compareReturnValue, 2); 3220 TEST_RETURN(compareReturnValue, 3221 BackupQueries::ReturnCode::Compare_Different); 2615 3222 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 2616 3223 … … 2620 3227 TEST_RETURN(compareReturnValue, 0); 2621 3228 2622 compareReturnValue = ::system(BBACKUPQUERY " -q"3229 compareReturnValue = ::system(BBACKUPQUERY " " 2623 3230 "-c testfiles/bbackupd.conf -l testfiles/query10a.log " 3231 "-Wwarning " 2624 3232 "\"compare -cEQ Test1 testfiles/restore-Test1\" " 2625 3233 "quit"); 2626 TEST_RETURN(compareReturnValue, 1); 3234 TEST_RETURN(compareReturnValue, 3235 BackupQueries::ReturnCode::Compare_Same); 2627 3236 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 2628 3237 … … 2644 3253 TEST_THAT(set_file_time(testfile, dummyTime, lastModTime, 2645 3254 lastAccessTime)); 2646 compareReturnValue = ::system(BBACKUPQUERY " -q"3255 compareReturnValue = ::system(BBACKUPQUERY " " 2647 3256 "-c testfiles/bbackupd.conf " 2648 3257 "-l testfiles/query10a.log " 3258 "-Werror " 2649 3259 "\"compare -cEQ Test1 testfiles/restore-Test1\" " 2650 3260 "quit"); 2651 TEST_RETURN(compareReturnValue, 2); 3261 TEST_RETURN(compareReturnValue, 3262 BackupQueries::ReturnCode::Compare_Different); 2652 3263 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 2653 3264 … … 2655 3266 TEST_THAT(set_file_time(testfile, creationTime, lastModTime, 2656 3267 dummyTime)); 2657 compareReturnValue = ::system(BBACKUPQUERY " -q"3268 compareReturnValue = ::system(BBACKUPQUERY " " 2658 3269 "-c testfiles/bbackupd.conf " 2659 3270 "-l testfiles/query10a.log " 3271 "-Wwarning " 2660 3272 "\"compare -cEQ Test1 testfiles/restore-Test1\" " 2661 3273 "quit"); 2662 TEST_RETURN(compareReturnValue, 1); 3274 TEST_RETURN(compareReturnValue, 3275 BackupQueries::ReturnCode::Compare_Same); 2663 3276 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 2664 3277 … … 2667 3280 TEST_THAT(set_file_time(testfile, creationTime, dummyTime, 2668 3281 lastAccessTime)); 2669 compareReturnValue = ::system(BBACKUPQUERY " -q"3282 compareReturnValue = ::system(BBACKUPQUERY " " 2670 3283 "-c testfiles/bbackupd.conf " 2671 3284 "-l testfiles/query10a.log " 3285 "-Werror " 2672 3286 "\"compare -cEQ Test1 testfiles/restore-Test1\" " 2673 3287 "quit"); 2674 TEST_RETURN(compareReturnValue, 2); 3288 TEST_RETURN(compareReturnValue, 3289 BackupQueries::ReturnCode::Compare_Different); 2675 3290 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 2676 3291 … … 2678 3293 TEST_THAT(set_file_time(testfile, creationTime, lastModTime, 2679 3294 lastAccessTime)); 2680 compareReturnValue = ::system(BBACKUPQUERY " -q"3295 compareReturnValue = ::system(BBACKUPQUERY " " 2681 3296 "-c testfiles/bbackupd.conf " 2682 3297 "-l testfiles/query10a.log " 3298 "-Wwarning " 2683 3299 "\"compare -cEQ Test1 testfiles/restore-Test1\" " 2684 3300 "quit"); 2685 TEST_RETURN(compareReturnValue, 1); 3301 TEST_RETURN(compareReturnValue, 3302 BackupQueries::ReturnCode::Compare_Same); 2686 3303 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 2687 3304 #endif // WIN32 … … 2706 3323 // Wait and test 2707 3324 wait_for_backup_operation(); 2708 compareReturnValue = ::system(BBACKUPQUERY " -q"3325 compareReturnValue = ::system(BBACKUPQUERY " " 2709 3326 "-c testfiles/bbackupd.conf " 2710 3327 "-l testfiles/query5.log " 2711 "\"compare -acQ\" quit"); 2712 TEST_RETURN(compareReturnValue, 1); 3328 "-Wwarning \"compare -acQ\" quit"); 3329 TEST_RETURN(compareReturnValue, 3330 BackupQueries::ReturnCode::Compare_Same); 2713 3331 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 2714 3332 … … 2723 3341 "testfiles/TestDir1/renamed-dir") == 0); 2724 3342 wait_for_backup_operation(); 2725 compareReturnValue = ::system(BBACKUPQUERY " -q"3343 compareReturnValue = ::system(BBACKUPQUERY " " 2726 3344 "-c testfiles/bbackupd.conf " 2727 3345 "-l testfiles/query6.log " 2728 "\"compare -acQ\" quit"); 2729 TEST_RETURN(compareReturnValue, 1); 3346 "-Wwarning \"compare -acQ\" quit"); 3347 TEST_RETURN(compareReturnValue, 3348 BackupQueries::ReturnCode::Compare_Same); 2730 3349 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 2731 3350 2732 3351 // and again, but with quick flag 2733 compareReturnValue = ::system(BBACKUPQUERY " -q"3352 compareReturnValue = ::system(BBACKUPQUERY " " 2734 3353 "-c testfiles/bbackupd.conf " 2735 3354 "-l testfiles/query6q.log " 2736 "\"compare -acqQ\" quit"); 2737 TEST_RETURN(compareReturnValue, 1); 3355 "-Wwarning \"compare -acqQ\" quit"); 3356 TEST_RETURN(compareReturnValue, 3357 BackupQueries::ReturnCode::Compare_Same); 2738 3358 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 2739 3359 … … 2747 3367 "testfiles/TestDir1/find2perl-ren") == 0); 2748 3368 wait_for_backup_operation(); 2749 compareReturnValue = ::system(BBACKUPQUERY " -q"3369 compareReturnValue = ::system(BBACKUPQUERY " " 2750 3370 "-c testfiles/bbackupd.conf " 2751 3371 "-l testfiles/query6.log " 2752 "\"compare -acQ\" quit"); 2753 TEST_RETURN(compareReturnValue, 1); 3372 "-Wwarning \"compare -acQ\" quit"); 3373 TEST_RETURN(compareReturnValue, 3374 BackupQueries::ReturnCode::Compare_Same); 2754 3375 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 2755 3376 … … 2789 3410 // Wait and test 2790 3411 wait_for_backup_operation(); 2791 compareReturnValue = ::system(BBACKUPQUERY " -q"3412 compareReturnValue = ::system(BBACKUPQUERY " " 2792 3413 "-c testfiles/bbackupd.conf " 2793 3414 "-l testfiles/query3e.log " 2794 "\"compare -acQ\" quit"); 2795 TEST_RETURN(compareReturnValue, 1); 3415 "-Wwarning \"compare -acQ\" quit"); 3416 TEST_RETURN(compareReturnValue, 3417 BackupQueries::ReturnCode::Compare_Same); 2796 3418 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 2797 3419 … … 2857 3479 wait_for_backup_operation((TIME_TO_WAIT_FOR_BACKUP_OPERATION * 2858 3480 3) / 2); // little bit longer than usual 2859 compareReturnValue = ::system(BBACKUPQUERY " -q"3481 compareReturnValue = ::system(BBACKUPQUERY " " 2860 3482 "-c testfiles/bbackupd.conf " 2861 3483 "-l testfiles/query6.log " 2862 "\"compare -acQ\" quit"); 2863 TEST_RETURN(compareReturnValue, 2); 3484 "-Werror \"compare -acQ\" quit"); 3485 TEST_RETURN(compareReturnValue, 3486 BackupQueries::ReturnCode::Compare_Different); 2864 3487 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 2865 3488 … … 2915 3538 2916 3539 // Then check it has restored the correct stuff 2917 compareReturnValue = ::system(BBACKUPQUERY " -q"3540 compareReturnValue = ::system(BBACKUPQUERY " " 2918 3541 "-c testfiles/bbackupd.conf " 2919 3542 "-l testfiles/query14.log " 2920 " \"compare -cEQ Test1 "3543 "-Wwarning \"compare -cEQ Test1 " 2921 3544 "testfiles/restore-interrupt\" quit"); 2922 TEST_RETURN(compareReturnValue, 1); 3545 TEST_RETURN(compareReturnValue, 3546 BackupQueries::ReturnCode::Compare_Same); 2923 3547 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 2924 3548 } … … 2948 3572 2949 3573 // Do a compare with the now undeleted files 2950 compareReturnValue = ::system(BBACKUPQUERY " -q"3574 compareReturnValue = ::system(BBACKUPQUERY " " 2951 3575 "-c testfiles/bbackupd.conf " 2952 3576 "-l testfiles/query11.log " 3577 "-Wwarning " 2953 3578 "\"compare -cEQ Test1/x1 " 2954 3579 "testfiles/restore-Test1-x1-2\" quit"); 2955 TEST_RETURN(compareReturnValue, 1); 3580 TEST_RETURN(compareReturnValue, 3581 BackupQueries::ReturnCode::Compare_Same); 2956 3582 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 2957 3583 } … … 3003 3629 // compare, and check that it works 3004 3630 // reports the correct error message (and finishes) 3005 compareReturnValue = ::system(BBACKUPQUERY " -q"3631 compareReturnValue = ::system(BBACKUPQUERY " " 3006 3632 "-c testfiles/bbackupd.conf " 3007 3633 "-l testfiles/query15a.log " 3008 "\"compare -acQ\" quit"); 3009 TEST_RETURN(compareReturnValue, 1); 3634 "-Wwarning \"compare -acQ\" quit"); 3635 TEST_RETURN(compareReturnValue, 3636 BackupQueries::ReturnCode::Compare_Same); 3010 3637 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 3011 3638 … … 3016 3643 TEST_THAT(handle != INVALID_HANDLE_VALUE); 3017 3644 3018 compareReturnValue = ::system(BBACKUPQUERY 3019 " -q-c testfiles/bbackupd.conf "3645 compareReturnValue = ::system(BBACKUPQUERY " " 3646 "-c testfiles/bbackupd.conf " 3020 3647 "-l testfiles/query15.log " 3021 "\"compare -acQ\" quit"); 3022 TEST_RETURN(compareReturnValue, 3); 3648 "-Werror \"compare -acQ\" quit"); 3649 TEST_RETURN(compareReturnValue, 3650 BackupQueries::ReturnCode::Compare_Error); 3023 3651 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 3024 3652 … … 3027 3655 CloseHandle(handle); 3028 3656 3029 compareReturnValue = ::system(BBACKUPQUERY " -q"3657 compareReturnValue = ::system(BBACKUPQUERY " " 3030 3658 "-c testfiles/bbackupd.conf " 3031 3659 "-l testfiles/query15a.log " 3032 "\"compare -acQ\" quit"); 3033 TEST_RETURN(compareReturnValue, 1); 3660 "-Wwarning \"compare -acQ\" quit"); 3661 TEST_RETURN(compareReturnValue, 3662 BackupQueries::ReturnCode::Compare_Same); 3034 3663 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 3035 3664 } … … 3056 3685 wait_for_backup_operation( 3057 3686 (TIME_TO_WAIT_FOR_BACKUP_OPERATION*3) / 2); 3058 compareReturnValue = ::system(BBACKUPQUERY " -q"3687 compareReturnValue = ::system(BBACKUPQUERY " " 3059 3688 "-c testfiles/bbackupd.conf " 3060 3689 "-l testfiles/query4a.log " 3061 "\"compare -acQ\" quit"); 3062 TEST_RETURN(compareReturnValue, 1); 3690 "-Wwarning \"compare -acQ\" quit"); 3691 TEST_RETURN(compareReturnValue, 3692 BackupQueries::ReturnCode::Compare_Same); 3063 3693 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 3064 3694 … … 3068 3698 } 3069 3699 3070 // List the files on the server 3700 /* 3701 // List the files on the server - why? 3071 3702 ::system(BBACKUPQUERY " -q -c testfiles/bbackupd.conf " 3072 3703 "-l testfiles/queryLIST.log \"list -rotdh\" quit"); 3073 3704 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 3705 */ 3074 3706 3075 3707 #ifndef WIN32 -
box/trunk/test/bbackupd/testfiles/extcheck1.pl.in
r2056 r2184 4 4 my $flags = $ARGV[0] or ""; 5 5 6 unless(open IN,"../../bin/bbackupquery/bbackupquery -q -c testfiles/bbackupd.conf -l testfiles/query4.log \"compare -ac$flags\" quit 2>&1 |") 6 unless(open IN,"../../bin/bbackupquery/bbackupquery -Wwarning " . 7 "-c testfiles/bbackupd.conf " . 8 "-l testfiles/query4.log " . 9 "\"compare -ac$flags\" quit 2>&1 |") 7 10 { 8 11 print "Couldn't open compare utility\n"; -
box/trunk/test/bbackupd/testfiles/extcheck2.pl.in
r2056 r2184 4 4 my $flags = $ARGV[0] or ""; 5 5 6 unless(open IN,"../../bin/bbackupquery/bbackupquery -q -c testfiles/bbackupd.conf -l testfiles/query4.log \"compare -ac$flags\" quit 2>&1 |") 6 unless(open IN,"../../bin/bbackupquery/bbackupquery -Wwarning " . 7 "-c testfiles/bbackupd.conf " . 8 "-l testfiles/query4.log " . 9 "\"compare -ac$flags\" quit 2>&1 |") 7 10 { 8 11 print "Couldn't open compare utility\n";
Note: See TracChangeset
for help on using the changeset viewer.
