Changeset 2184


Ignore:
Timestamp:
28/05/2008 16:35:42 (4 years ago)
Author:
chris
Message:

Add bbackupquery -W<level> option to set explicit warning level,

Obsolete old (inconsistent) meaning of -q in bbackupquery.

Replace -q with -Wwarning or -Werror in tests to reduce noise and fix
tests.

Test that reading a nonexistent directory on the server doesn't crash
server or client.

Test that bbackupd does continue backup run and delete files when
storage limit is exceeded.

Use logging guards to hide expected warnings in testbbackupd.

Remove apparently pointless listing files on server at the end of
testbbackupd.

Location:
box/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • box/trunk/bin/bbackupquery/bbackupquery.cpp

    r2149 r2184  
    108108         
    109109        // Flags 
    110         bool quiet = false; 
    111110        bool readWrite = false; 
    112111 
     
    120119 
    121120#ifdef WIN32 
    122         const char* validOpts = "qvwuc:l:"; 
     121        const char* validOpts = "qvwuc:l:W:"; 
    123122        bool unicodeConsole = false; 
    124123#else 
    125         const char* validOpts = "qvwc:l:"; 
     124        const char* validOpts = "qvwc:l:W:"; 
    126125#endif 
    127126 
     
    134133                        case 'q': 
    135134                        { 
    136                                 // Quiet mode 
    137                                 quiet = true; 
    138  
    139135                                if(masterLevel == Log::NOTHING) 
    140136                                { 
     
    161157                        break; 
    162158 
     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 
    163170                case 'w': 
    164171                        // Read/write mode 
     
    198205        Logging::SetGlobalLevel((Log::Level)masterLevel); 
    199206 
     207        bool quiet = false; 
     208        if (masterLevel < Log::NOTICE) 
     209        { 
     210                // Quiet mode 
     211                quiet = true; 
     212        } 
     213 
    200214        // Print banner? 
    201215        if(!quiet) 
  • box/trunk/test/backupstorefix/testbackupstorefix.cpp

    r2096 r2184  
    339339                 
    340340                // Generate a list of all the object IDs 
    341                 TEST_THAT_ABORTONFAIL(::system(BBACKUPQUERY " -q " 
     341                TEST_THAT_ABORTONFAIL(::system(BBACKUPQUERY " -Wwarning " 
    342342                        "-c testfiles/bbackupd.conf \"list -r\" quit " 
    343343                        "> testfiles/initial-listing.txt") == 0); 
  • box/trunk/test/backupstorefix/testfiles/testbackupstorefix.pl.in

    r930 r2184  
    9494 
    9595        # 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"; 
    98102        my $err = 0; 
    99103        while(<LISTING>) 
     
    126130elsif($ARGV[0] eq 'reroot') 
    127131{ 
    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"; 
    130138        my $err = 0; 
    131139        my $count = 0; 
  • box/trunk/test/bbackupd/testbbackupd.cpp

    r2127 r2184  
    4444#include "BackupDaemon.h" 
    4545#include "BackupDaemonConfigVerify.h" 
     46#include "BackupQueries.h" 
    4647#include "BackupStoreConstants.h" 
    4748#include "BackupStoreDirectory.h" 
     
    8384#define TEST_EQUAL(expected, found, line) \ 
    8485{ \ 
    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        \ 
    8794        TEST_THAT(exp_str == found_str); \ 
     95        std::string _line = line; \ 
     96        \ 
    8897        if(exp_str != found_str) \ 
    8998        { \ 
    9099                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()); \ 
    92101        } \ 
    93102} 
     
    337346         
    338347        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        } 
    340353 
    341354        // Create some more files 
     
    354367 
    355368#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        } 
    358376 
    359377        // Test that attributes are vaguely similar 
     
    651669        // ensure that no child processes end up running tests! 
    652670        int own_pid = getpid(); 
     671        BOX_TRACE("Test PID is " << own_pid); 
    653672                 
    654673        // this is a quick hack to allow passing some options to the daemon 
     
    670689        } 
    671690         
    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"); 
    677692         
    678693        // ensure that no child processes end up running tests! 
    679         TEST_THAT(getpid() == own_pid); 
     694        TEST_EQUAL(own_pid, getpid(), "Forking test problem"); 
    680695        if (getpid() != own_pid) 
    681696        { 
     
    800815#endif 
    801816{ 
    802         // TRACE1("lstat hook triggered for %s", file_name);             
     817        // TRACE1("lstat hook triggered for %s", file_name); 
    803818        memset(buf, 0, sizeof(*buf)); 
    804819        buf->st_mode = S_IFREG; 
    805820        return 0; 
     821} 
     822 
     823// Simulate a symlink that is on a different device than the file 
     824// that it points to. 
     825int 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 
     836bool 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; 
    806849} 
    807850 
     
    818861                        "testfiles/clientPrivKey.pem", 
    819862                        "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        } 
    820880 
    821881        // unpack the files for the initial test 
     
    853913                memset(buffer, 0, sizeof(buffer)); 
    854914 
    855                 TEST_THAT(write(fd, buffer, sizeof(buffer)) == sizeof(buffer)); 
     915                TEST_EQUAL(sizeof(buffer), write(fd, buffer, sizeof(buffer)), 
     916                        "Buffer write"); 
    856917                TEST_THAT(close(fd) == 0); 
    857918                 
     
    868929 
    869930                pid = start_internal_daemon(); 
     931                intercept_clear_setup(); 
    870932                 
    871933                fd = open("testfiles/TestDir1/spacetest/f1", O_WRONLY); 
    872934                TEST_THAT(fd > 0); 
    873935                // 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"); 
    875938                TEST_THAT(close(fd) == 0);       
    876939 
     
    9381001                        0, 4000, SYS_read, 1); 
    9391002                pid = start_internal_daemon(); 
     1003                intercept_clear_setup(); 
    9401004                 
    9411005                fd = open("testfiles/TestDir1/spacetest/f1", O_WRONLY); 
    9421006                TEST_THAT(fd > 0); 
    9431007                // 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"); 
    9451010                TEST_THAT(close(fd) == 0);       
    9461011 
     
    9711036                        TEST_THAT(reader.GetLine(line)); 
    9721037                        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); 
    9741039                        TEST_THAT(reader.GetLine(line)); 
    975                         TEST_THAT(line == "Receiving stream, size 124"); 
     1040                        TEST_EQUAL("Receiving stream, size 124", line, line); 
    9761041 
    9771042                        // delaying for 4 seconds in one step means that 
     
    9981063                        0, 1000, SYS_read, 3); 
    9991064                pid = start_internal_daemon(); 
     1065                intercept_clear_setup(); 
    10001066                 
    10011067                fd = open("testfiles/TestDir1/spacetest/f1", O_WRONLY); 
    10021068                TEST_THAT(fd > 0); 
    10031069                // 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"); 
    10051072                TEST_THAT(close(fd) == 0);       
    10061073 
     
    10311098                        TEST_THAT(reader.GetLine(line)); 
    10321099                        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); 
    10341101                        TEST_THAT(reader.GetLine(line)); 
    1035                         TEST_THAT(line == "Receiving stream, size 124"); 
     1102                        TEST_EQUAL("Receiving stream, size 124", line, line); 
    10361103 
    10371104                        // delaying for 3 seconds in steps of 1 second 
     
    10421109                         
    10431110                        TEST_THAT(reader.GetLine(line)); 
    1044                         TEST_THAT(line == "Send GetIsAlive()"); 
     1111                        TEST_EQUAL("Send GetIsAlive()", line, line); 
    10451112                        TEST_THAT(reader.GetLine(line)); 
    1046                         TEST_THAT(line == "Receive IsAlive()"); 
     1113                        TEST_EQUAL("Receive IsAlive()", line, line); 
    10471114                        TEST_THAT(reader.GetLine(line)); 
    1048                         TEST_THAT(line == "Send GetIsAlive()"); 
     1115                        TEST_EQUAL("Send GetIsAlive()", line, line); 
    10491116                        TEST_THAT(reader.GetLine(line)); 
    1050                         TEST_THAT(line == "Receive IsAlive()"); 
     1117                        TEST_EQUAL("Receive IsAlive()", line, line); 
    10511118 
    10521119                        // but two matching blocks should have been found 
     
    10791146 
    10801147                pid = start_internal_daemon(); 
     1148                intercept_clear_setup(); 
    10811149                 
    10821150                std::string touchfile =  
     
    10861154                TEST_THAT(fd > 0); 
    10871155                // 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"); 
    10891158                TEST_THAT(close(fd) == 0);       
    10901159 
     
    11591228 
    11601229        std::string cmd = BBACKUPD " " + bbackupd_args +  
    1161                 " testfiles/bbackupd-temploc.conf"; 
     1230                " testfiles/bbackupd.conf"; 
    11621231 
    11631232        bbackupd_pid = LaunchServer(cmd, "testfiles/bbackupd.pid"); 
     
    11691238        if (!ServerIsAlive(bbackupd_pid)) return 1; 
    11701239        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        } 
    11711602 
    11721603        #ifndef WIN32 
     
    12051636 
    12061637                // Check that the backup was successful, i.e. no differences 
    1207                 int compareReturnValue = ::system(BBACKUPQUERY " -q " 
     1638                int compareReturnValue = ::system(BBACKUPQUERY " " 
    12081639                        "-c testfiles/bbackupd.conf " 
    12091640                        "-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); 
    12121644                TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
    12131645 
     
    12281660                compareReturnValue = ::system(BBACKUPQUERY " " 
    12291661                        "-c testfiles/bbackupd.conf " 
    1230                         "-q \"restore Test1 testfiles/restore-symlink\" " 
     1662                        "-Wwarning \"restore Test1 testfiles/restore-symlink\" " 
    12311663                        "quit"); 
    1232                 TEST_RETURN(compareReturnValue, 0); 
     1664                TEST_RETURN(compareReturnValue, 
     1665                        BackupQueries::ReturnCode::Command_OK); 
    12331666 
    12341667                // make it accessible again 
     
    12411674                TEST_THAT(gl.GetLine(line)); 
    12421675                TEST_THAT(line != "before"); 
    1243                 TEST_THAT(line == "after"); 
     1676                TEST_EQUAL("after", line, line); 
    12441677 
    12451678                #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                */ 
    12461721 
    12471722                bbackupd_pid = LaunchServer(cmd, "testfiles/bbackupd.pid"); 
     
    12581733        printf("\n==== Testing that redundant locations are deleted on time\n"); 
    12591734 
     1735        // BLOCK 
    12601736        { 
    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  
    12831737                // Kill the daemon 
    12841738                terminate_bbackupd(bbackupd_pid); 
    12851739 
    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 
    12881745                bbackupd_pid = LaunchServer(cmd, "testfiles/bbackupd.pid"); 
    1289  
    12901746                TEST_THAT(bbackupd_pid != -1 && bbackupd_pid != 0); 
    1291  
    12921747                ::safe_sleep(1); 
    12931748 
     
    12971752                if (!ServerIsAlive(bbstored_pid)) return 1; 
    12981753 
    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(); 
    13031755 
    13041756                { 
     
    13121764                        int64_t testDirId = SearchDir(*dir, "Test2"); 
    13131765                        TEST_THAT(testDirId != 0); 
     1766 
    13141767                        client->QueryFinished(); 
    13151768                        sSocket.Close(); 
    13161769                } 
    13171770 
     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) 
    13181789                wait_for_sync_end(); 
     1790                wait_for_sync_end(); 
     1791                wait_for_sync_end(); 
     1792 
     1793                // not yet! should still be there 
    13191794 
    13201795                { 
     
    13291804                        TEST_THAT(testDirId != 0); 
    13301805 
    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 
    13381825                        client->QueryFinished(); 
    13391826                        sSocket.Close(); 
     
    13481835        if(bbackupd_pid > 0) 
    13491836        { 
    1350                 printf("\n==== Testing that backup pauses when store is full\n"); 
    1351  
    1352                 // wait for files to be uploaded 
    1353                 wait_for_backup_operation(); 
    1354  
    1355                 // Set limit to something very small 
    1356                 // About 28 blocks will be used at this point. bbackupd  
    1357                 // will only pause if the size used is greater than  
    1358                 // soft limit + 1/3 of (hard - soft). Set small values 
    1359                 // 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 files 
    1366                 #ifdef WIN32 
    1367                         TEST_THAT(::system("tar xzvf testfiles/spacetest2.tgz " 
    1368                                 "-C testfiles/TestDir1") == 0); 
    1369                 #else 
    1370                         TEST_THAT(::system("gzip -d < testfiles/spacetest2.tgz " 
    1371                                 "| ( cd testfiles/TestDir1 && tar xf - )") == 0); 
    1372                 #endif 
    1373  
    1374                 // Delete a file and a directory 
    1375                 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 differences 
    1380                 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 back 
    1388                 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 run 
    1394                 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 again 
    1399                 #ifdef WIN32 
    1400                         TEST_THAT(::system("tar xzvf testfiles/test_base.tgz " 
    1401                                 "-C testfiles") == 0); 
    1402                 #else 
    1403                         TEST_THAT(::system("gzip -d < testfiles/test_base.tgz " 
    1404                                 "| ( cd testfiles && tar xf - )") == 0); 
    1405                 #endif 
    1406  
    1407                 // wait for it to do it's stuff 
    1408                 wait_for_backup_operation(); 
    1409                  
    1410                 // Check that the contents of the store are the same  
    1411                 // as the contents of the disc  
    1412                 // (-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  
    14261837                printf("\n==== Check that read-only directories and " 
    14271838                        "their contents can be restored.\n"); 
     
    14391850                        wait_for_sync_end(); // should be backed up now 
    14401851 
    1441                         compareReturnValue = ::system(BBACKUPQUERY " " 
     1852                        int compareReturnValue = ::system(BBACKUPQUERY " " 
     1853                                "-Wwarning " 
    14421854                                "-c testfiles/bbackupd.conf " 
    1443                                 "-q \"compare -cEQ Test1 testfiles/TestDir1\" "  
     1855                                "\"compare -cEQ Test1 testfiles/TestDir1\" "  
    14441856                                "quit"); 
    1445                         TEST_RETURN(compareReturnValue, 1); 
     1857                        TEST_RETURN(compareReturnValue, 
     1858                                BackupQueries::ReturnCode::Compare_Same); 
    14461859                        TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
    14471860 
    14481861                        // check that we can restore it 
    14491862                        compareReturnValue = ::system(BBACKUPQUERY " " 
     1863                                "-Wwarning " 
    14501864                                "-c testfiles/bbackupd.conf " 
    1451                                 "-q \"restore Test1 testfiles/restore1\" " 
     1865                                "\"restore Test1 testfiles/restore1\" " 
    14521866                                "quit"); 
    1453                         TEST_RETURN(compareReturnValue, 0); 
     1867                        TEST_RETURN(compareReturnValue, 
     1868                                BackupQueries::ReturnCode::Command_OK); 
    14541869                        TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
    14551870 
    14561871                        // check that it restored properly 
    14571872                        compareReturnValue = ::system(BBACKUPQUERY " " 
     1873                                "-Wwarning " 
    14581874                                "-c testfiles/bbackupd.conf " 
    1459                                 "-q \"compare -cEQ Test1 testfiles/restore1\" "  
     1875                                "\"compare -cEQ Test1 testfiles/restore1\" "  
    14601876                                "quit"); 
    1461                         TEST_RETURN(compareReturnValue, 1); 
     1877                        TEST_RETURN(compareReturnValue, 
     1878                                BackupQueries::ReturnCode::Compare_Same); 
    14621879                        TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
    14631880 
     
    15141931 
    15151932                char cwdbuf[1024]; 
    1516                 TEST_THAT(getcwd(cwdbuf, sizeof(cwdbuf)) == cwdbuf); 
     1933                TEST_EQUAL(cwdbuf, getcwd(cwdbuf, sizeof(cwdbuf)), "getcwd"); 
    15171934                std::string cwd = cwdbuf; 
    15181935 
     
    15451962                // test that bbackupd will let us lcd into the local  
    15461963                // directory using a relative path 
    1547                 std::string command = BBACKUPQUERY " -q " 
     1964                std::string command = BBACKUPQUERY " " 
     1965                        "-Wwarning " 
    15481966                        "-c testfiles/bbackupd.conf " 
    15491967                        "\"lcd testfiles/TestDir1/" + systemDirName + "\" " 
    15501968                        "quit"; 
    15511969                compareReturnValue = ::system(command.c_str()); 
    1552                 TEST_RETURN(compareReturnValue, 0); 
     1970                TEST_RETURN(compareReturnValue, 
     1971                        BackupQueries::ReturnCode::Command_OK); 
    15531972 
    15541973                // and back out again 
    1555                 command = BBACKUPQUERY " -q " 
     1974                command = BBACKUPQUERY " " 
     1975                        "-Wwarning " 
    15561976                        "-c testfiles/bbackupd.conf " 
    15571977                        "\"lcd testfiles/TestDir1/" + systemDirName + "\" " 
    15581978                        "\"lcd ..\" quit"; 
    15591979                compareReturnValue = ::system(command.c_str()); 
    1560                 TEST_RETURN(compareReturnValue, 0); 
     1980                TEST_RETURN(compareReturnValue, 
     1981                        BackupQueries::ReturnCode::Command_OK); 
    15611982 
    15621983                // and using an absolute path 
    1563                 command = BBACKUPQUERY " -q " 
     1984                command = BBACKUPQUERY " " 
     1985                        "-Wwarning " 
    15641986                        "-c testfiles/bbackupd.conf " 
    15651987                        "\"lcd " + cwd + "/testfiles/TestDir1/" +  
    15661988                        systemDirName + "\" quit"; 
    15671989                compareReturnValue = ::system(command.c_str()); 
    1568                 TEST_RETURN(compareReturnValue, 0); 
     1990                TEST_RETURN(compareReturnValue, 
     1991                        BackupQueries::ReturnCode::Command_OK); 
    15691992 
    15701993                // and back out again 
    1571                 command = BBACKUPQUERY " -q " 
     1994                command = BBACKUPQUERY " " 
     1995                        "-Wwarning " 
    15721996                        "-c testfiles/bbackupd.conf " 
    15731997                        "\"lcd " + cwd + "/testfiles/TestDir1/" +  
     
    15751999                        "\"lcd ..\" quit"; 
    15762000                compareReturnValue = ::system(command.c_str()); 
    1577                 TEST_RETURN(compareReturnValue, 0); 
     2001                TEST_RETURN(compareReturnValue, 
     2002                        BackupQueries::ReturnCode::Command_OK); 
    15782003 
    15792004                { 
     
    15822007                        std::string data("hello world\n"); 
    15832008                        fs.Write(data.c_str(), data.size()); 
    1584                         TEST_THAT(fs.GetPosition() == 12); 
     2009                        TEST_EQUAL(12, fs.GetPosition(), "FileStream position"); 
    15852010                        fs.Close(); 
    15862011                } 
     
    15882013                wait_for_backup_operation(); 
    15892014                // Compare to check that the file was uploaded 
    1590                 compareReturnValue = ::system(BBACKUPQUERY " -q " 
     2015                compareReturnValue = ::system(BBACKUPQUERY " -Wwarning " 
    15912016                        "-c testfiles/bbackupd.conf \"compare -acQ\" quit"); 
    1592                 TEST_RETURN(compareReturnValue, 1); 
     2017                TEST_RETURN(compareReturnValue, 
     2018                        BackupQueries::ReturnCode::Compare_Same); 
    15932019                TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
    15942020 
     
    16162042                } 
    16172043 
    1618  
    16192044                // Check that bbackupquery shows the dir in console encoding 
    1620                 command = BBACKUPQUERY " -q " 
     2045                command = BBACKUPQUERY " -Wwarning " 
    16212046                        "-c testfiles/bbackupd.conf " 
    16222047                        "-q \"list Test1\" quit"; 
     
    16482073                // the file in console encoding 
    16492074                command = BBACKUPQUERY " -c testfiles/bbackupd.conf " 
    1650                         "-q \"list Test1/" + systemDirName + "\" quit"; 
     2075                        "-Wwarning \"list Test1/" + systemDirName + "\" quit"; 
    16512076                queryout = LocalProcessStream(command.c_str(),  
    16522077                        bbackupquery_pid); 
     
    16722097                // on the command line in system encoding. 
    16732098                command = BBACKUPQUERY " -c testfiles/bbackupd.conf " 
    1674                         "-q \"compare -cEQ Test1/" + systemDirName + 
     2099                        "-Wwarning \"compare -cEQ Test1/" + systemDirName + 
    16752100                        " testfiles/TestDir1/" + systemDirName + "\" quit"; 
    16762101 
    16772102                compareReturnValue = ::system(command.c_str()); 
    16782103                TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
    1679                 TEST_RETURN(compareReturnValue, 1); 
     2104                TEST_RETURN(compareReturnValue, 
     2105                        BackupQueries:ReturnCode::Compare_Same); 
    16802106 
    16812107                // Check that bbackupquery can restore the dir when given 
    16822108                // on the command line in system encoding. 
    16832109                command = BBACKUPQUERY " -c testfiles/bbackupd.conf " 
    1684                         "-q \"restore Test1/" + systemDirName + 
     2110                        "-Wwarning \"restore Test1/" + systemDirName + 
    16852111                        " testfiles/restore-" + systemDirName + "\" quit"; 
    16862112 
    16872113                compareReturnValue = ::system(command.c_str()); 
    16882114                TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
    1689                 TEST_RETURN(compareReturnValue, 0); 
     2115                TEST_RETURN(compareReturnValue, 
     2116                        BackupQueries:ReturnCode::Command_OK); 
    16902117 
    16912118                // Compare to make sure it was restored properly. 
    16922119                command = BBACKUPQUERY " -c testfiles/bbackupd.conf " 
    1693                         "-q \"compare -cEQ Test1/" + systemDirName + 
     2120                        "-Wwarning \"compare -cEQ Test1/" + systemDirName + 
    16942121                        " testfiles/restore-" + systemDirName + "\" quit"; 
    16952122 
    16962123                compareReturnValue = ::system(command.c_str()); 
    16972124                TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
    1698                 TEST_RETURN(compareReturnValue, 1); 
     2125                TEST_RETURN(compareReturnValue, 
     2126                        BackupQueries::ReturnCode::Compare_Same); 
    16992127 
    17002128                std::string fileToUnlink = "testfiles/restore-" +  
     
    17052133                // on the command line in system encoding. 
    17062134                command = BBACKUPQUERY " -c testfiles/bbackupd.conf " 
    1707                         "-q \"get Test1/" + systemDirName + "/" +  
     2135                        "-Wwarning \"get Test1/" + systemDirName + "/" +  
    17082136                        systemFileName + " " + "testfiles/restore-" +  
    17092137                        systemDirName + "/" + systemFileName + "\" quit"; 
    17102138 
    17112139                compareReturnValue = ::system(command.c_str()); 
    1712                 TEST_RETURN(compareReturnValue, 0); 
     2140                TEST_RETURN(compareReturnValue, 
     2141                        BackupQueries:ReturnCode::Command_OK); 
    17132142                TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
    17142143 
    17152144                // 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 " 
    17172147                        "\"lcd testfiles\" " 
    17182148                        "\"cd Test1/" + systemDirName + "\" " +  
     
    17202150 
    17212151                compareReturnValue = ::system(command.c_str()); 
    1722                 TEST_RETURN(compareReturnValue, 0); 
     2152                TEST_RETURN(compareReturnValue, 
     2153                        BackupQueries:ReturnCode::Command_OK); 
    17232154                TestRemoteProcessMemLeaks("testfiles/bbackupquery.memleaks"); 
    17242155 
     
    17282159 
    17292160                // And after changing directory to an absolute path 
    1730                 command = BBACKUPQUERY " -c testfiles/bbackupd.conf -q " 
     2161                command = BBACKUPQUERY " -c testfiles/bbackupd.conf -Wwarning " 
    17312162                        "\"lcd " + cwd + "/testfiles\" " 
    17322163                        "\"cd Test1/" + systemDirName + "\" " +  
     
    17342165 
    17352166                compareReturnValue = ::system(command.c_str()); 
    1736                 TEST_RETURN(compareReturnValue, 0); 
     2167                TEST_RETURN(compareReturnValue, 
     2168                        BackupQueries:ReturnCode::Command_OK); 
    17372169                TestRemoteProcessMemLeaks("testfiles/bbackupquery.memleaks"); 
    17382170 
     
    17402172                // The Get command does not restore attributes, so 
    17412173                // 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 + 
    17442177                        " testfiles/restore-" + systemDirName + "\" quit"; 
    17452178 
    17462179                compareReturnValue = ::system(command.c_str()); 
    17472180                TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
    1748                 TEST_RETURN(compareReturnValue, 1); 
     2181                TEST_RETURN(compareReturnValue, 
     2182                        BackupQueries:ReturnCode::Compare_Same); 
    17492183 
    17502184                // 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 + 
    17532188                        " testfiles/restore-" + systemDirName + "\" quit"; 
    1754  
    17552189                compareReturnValue = ::system(command.c_str()); 
    17562190                TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
    1757                 TEST_RETURN(compareReturnValue, 2); 
     2191                TEST_RETURN(compareReturnValue, 
     2192                        BackupQueries::ReturnCode::Compare_Different); 
    17582193#endif // WIN32 
    17592194 
     
    18322267 
    18332268                        // check that no backup has run (compare fails) 
    1834                         compareReturnValue = ::system(BBACKUPQUERY " -q " 
     2269                        int compareReturnValue = ::system(BBACKUPQUERY " " 
     2270                                "-Werror " 
    18352271                                "-c testfiles/bbackupd.conf " 
    18362272                                "-l testfiles/query3.log " 
    18372273                                "\"compare -acQ\" quit"); 
    1838                         TEST_RETURN(compareReturnValue, 2); 
     2274                        TEST_RETURN(compareReturnValue, 
     2275                                BackupQueries::ReturnCode::Compare_Different); 
    18392276                        TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
    18402277 
     
    18522289                        wait_for_sync_end(); 
    18532290                        // check that backup has run (compare succeeds) 
    1854                         compareReturnValue = ::system(BBACKUPQUERY " -q " 
     2291                        compareReturnValue = ::system(BBACKUPQUERY " " 
     2292                                "-Wwarning " 
    18552293                                "-c testfiles/bbackupd.conf " 
    18562294                                "-l testfiles/query3a.log " 
    18572295                                "\"compare -acQ\" quit"); 
    1858                         TEST_RETURN(compareReturnValue, 1); 
     2296                        TEST_RETURN(compareReturnValue, 
     2297                                BackupQueries::ReturnCode::Compare_Same); 
    18592298                        TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
    18602299 
     
    19012340                // wait for backup daemon to do it's stuff, and compare again 
    19022341                wait_for_backup_operation(); 
    1903                 compareReturnValue = ::system(BBACKUPQUERY " -q " 
     2342                int compareReturnValue = ::system(BBACKUPQUERY " -Wwarning " 
    19042343                        "-c testfiles/bbackupd.conf " 
    19052344                        "-l testfiles/query2.log " 
    19062345                        "\"compare -acQ\" quit"); 
    1907                 TEST_RETURN(compareReturnValue, 1); 
     2346                TEST_RETURN(compareReturnValue, 
     2347                        BackupQueries::ReturnCode::Compare_Same); 
    19082348                TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
    19092349 
    19102350                // Try a quick compare, just for fun 
    1911                 compareReturnValue = ::system(BBACKUPQUERY " -q " 
     2351                compareReturnValue = ::system(BBACKUPQUERY " " 
    19122352                        "-c testfiles/bbackupd.conf " 
    19132353                        "-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); 
    19162357                TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
    19172358                 
     
    19232364                // Check that store errors are reported neatly 
    19242365                printf("\n==== Create store error\n"); 
     2366 
     2367                // break the store 
    19252368                TEST_THAT(::rename("testfiles/0_0/backup/01234567/info.rf", 
    19262369                        "testfiles/0_0/backup/01234567/info.rf.bak") == 0); 
     
    19292372                TEST_THAT(::rename("testfiles/0_2/backup/01234567/info.rf", 
    19302373                        "testfiles/0_2/backup/01234567/info.rf.bak") == 0); 
     2374 
    19312375                // Create a file to trigger an upload 
    19322376                { 
     
    19362380                        TEST_THAT(write(fd1, "just do it", 10) == 10); 
    19372381                        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 
    19432386                TEST_THAT(TestFileExists("testfiles/notifyran.backup-error.1")); 
    1944                 // Check that the error was only reported once 
    19452387                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) 
    19472409                TEST_THAT(::rename("testfiles/0_0/backup/01234567/info.rf.bak", 
    19482410                        "testfiles/0_0/backup/01234567/info.rf") == 0); 
     
    19512413                TEST_THAT(::rename("testfiles/0_2/backup/01234567/info.rf.bak", 
    19522414                        "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")); 
    19532458         
    1954                 // Check that we DO get errors on compare 
    1955                 compareReturnValue = ::system(BBACKUPQUERY " -q " 
     2459                // Check that it did get uploaded, and we have no more errors 
     2460                compareReturnValue = ::system(BBACKUPQUERY " " 
    19562461                        "-c testfiles/bbackupd.conf " 
    19572462                        "-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); 
    19602466                TestRemoteProcessMemLeaks("bbackupquery.memleaks");              
    19612467 
     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); 
    19622496                TEST_THAT(ServerIsAlive(bbackupd_pid)); 
    19632497                TEST_THAT(ServerIsAlive(bbstored_pid)); 
     
    19652499                if (!ServerIsAlive(bbstored_pid)) return 1; 
    19662500 
    1967                 // Wait until bbackupd recovers from the exception 
    1968                 wait_for_backup_operation(100); 
    1969  
    1970                 // Ensure that the force-upload file gets uploaded, 
    1971                 // meaning that bbackupd recovered 
    19722501                sync_and_wait(); 
    19732502 
     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         
    19742554                // Check that it did get uploaded, and we have no more errors 
    1975                 compareReturnValue = ::system(BBACKUPQUERY " -q " 
     2555                compareReturnValue = ::system(BBACKUPQUERY " " 
    19762556                        "-c testfiles/bbackupd.conf " 
    19772557                        "-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); 
    19802561                TestRemoteProcessMemLeaks("bbackupquery.memleaks");              
     2562 
     2563                TEST_THAT(::unlink("testfiles/notifyscript.tag") == 0); 
    19812564 
    19822565                TEST_THAT(ServerIsAlive(bbackupd_pid)); 
     
    20092592 
    20102593                wait_for_backup_operation(); 
    2011                 compareReturnValue = ::system(BBACKUPQUERY " -q " 
     2594                compareReturnValue = ::system(BBACKUPQUERY " " 
    20122595                        "-c testfiles/bbackupd.conf " 
    20132596                        "-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); 
    20162600                TestRemoteProcessMemLeaks("bbackupquery.memleaks");              
    20172601 
     
    20372621 
    20382622                wait_for_backup_operation(); 
    2039                 compareReturnValue = ::system(BBACKUPQUERY " -q " 
     2623                compareReturnValue = ::system(BBACKUPQUERY " " 
    20402624                        "-c testfiles/bbackupd.conf " 
    20412625                        "-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); 
    20442629                TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
    20452630                 
     
    20682653 
    20692654                wait_for_backup_operation(); 
    2070                 compareReturnValue = ::system(BBACKUPQUERY " -q " 
     2655                compareReturnValue = ::system(BBACKUPQUERY " " 
    20712656                        "-c testfiles/bbackupd.conf " 
    20722657                        "-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); 
    20752661                TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
    20762662                 
     
    20992685 
    21002686                wait_for_backup_operation(); 
    2101                 compareReturnValue = ::system(BBACKUPQUERY " -q " 
     2687                compareReturnValue = ::system(BBACKUPQUERY " " 
    21022688                        "-c testfiles/bbackupd.conf " 
    21032689                        "-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); 
    21062693                TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
    21072694 
     
    21302717                // back up both files 
    21312718                wait_for_backup_operation(); 
    2132                 compareReturnValue = ::system(BBACKUPQUERY " -q " 
     2719                compareReturnValue = ::system(BBACKUPQUERY " " 
    21332720                        "-c testfiles/bbackupd.conf " 
    21342721                        "-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); 
    21372725                TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
    21382726 
     
    21472735                TEST_THAT( TestFileExists("testfiles/TestDir1/untracked-2")); 
    21482736                wait_for_backup_operation(); 
    2149                 compareReturnValue = ::system(BBACKUPQUERY " -q " 
     2737                compareReturnValue = ::system(BBACKUPQUERY " " 
    21502738                        "-c testfiles/bbackupd.conf " 
    21512739                        "-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); 
    21542743                TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
    21552744 
     
    21812770                // back up both files 
    21822771                wait_for_backup_operation(); 
    2183                 compareReturnValue = ::system(BBACKUPQUERY " -q " 
     2772                compareReturnValue = ::system(BBACKUPQUERY " " 
    21842773                        "-c testfiles/bbackupd.conf " 
    21852774                        "-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); 
    21882778                TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
    21892779 
     
    21982788                TEST_THAT( TestFileExists("testfiles/TestDir1/tracked-2")); 
    21992789                wait_for_backup_operation(); 
    2200                 compareReturnValue = ::system(BBACKUPQUERY " -q " 
     2790                compareReturnValue = ::system(BBACKUPQUERY " " 
    22012791                        "-c testfiles/bbackupd.conf " 
    22022792                        "-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); 
    22052796                TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
    22062797         
     
    22182809                 
    22192810                wait_for_backup_operation(); 
    2220                 compareReturnValue = ::system(BBACKUPQUERY " -q " 
     2811                compareReturnValue = ::system(BBACKUPQUERY " " 
    22212812                        "-c testfiles/bbackupd.conf " 
    22222813                        "-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); 
    22252817                TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
    22262818                 
     
    22522844                // Wait and test 
    22532845                wait_for_backup_operation(); 
    2254                 compareReturnValue = ::system(BBACKUPQUERY " -q " 
     2846                compareReturnValue = ::system(BBACKUPQUERY " " 
    22552847                        "-c testfiles/bbackupd.conf " 
    22562848                        "-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); 
    22592852                TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
    22602853                 
     
    23102903                wait_for_sync_end(); // should (not) be backed up this time 
    23112904 
    2312                 compareReturnValue = ::system(BBACKUPQUERY " -q " 
     2905                compareReturnValue = ::system(BBACKUPQUERY " " 
    23132906                        "-c testfiles/bbackupd.conf " 
    23142907                        "-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); 
    23172911                TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
    23182912 
     
    23382932                 
    23392933                // compare with exclusions, should not find differences 
    2340                 compareReturnValue = ::system(BBACKUPQUERY " -q " 
     2934                compareReturnValue = ::system(BBACKUPQUERY " " 
    23412935                        "-c testfiles/bbackupd.conf " 
    23422936                        "-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); 
    23452940                TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
    23462941 
    23472942                // compare without exclusions, should find differences 
    2348                 compareReturnValue = ::system(BBACKUPQUERY " -q " 
     2943                compareReturnValue = ::system(BBACKUPQUERY " " 
    23492944                        "-c testfiles/bbackupd.conf " 
    23502945                        "-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); 
    23532949                TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
    23542950 
     
    24223018                        // Wait and test... 
    24233019                        wait_for_backup_operation(); 
    2424                         compareReturnValue = ::system(BBACKUPQUERY " -q " 
     3020                        compareReturnValue = ::system(BBACKUPQUERY " " 
    24253021                                "-c testfiles/bbackupd.conf " 
    24263022                                "-l testfiles/query3o.log " 
    2427                                 "\"compare -acQ\" quit"); 
     3023                                "-Werror \"compare -acQ\" quit"); 
    24283024 
    24293025                        // should find differences 
    2430                         TEST_RETURN(compareReturnValue, 3); 
     3026                        TEST_RETURN(compareReturnValue, 
     3027                                BackupQueries::ReturnCode::Compare_Error); 
    24313028                        TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
    24323029 
     
    25253122                // Wait and test 
    25263123                wait_for_backup_operation(); 
    2527                 compareReturnValue = ::system(BBACKUPQUERY " -q " 
     3124                compareReturnValue = ::system(BBACKUPQUERY " " 
    25283125                        "-c testfiles/bbackupd.conf " 
    25293126                        "-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); 
    25323130                TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
    25333131         
     
    25743172 
    25753173                        // 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 " 
    25773175                                "that doesn't exist\n"); 
    25783176                        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                        } 
    25833186 
    25843187                        // Log out 
     
    25883191 
    25893192                // Compare the restored files 
    2590                 compareReturnValue = ::system(BBACKUPQUERY " -q " 
     3193                compareReturnValue = ::system(BBACKUPQUERY " " 
    25913194                        "-c testfiles/bbackupd.conf " 
    25923195                        "-l testfiles/query10.log " 
     3196                        "-Wwarning " 
    25933197                        "\"compare -cEQ Test1 testfiles/restore-Test1\" " 
    25943198                        "quit"); 
    2595                 TEST_RETURN(compareReturnValue, 1); 
     3199                TEST_RETURN(compareReturnValue, 
     3200                        BackupQueries::ReturnCode::Compare_Same); 
    25963201                TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
    25973202                 
     
    26073212                TEST_RETURN(compareReturnValue, 0); 
    26083213 
    2609                 compareReturnValue = ::system(BBACKUPQUERY " -q " 
     3214                compareReturnValue = ::system(BBACKUPQUERY " " 
    26103215                        "-c testfiles/bbackupd.conf " 
    26113216                        "-l testfiles/query10a.log " 
     3217                        "-Werror " 
    26123218                        "\"compare -cEQ Test1 testfiles/restore-Test1\" " 
    26133219                        "quit"); 
    2614                 TEST_RETURN(compareReturnValue, 2); 
     3220                TEST_RETURN(compareReturnValue, 
     3221                        BackupQueries::ReturnCode::Compare_Different); 
    26153222                TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
    26163223         
     
    26203227                TEST_RETURN(compareReturnValue, 0); 
    26213228 
    2622                 compareReturnValue = ::system(BBACKUPQUERY " -q " 
     3229                compareReturnValue = ::system(BBACKUPQUERY " " 
    26233230                        "-c testfiles/bbackupd.conf -l testfiles/query10a.log " 
     3231                        "-Wwarning " 
    26243232                        "\"compare -cEQ Test1 testfiles/restore-Test1\" " 
    26253233                        "quit"); 
    2626                 TEST_RETURN(compareReturnValue, 1); 
     3234                TEST_RETURN(compareReturnValue, 
     3235                        BackupQueries::ReturnCode::Compare_Same); 
    26273236                TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
    26283237 
     
    26443253                TEST_THAT(set_file_time(testfile, dummyTime, lastModTime, 
    26453254                        lastAccessTime)); 
    2646                 compareReturnValue = ::system(BBACKUPQUERY " -q " 
     3255                compareReturnValue = ::system(BBACKUPQUERY " " 
    26473256                        "-c testfiles/bbackupd.conf " 
    26483257                        "-l testfiles/query10a.log " 
     3258                        "-Werror " 
    26493259                        "\"compare -cEQ Test1 testfiles/restore-Test1\" " 
    26503260                        "quit"); 
    2651                 TEST_RETURN(compareReturnValue, 2); 
     3261                TEST_RETURN(compareReturnValue, 
     3262                        BackupQueries::ReturnCode::Compare_Different); 
    26523263                TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
    26533264 
     
    26553266                TEST_THAT(set_file_time(testfile, creationTime, lastModTime, 
    26563267                        dummyTime)); 
    2657                 compareReturnValue = ::system(BBACKUPQUERY " -q " 
     3268                compareReturnValue = ::system(BBACKUPQUERY " " 
    26583269                        "-c testfiles/bbackupd.conf " 
    26593270                        "-l testfiles/query10a.log " 
     3271                        "-Wwarning " 
    26603272                        "\"compare -cEQ Test1 testfiles/restore-Test1\" " 
    26613273                        "quit"); 
    2662                 TEST_RETURN(compareReturnValue, 1); 
     3274                TEST_RETURN(compareReturnValue, 
     3275                        BackupQueries::ReturnCode::Compare_Same); 
    26633276                TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
    26643277 
     
    26673280                TEST_THAT(set_file_time(testfile, creationTime, dummyTime, 
    26683281                        lastAccessTime)); 
    2669                 compareReturnValue = ::system(BBACKUPQUERY " -q " 
     3282                compareReturnValue = ::system(BBACKUPQUERY " " 
    26703283                        "-c testfiles/bbackupd.conf " 
    26713284                        "-l testfiles/query10a.log " 
     3285                        "-Werror " 
    26723286                        "\"compare -cEQ Test1 testfiles/restore-Test1\" " 
    26733287                        "quit"); 
    2674                 TEST_RETURN(compareReturnValue, 2); 
     3288                TEST_RETURN(compareReturnValue, 
     3289                        BackupQueries::ReturnCode::Compare_Different); 
    26753290                TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
    26763291 
     
    26783293                TEST_THAT(set_file_time(testfile, creationTime, lastModTime, 
    26793294                        lastAccessTime)); 
    2680                 compareReturnValue = ::system(BBACKUPQUERY " -q " 
     3295                compareReturnValue = ::system(BBACKUPQUERY " " 
    26813296                        "-c testfiles/bbackupd.conf " 
    26823297                        "-l testfiles/query10a.log " 
     3298                        "-Wwarning " 
    26833299                        "\"compare -cEQ Test1 testfiles/restore-Test1\" " 
    26843300                        "quit"); 
    2685                 TEST_RETURN(compareReturnValue, 1); 
     3301                TEST_RETURN(compareReturnValue, 
     3302                        BackupQueries::ReturnCode::Compare_Same); 
    26863303                TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
    26873304#endif // WIN32 
     
    27063323                // Wait and test 
    27073324                wait_for_backup_operation(); 
    2708                 compareReturnValue = ::system(BBACKUPQUERY " -q " 
     3325                compareReturnValue = ::system(BBACKUPQUERY " " 
    27093326                        "-c testfiles/bbackupd.conf " 
    27103327                        "-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); 
    27133331                TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
    27143332                 
     
    27233341                        "testfiles/TestDir1/renamed-dir") == 0); 
    27243342                wait_for_backup_operation(); 
    2725                 compareReturnValue = ::system(BBACKUPQUERY " -q " 
     3343                compareReturnValue = ::system(BBACKUPQUERY " " 
    27263344                        "-c testfiles/bbackupd.conf " 
    27273345                        "-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); 
    27303349                TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
    27313350 
    27323351                // and again, but with quick flag 
    2733                 compareReturnValue = ::system(BBACKUPQUERY " -q " 
     3352                compareReturnValue = ::system(BBACKUPQUERY " " 
    27343353                        "-c testfiles/bbackupd.conf " 
    27353354                        "-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); 
    27383358                TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
    27393359 
     
    27473367                        "testfiles/TestDir1/find2perl-ren") == 0); 
    27483368                wait_for_backup_operation(); 
    2749                 compareReturnValue = ::system(BBACKUPQUERY " -q " 
     3369                compareReturnValue = ::system(BBACKUPQUERY " " 
    27503370                        "-c testfiles/bbackupd.conf " 
    27513371                        "-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); 
    27543375                TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
    27553376 
     
    27893410                // Wait and test 
    27903411                wait_for_backup_operation(); 
    2791                 compareReturnValue = ::system(BBACKUPQUERY " -q " 
     3412                compareReturnValue = ::system(BBACKUPQUERY " " 
    27923413                        "-c testfiles/bbackupd.conf " 
    27933414                        "-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); 
    27963418                TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
    27973419 
     
    28573479                wait_for_backup_operation((TIME_TO_WAIT_FOR_BACKUP_OPERATION *  
    28583480                        3) / 2); // little bit longer than usual 
    2859                 compareReturnValue = ::system(BBACKUPQUERY " -q " 
     3481                compareReturnValue = ::system(BBACKUPQUERY " " 
    28603482                        "-c testfiles/bbackupd.conf " 
    28613483                        "-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); 
    28643487                TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
    28653488         
     
    29153538 
    29163539                        // Then check it has restored the correct stuff 
    2917                         compareReturnValue = ::system(BBACKUPQUERY " -q " 
     3540                        compareReturnValue = ::system(BBACKUPQUERY " " 
    29183541                                "-c testfiles/bbackupd.conf " 
    29193542                                "-l testfiles/query14.log " 
    2920                                 "\"compare -cEQ Test1 " 
     3543                                "-Wwarning \"compare -cEQ Test1 " 
    29213544                                "testfiles/restore-interrupt\" quit"); 
    2922                         TEST_RETURN(compareReturnValue, 1); 
     3545                        TEST_RETURN(compareReturnValue, 
     3546                                BackupQueries::ReturnCode::Compare_Same); 
    29233547                        TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
    29243548                } 
     
    29483572 
    29493573                        // Do a compare with the now undeleted files 
    2950                         compareReturnValue = ::system(BBACKUPQUERY " -q " 
     3574                        compareReturnValue = ::system(BBACKUPQUERY " " 
    29513575                                "-c testfiles/bbackupd.conf " 
    29523576                                "-l testfiles/query11.log " 
     3577                                "-Wwarning " 
    29533578                                "\"compare -cEQ Test1/x1 " 
    29543579                                "testfiles/restore-Test1-x1-2\" quit"); 
    2955                         TEST_RETURN(compareReturnValue, 1); 
     3580                        TEST_RETURN(compareReturnValue, 
     3581                                BackupQueries::ReturnCode::Compare_Same); 
    29563582                        TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
    29573583                } 
     
    30033629                        // compare, and check that it works 
    30043630                        // reports the correct error message (and finishes) 
    3005                         compareReturnValue = ::system(BBACKUPQUERY " -q " 
     3631                        compareReturnValue = ::system(BBACKUPQUERY " " 
    30063632                                "-c testfiles/bbackupd.conf " 
    30073633                                "-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); 
    30103637                        TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
    30113638 
     
    30163643                        TEST_THAT(handle != INVALID_HANDLE_VALUE); 
    30173644 
    3018                         compareReturnValue = ::system(BBACKUPQUERY  
    3019                                 " -q -c testfiles/bbackupd.conf " 
     3645                        compareReturnValue = ::system(BBACKUPQUERY " " 
     3646                                "-c testfiles/bbackupd.conf " 
    30203647                                "-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); 
    30233651                        TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
    30243652 
     
    30273655                        CloseHandle(handle); 
    30283656 
    3029                         compareReturnValue = ::system(BBACKUPQUERY " -q " 
     3657                        compareReturnValue = ::system(BBACKUPQUERY " " 
    30303658                                "-c testfiles/bbackupd.conf " 
    30313659                                "-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); 
    30343663                        TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
    30353664                } 
     
    30563685                        wait_for_backup_operation( 
    30573686                                (TIME_TO_WAIT_FOR_BACKUP_OPERATION*3) / 2);  
    3058                         compareReturnValue = ::system(BBACKUPQUERY " -q " 
     3687                        compareReturnValue = ::system(BBACKUPQUERY " " 
    30593688                                "-c testfiles/bbackupd.conf " 
    30603689                                "-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); 
    30633693                        TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
    30643694 
     
    30683698        } 
    30693699 
    3070         // List the files on the server 
     3700        /* 
     3701        // List the files on the server - why? 
    30713702        ::system(BBACKUPQUERY " -q -c testfiles/bbackupd.conf " 
    30723703                "-l testfiles/queryLIST.log \"list -rotdh\" quit"); 
    30733704        TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
     3705        */ 
    30743706 
    30753707        #ifndef WIN32    
  • box/trunk/test/bbackupd/testfiles/extcheck1.pl.in

    r2056 r2184  
    44my $flags = $ARGV[0] or ""; 
    55 
    6 unless(open IN,"../../bin/bbackupquery/bbackupquery -q -c testfiles/bbackupd.conf -l testfiles/query4.log \"compare -ac$flags\" quit 2>&1 |") 
     6unless(open IN,"../../bin/bbackupquery/bbackupquery -Wwarning " . 
     7        "-c testfiles/bbackupd.conf " . 
     8        "-l testfiles/query4.log " . 
     9        "\"compare -ac$flags\" quit 2>&1 |") 
    710{ 
    811        print "Couldn't open compare utility\n"; 
  • box/trunk/test/bbackupd/testfiles/extcheck2.pl.in

    r2056 r2184  
    44my $flags = $ARGV[0] or ""; 
    55 
    6 unless(open IN,"../../bin/bbackupquery/bbackupquery -q -c testfiles/bbackupd.conf -l testfiles/query4.log \"compare -ac$flags\" quit 2>&1 |") 
     6unless(open IN,"../../bin/bbackupquery/bbackupquery -Wwarning " . 
     7        "-c testfiles/bbackupd.conf " . 
     8        "-l testfiles/query4.log " . 
     9        "\"compare -ac$flags\" quit 2>&1 |") 
    710{ 
    811        print "Couldn't open compare utility\n"; 
Note: See TracChangeset for help on using the changeset viewer.