Changeset 2216

Show
Ignore:
Timestamp:
03/08/2008 08:09:18 (5 months ago)
Author:
chris
Message:

Windows compile and deletion/housekeeping test fix.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • box/trunk/test/bbackupd/testbbackupd.cpp

    r2188 r2216  
    9292        std::string found_str = _oss2.str(); \ 
    9393        \ 
    94         TEST_THAT(exp_str == found_str); \ 
    95         std::string _line = line; \ 
    96         \ 
    9794        if(exp_str != found_str) \ 
    9895        { \ 
     96                std::string _line = line; \ 
    9997                printf("Expected <%s> but found <%s> in <%s>\n", \ 
    10098                        exp_str.c_str(), found_str.c_str(), _line.c_str()); \ 
     99                TEST_FAIL_WITH_MESSAGE(#found " != " #expected " in " line); \ 
    101100        } \ 
    102101} 
     
    13471346                } 
    13481347 
     1348                if (failures > 0) 
     1349                { 
     1350                        // stop early to make debugging easier 
     1351                        return 1; 
     1352                } 
     1353 
     1354                // ensure time is different to refresh the cache 
     1355                ::safe_sleep(1); 
     1356 
    13491357                BOX_TRACE("Restart bbackupd with more exclusions"); 
    13501358                // Start again with a new config that excludes d3 and f2, 
     
    13581366                bbackupd_pid = LaunchServer(cmd, "testfiles/bbackupd.pid"); 
    13591367                TEST_THAT(bbackupd_pid != -1 && bbackupd_pid != 0); 
    1360                 ::safe_sleep(1); 
    13611368                TEST_THAT(ServerIsAlive(bbackupd_pid)); 
    13621369                TEST_THAT(ServerIsAlive(bbstored_pid)); 
     
    13641371                if (!ServerIsAlive(bbstored_pid)) return 1; 
    13651372                */ 
     1373 
    13661374                BackupDaemon bbackupd; 
    13671375                bbackupd.Configure("testfiles/bbackupd-exclude.conf"); 
     
    13721380                // wait_for_sync_end(); 
    13731381                { 
    1374                         Logging::Guard guard(Log::ERROR); 
     1382                        // Logging::Guard guard(Log::ERROR); 
    13751383                        bbackupd.RunSyncNow(); 
    13761384                } 
     
    13941402                // d7           deleted 
    13951403                // Careful with timing here, these files can already be 
    1396                 // deleted by housekeeping. 
     1404                // deleted by housekeeping. On Win32, housekeeping runs 
     1405                // immediately after disconnect, but only if enough time 
     1406                // has elapsed since the last housekeeping. Since the 
     1407                // backup run closely follows the last one, housekeeping 
     1408                // should not run afterwards. By waiting before 
     1409                // connecting to check the results, we should force 
     1410                // housekeeping to run after that check, so the next check 
     1411                // will see that the deleted files have been removed. 
     1412 
     1413                #ifdef WIN32 
     1414                        BOX_TRACE("Wait long enough that housekeeping " 
     1415                                "will run again") 
     1416                        wait_for_backup_operation(5); 
     1417                        BOX_TRACE("done."); 
     1418                #endif 
    13971419 
    13981420                BOX_TRACE("Find out whether bbackupd marked files as deleted"); 
     
    14181440                                ReadDirectory(*client, spacetestDirId); 
    14191441 
     1442                        // these files were deleted before, they should be 
     1443                        // long gone by now 
     1444 
    14201445                        TEST_THAT(SearchDir(*spacetest_dir, "f1") == 0); 
     1446                        TEST_THAT(SearchDir(*spacetest_dir, "d7") == 0); 
     1447 
     1448                        // these files have just been deleted, because 
     1449                        // they are excluded by the new configuration. 
     1450                        // but housekeeping should not have run yet 
    14211451                        TEST_THAT(test_entry_deleted(*spacetest_dir, "f2")); 
    14221452                        TEST_THAT(test_entry_deleted(*spacetest_dir, "d3")); 
    1423                         TEST_THAT(SearchDir(*spacetest_dir, "d7") == 0); 
    14241453 
    14251454                        int64_t d3_id = SearchDir(*spacetest_dir, "d3"); 
     
    14551484                BOX_TRACE("done."); 
    14561485 
     1486                if (failures > 0) 
     1487                { 
     1488                        // stop early to make debugging easier 
     1489                        return 1; 
     1490                } 
     1491 
    14571492                // Wait for housekeeping to run 
    14581493                BOX_TRACE("Wait for housekeeping to remove the deleted files"); 
     
    15031538                } 
    15041539 
     1540                if (failures > 0) 
     1541                { 
     1542                        // stop early to make debugging easier 
     1543                        return 1; 
     1544                } 
     1545 
    15051546                // Need 22 blocks free to upload everything 
    15061547                TEST_THAT_ABORTONFAIL(::system(BBSTOREACCOUNTS " -c " 
     
    15471588                        client->QueryFinished(); 
    15481589                        sSocket.Close(); 
     1590                } 
     1591 
     1592                if (failures > 0) 
     1593                { 
     1594                        // stop early to make debugging easier 
     1595                        return 1; 
    15491596                } 
    15501597 
     
    15991646                if (!ServerIsAlive(bbackupd_pid)) return 1; 
    16001647                if (!ServerIsAlive(bbstored_pid)) return 1; 
     1648 
     1649                if (failures > 0) 
     1650                { 
     1651                        // stop early to make debugging easier 
     1652                        return 1; 
     1653                } 
    16011654        } 
    16021655 
     
    16231676 
    16241677                char buf[PATH_MAX]; 
    1625                 TEST_THAT(getcwd(buf, sizeof(buf)) != NULL); 
     1678                TEST_THAT(getcwd(buf, sizeof(buf)) == buf); 
    16261679                std::string path = buf; 
    16271680                path += DIRECTORY_SEPARATOR SYM_DIR  
     
    18891942 
    18901943                } 
     1944 
     1945                int compareReturnValue; 
    18911946 
    18921947#ifdef WIN32 
     
    19311986 
    19321987                char cwdbuf[1024]; 
    1933                 TEST_EQUAL(cwdbuf, getcwd(cwdbuf, sizeof(cwdbuf)), "getcwd"); 
     1988                TEST_THAT(getcwd(cwdbuf, sizeof(cwdbuf)) == cwdbuf); 
    19341989                std::string cwd = cwdbuf; 
    19351990 
     
    22672322 
    22682323                        // check that no backup has run (compare fails) 
    2269                         int compareReturnValue = ::system(BBACKUPQUERY " " 
     2324                        compareReturnValue = ::system(BBACKUPQUERY " " 
    22702325                                "-Werror " 
    22712326                                "-c testfiles/bbackupd.conf " 
     
    23402395                // wait for backup daemon to do it's stuff, and compare again 
    23412396                wait_for_backup_operation(); 
    2342                 int compareReturnValue = ::system(BBACKUPQUERY " -Wwarning " 
     2397                compareReturnValue = ::system(BBACKUPQUERY " -Wwarning " 
    23432398                        "-c testfiles/bbackupd.conf " 
    23442399                        "-l testfiles/query2.log "