Changeset 219


Ignore:
Timestamp:
12/12/2005 23:56:44 (6 years ago)
Author:
martin
Message:

Merged 210:218 from chris/win32/merge/07-win32-fixes to trunk

Location:
box/trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • box/trunk/infrastructure/buildenv-testmain-template.cpp

    r217 r219  
    2121#include <unistd.h> 
    2222#include <stdlib.h> 
    23 #include <syslog.h> 
    2423#include <stdarg.h> 
    2524#include <fcntl.h> 
    2625#include <errno.h> 
     26 
     27#ifdef WIN32 
     28        #include "emu.h" 
     29#else 
     30        #include <syslog.h> 
     31#endif 
    2732 
    2833#include "MemLeakFindOn.h" 
     
    3944 
    4045int filedes_open_at_beginning = -1; 
     46 
     47#ifdef WIN32 
     48 
     49// any way to check for open file descriptors on Win32? 
     50inline int count_filedes() { return 0; } 
     51inline bool checkfilesleftopen() { return false; } 
     52 
     53#else // !WIN32 
    4154 
    4255int count_filedes() 
     
    7184        return filedes_open_at_beginning != count_filedes(); 
    7285} 
     86 
     87#endif 
    7388 
    7489int main(int argc, const char *argv[]) 
  • box/trunk/infrastructure/makebuildenv.pl

    r217 r219  
    409409                 
    410410                writetestfile("$mod/_t",  
    411                         './test${platform_exe_ext} $1 $2 $3 $4 $5', $mod); 
     411                        './test' . $platform_exe_ext . '$1 $2 $3 $4 $5', $mod); 
    412412                writetestfile("$mod/_t-gdb",  
    413                         'gdb ./test${platform_exe_ext}', $mod); 
     413                        'gdb ./test ' . $platform_exe_ext, $mod); 
    414414                 
    415415        } 
  • box/trunk/lib/common/DebugAssertFailed.cpp

    r217 r219  
    1313 
    1414#include <stdio.h> 
    15 #include <syslog.h> 
     15 
     16#ifdef WIN32 
     17        #include "emu.h" 
     18#else 
     19        #include <syslog.h> 
     20#endif 
    1621 
    1722#include "MemLeakFindOn.h" 
  • box/trunk/lib/common/DebugPrintf.cpp

    r217 r219  
    1414#include <stdio.h> 
    1515#include <stdarg.h> 
    16 #include <syslog.h> 
     16 
     17#ifdef WIN32 
     18        #include "emu.h" 
     19#else 
     20        #include <syslog.h> 
     21#endif 
    1722 
    1823#include "MemLeakFindOn.h" 
  • box/trunk/lib/common/FileStream.cpp

    r217 r219  
    198198        if ( (res == 0) || (numBytesWritten != NBytes)) 
    199199        { 
    200                 DWORD err = GetLastError(); 
     200                // DWORD err = GetLastError(); 
    201201                THROW_EXCEPTION(CommonException, OSFileWriteError) 
    202202        } 
    203  
    204  
    205203#else 
    206204        if(::write(mOSFileHandle, pBuffer, NBytes) != NBytes) 
  • box/trunk/lib/common/Test.h

    r217 r219  
    109109} 
    110110 
     111#ifdef WIN32 
     112 
     113#include "WinNamedPipeStream.h" 
     114#include "IOStreamGetLine.h" 
     115#include "BoxPortsAndFiles.h" 
     116 
     117bool SendCommands(const std::string& rCmd) 
     118{ 
     119        WinNamedPipeStream connection; 
     120 
     121        try 
     122        { 
     123                connection.Connect(BOX_NAMED_PIPE_NAME); 
     124        } 
     125        catch(...) 
     126        { 
     127                printf("Failed to connect to daemon control socket.\n"); 
     128                return false; 
     129        } 
     130 
     131        // For receiving data 
     132        IOStreamGetLine getLine(connection); 
     133         
     134        // Wait for the configuration summary 
     135        std::string configSummary; 
     136        if(!getLine.GetLine(configSummary)) 
     137        { 
     138                printf("Failed to receive configuration summary from daemon\n"); 
     139                return false; 
     140        } 
     141 
     142        // Was the connection rejected by the server? 
     143        if(getLine.IsEOF()) 
     144        { 
     145                printf("Server rejected the connection.\n"); 
     146                return false; 
     147        } 
     148 
     149        // Decode it 
     150        int autoBackup, updateStoreInterval, minimumFileAge, maxUploadWait; 
     151        if(::sscanf(configSummary.c_str(), "bbackupd: %d %d %d %d",  
     152                        &autoBackup, &updateStoreInterval,  
     153                        &minimumFileAge, &maxUploadWait) != 4) 
     154        { 
     155                printf("Config summary didn't decode\n"); 
     156                return false; 
     157        } 
     158 
     159        std::string cmds; 
     160        bool expectResponse; 
     161 
     162        if (rCmd != "") 
     163        { 
     164                cmds = rCmd; 
     165                cmds += "\nquit\n"; 
     166                expectResponse = true; 
     167        } 
     168        else 
     169        { 
     170                cmds = "quit\n"; 
     171                expectResponse = false; 
     172        } 
     173         
     174        connection.Write(cmds.c_str(), cmds.size()); 
     175         
     176        // Read the response 
     177        std::string line; 
     178        bool statusOk = !expectResponse; 
     179 
     180        while (expectResponse && !getLine.IsEOF() && getLine.GetLine(line)) 
     181        { 
     182                // Is this an OK or error line? 
     183                if (line == "ok") 
     184                { 
     185                        statusOk = true; 
     186                } 
     187                else if (line == "error") 
     188                { 
     189                        printf("ERROR (%s)\n", rCmd.c_str()); 
     190                        break; 
     191                } 
     192                else 
     193                { 
     194                        printf("WARNING: Unexpected response to command '%s': " 
     195                                "%s", rCmd.c_str(), line.c_str()); 
     196                } 
     197        } 
     198         
     199        return statusOk; 
     200} 
     201 
     202inline bool ServerIsAlive() 
     203{ 
     204        return SendCommands(""); 
     205} 
     206 
     207inline bool HUPServer(int pid) 
     208{ 
     209        return SendCommands("reload"); 
     210} 
     211 
     212inline bool KillServer(int pid) 
     213{ 
     214        TEST_THAT(SendCommands("terminate")); 
     215        ::sleep(1); 
     216        return !ServerIsAlive(); 
     217} 
     218 
     219#else // !WIN32 
     220 
    111221inline bool ServerIsAlive(int pid) 
    112222{ 
     
    129239        return !ServerIsAlive(pid); 
    130240} 
     241 
     242#endif // WIN32 
    131243 
    132244inline void TestRemoteProcessMemLeaks(const char *filename) 
  • box/trunk/modules.txt

    r217 r219  
    1919lib/win32               lib/server 
    2020lib/compress 
    21 test/common 
    22 test/crypto                     lib/crypto 
    23 test/compress           lib/compress 
    24 test/basicserver        lib/server 
     21test/common             lib/win32 
     22test/crypto             lib/crypto      lib/win32 
     23test/compress           lib/compress    lib/win32 
    2524 
    2625OMIT:mingw32 
     26test/basicserver        lib/server      lib/win32 
    2727OMIT:CYGWIN 
    2828test/raidfile           lib/raidfile 
  • box/trunk/runtest.pl

    r217 r219  
    3939                if(m/\AOMIT:(.+)/) 
    4040                { 
    41                         if($1 eq $build_os) 
     41                        if($1 eq $build_os or $1 eq $target_os) 
    4242                        { 
    4343                                while(<MODULES>) 
  • box/trunk/test/common/testcommon.cpp

    r217 r219  
    182182        // First, test the FdGetLine class -- rather important this works! 
    183183        { 
    184                 FileHandleGuard<O_RDONLY> file("testfiles/fdgetlinetest.txt"); 
     184                FileHandleGuard<O_RDONLY> file("testfiles" 
     185                        DIRECTORY_SEPARATOR "fdgetlinetest.txt"); 
    185186                FdGetLine getline(file); 
    186187                 
     
    199200        // and again without pre-processing 
    200201        { 
    201                 FileHandleGuard<O_RDONLY> file("testfiles/fdgetlinetest.txt"); 
    202                 FILE *file2 = fopen("testfiles/fdgetlinetest.txt", "r"); 
     202                FileHandleGuard<O_RDONLY> file("testfiles" 
     203                        DIRECTORY_SEPARATOR "fdgetlinetest.txt"); 
     204                FILE *file2 = fopen("testfiles" DIRECTORY_SEPARATOR  
     205                        "fdgetlinetest.txt", "r"); 
    203206                TEST_THAT_ABORTONFAIL(file2 != 0); 
    204207                FdGetLine getline(file); 
     
    228231        // Then the IOStream version of get line, seeing as we're here... 
    229232        { 
    230                 FileStream file("testfiles/fdgetlinetest.txt", O_RDONLY); 
     233                FileStream file("testfiles" DIRECTORY_SEPARATOR  
     234                        "fdgetlinetest.txt", O_RDONLY); 
    231235                IOStreamGetLine getline(file); 
    232236                 
     
    248252        // and again without pre-processing 
    249253        { 
    250                 FileStream file("testfiles/fdgetlinetest.txt", O_RDONLY); 
     254                FileStream file("testfiles" DIRECTORY_SEPARATOR  
     255                        "fdgetlinetest.txt", O_RDONLY); 
    251256                IOStreamGetLine getline(file); 
    252257 
    253                 FILE *file2 = fopen("testfiles/fdgetlinetest.txt", "r"); 
     258                FILE *file2 = fopen("testfiles" DIRECTORY_SEPARATOR  
     259                        "fdgetlinetest.txt", "r"); 
    254260                TEST_THAT_ABORTONFAIL(file2 != 0); 
    255261                char ll[512]; 
     
    282288        { 
    283289                std::string errMsg; 
    284                 TEST_CHECK_THROWS(std::auto_ptr<Configuration> pconfig(Configuration::LoadAndVerify("testfiles/DOESNTEXIST", &verify, errMsg)), CommonException, OSFileOpenError); 
     290                TEST_CHECK_THROWS(std::auto_ptr<Configuration> pconfig( 
     291                        Configuration::LoadAndVerify( 
     292                                "testfiles" DIRECTORY_SEPARATOR "DOESNTEXIST",  
     293                                &verify, errMsg)),  
     294                        CommonException, OSFileOpenError); 
    285295        } 
    286296 
     
    288298        { 
    289299                std::string errMsg; 
    290                 std::auto_ptr<Configuration> pconfig(Configuration::LoadAndVerify("testfiles/config1.txt", &verify, errMsg)); 
     300                std::auto_ptr<Configuration> pconfig( 
     301                        Configuration::LoadAndVerify( 
     302                                "testfiles" DIRECTORY_SEPARATOR "config1.txt",  
     303                                &verify, errMsg)); 
    291304                if(!errMsg.empty()) 
    292305                { 
     
    333346        static const char *file[] = 
    334347        { 
    335                 "testfiles/config2.txt", // Value missing from root 
    336                 "testfiles/config3.txt", // Unexpected { 
    337                 "testfiles/config4.txt", // Missing } 
    338                 "testfiles/config5.txt", // { expected, but wasn't there 
    339                 "testfiles/config6.txt", // Duplicate key 
    340                 "testfiles/config7.txt", // Invalid key (no name) 
    341                 "testfiles/config8.txt", // Not all sub blocks terminated 
    342                 "testfiles/config9.txt", // Not valid integer 
    343                 "testfiles/config9b.txt", // Not valid integer 
    344                 "testfiles/config9c.txt", // Not valid integer 
    345                 "testfiles/config9d.txt", // Not valid integer 
    346                 "testfiles/config10.txt", // Missing key (in subblock) 
    347                 "testfiles/config11.txt", // Unknown key 
    348                 "testfiles/config12.txt", // Missing block 
    349                 "testfiles/config13.txt", // Subconfig (wildcarded) should exist, but missing (ie nothing present) 
    350                 "testfiles/config16.txt", // bad boolean value 
     348                "testfiles" DIRECTORY_SEPARATOR "config2.txt",  
     349                        // Value missing from root 
     350                "testfiles" DIRECTORY_SEPARATOR "config3.txt",  
     351                        // Unexpected { 
     352                "testfiles" DIRECTORY_SEPARATOR "config4.txt",  
     353                        // Missing } 
     354                "testfiles" DIRECTORY_SEPARATOR "config5.txt",  
     355                        // { expected, but wasn't there 
     356                "testfiles" DIRECTORY_SEPARATOR "config6.txt",  
     357                        // Duplicate key 
     358                "testfiles" DIRECTORY_SEPARATOR "config7.txt",  
     359                        // Invalid key (no name) 
     360                "testfiles" DIRECTORY_SEPARATOR "config8.txt",  
     361                        // Not all sub blocks terminated 
     362                "testfiles" DIRECTORY_SEPARATOR "config9.txt",  
     363                        // Not valid integer 
     364                "testfiles" DIRECTORY_SEPARATOR "config9b.txt",  
     365                        // Not valid integer 
     366                "testfiles" DIRECTORY_SEPARATOR "config9c.txt",  
     367                        // Not valid integer 
     368                "testfiles" DIRECTORY_SEPARATOR "config9d.txt",  
     369                        // Not valid integer 
     370                "testfiles" DIRECTORY_SEPARATOR "config10.txt",  
     371                        // Missing key (in subblock) 
     372                "testfiles" DIRECTORY_SEPARATOR "config11.txt",  
     373                        // Unknown key 
     374                "testfiles" DIRECTORY_SEPARATOR "config12.txt",  
     375                        // Missing block 
     376                "testfiles" DIRECTORY_SEPARATOR "config13.txt",  
     377                        // Subconfig (wildcarded) should exist, but missing (ie nothing present) 
     378                "testfiles" DIRECTORY_SEPARATOR "config16.txt",  
     379                        // bad boolean value 
    351380                0 
    352381        }; 
     
    365394        { 
    366395                std::string errMsg; 
    367                 std::auto_ptr<Configuration> pconfig(Configuration::LoadAndVerify("testfiles/config14.txt", &verify, errMsg)); 
     396                std::auto_ptr<Configuration> pconfig( 
     397                        Configuration::LoadAndVerify( 
     398                                "testfiles" DIRECTORY_SEPARATOR "config14.txt", 
     399                        &verify, errMsg)); 
    368400                TEST_THAT(pconfig.get() != 0); 
    369401                TEST_THAT(errMsg.empty()); 
     
    379411        { 
    380412                std::string errMsg; 
    381                 std::auto_ptr<Configuration> pconfig(Configuration::LoadAndVerify("testfiles/config15.txt", &verify, errMsg)); 
     413                std::auto_ptr<Configuration> pconfig( 
     414                        Configuration::LoadAndVerify( 
     415                                "testfiles" DIRECTORY_SEPARATOR "config15.txt", 
     416                        &verify, errMsg)); 
    382417                TEST_THAT(pconfig.get() != 0); 
    383418                TEST_THAT(errMsg.empty()); 
     
    392427                NamedLock lock1; 
    393428                // Try and get a lock on a name in a directory which doesn't exist 
    394                 TEST_CHECK_THROWS(lock1.TryAndGetLock("testfiles/non-exist/lock"), CommonException, OSFileError); 
     429                TEST_CHECK_THROWS(lock1.TryAndGetLock( 
     430                                "testfiles"  
     431                                DIRECTORY_SEPARATOR "non-exist" 
     432                                DIRECTORY_SEPARATOR "lock"),  
     433                        CommonException, OSFileError); 
     434 
    395435                // And a more resonable request 
    396                 TEST_THAT(lock1.TryAndGetLock("testfiles/lock1") == true); 
     436                TEST_THAT(lock1.TryAndGetLock( 
     437                        "testfiles" DIRECTORY_SEPARATOR "lock1") == true); 
     438 
    397439                // Try to lock something using the same lock 
    398                 TEST_CHECK_THROWS(lock1.TryAndGetLock("testfiles/non-exist/lock2"), CommonException, NamedLockAlreadyLockingSomething);          
     440                TEST_CHECK_THROWS( 
     441                        lock1.TryAndGetLock( 
     442                                "testfiles"  
     443                                DIRECTORY_SEPARATOR "non-exist" 
     444                                DIRECTORY_SEPARATOR "lock2"),  
     445                        CommonException, NamedLockAlreadyLockingSomething);              
    399446#if defined(HAVE_FLOCK) || HAVE_DECL_O_EXLOCK 
    400447                // And again on that name 
    401448                NamedLock lock2; 
    402                 TEST_THAT(lock2.TryAndGetLock("testfiles/lock1") == false); 
     449                TEST_THAT(lock2.TryAndGetLock( 
     450                        "testfiles" DIRECTORY_SEPARATOR "lock1") == false); 
    403451#endif 
    404452        } 
     
    406454                // Check that it unlocked when it went out of scope 
    407455                NamedLock lock3; 
    408                 TEST_THAT(lock3.TryAndGetLock("testfiles/lock1") == true); 
     456                TEST_THAT(lock3.TryAndGetLock( 
     457                        "testfiles" DIRECTORY_SEPARATOR "lock1") == true); 
    409458        } 
    410459        { 
    411460                // And unlocking works 
    412461                NamedLock lock4; 
    413                 TEST_CHECK_THROWS(lock4.ReleaseLock(), CommonException, NamedLockNotHeld);               
    414                 TEST_THAT(lock4.TryAndGetLock("testfiles/lock4") == true); 
     462                TEST_CHECK_THROWS(lock4.ReleaseLock(), CommonException,  
     463                        NamedLockNotHeld); 
     464                TEST_THAT(lock4.TryAndGetLock( 
     465                        "testfiles" DIRECTORY_SEPARATOR "lock4") == true); 
    415466                lock4.ReleaseLock(); 
    416467                NamedLock lock5; 
    417                 TEST_THAT(lock5.TryAndGetLock("testfiles/lock4") == true); 
     468                TEST_THAT(lock5.TryAndGetLock( 
     469                        "testfiles" DIRECTORY_SEPARATOR "lock4") == true); 
    418470                // And can reuse it 
    419                 TEST_THAT(lock4.TryAndGetLock("testfiles/lock5") == true); 
     471                TEST_THAT(lock4.TryAndGetLock( 
     472                        "testfiles" DIRECTORY_SEPARATOR "lock5") == true); 
    420473        } 
    421474 
  • box/trunk/test/crypto/testcrypto.cpp

    r217 r219  
    4444} 
    4545 
    46 #define ZERO_BUFFER(x) ::bzero(x, sizeof(x)); 
     46#define ZERO_BUFFER(x) ::memset(x, 0, sizeof(x)); 
    4747 
    4848template<typename CipherType, int BLOCKSIZE> 
Note: See TracChangeset for help on using the changeset viewer.