Changeset 2014 for box/trunk/test


Ignore:
Timestamp:
18/12/2007 00:21:38 (4 years ago)
Author:
chris
Message:

Send data back from test daemon to test code, and wait for it to be
received in the test code, to avoid synchronisation issue where the
QUIT command appears to be part of the received data. Mostly harmless,
but gives a false alarm when viewing the test output.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • box/trunk/test/basicserver/testbasicserver.cpp

    r2010 r2014  
    127127                                } 
    128128                                TEST_THAT(total == LARGE_DATA_SIZE); 
     129                                if (total != LARGE_DATA_SIZE) 
     130                                { 
     131                                        BOX_ERROR("Expected " <<  
     132                                                LARGE_DATA_SIZE << " bytes " << 
     133                                                "but was " << total); 
     134                                        return; 
     135                                } 
     136                        } 
     137                        { 
     138                                // Send lots of data again 
     139                                char data[LARGE_DATA_BLOCK_SIZE]; 
     140                                for(unsigned int y = 0; y < sizeof(data); y++) 
     141                                { 
     142                                        data[y] = y & 0xff; 
     143                                } 
     144                                for(int s = 0; s < (LARGE_DATA_SIZE / LARGE_DATA_BLOCK_SIZE); ++s) 
     145                                { 
     146                                        rStream.Write(data, sizeof(data)); 
     147                                } 
    129148                        } 
    130149                         
     
    346365                } 
    347366        } 
     367        for(unsigned int c = 0; c < conns.size(); ++c) 
     368        { 
     369                // Receive lots of data again 
     370                char buf[1024]; 
     371                int total = 0; 
     372                int r = 0; 
     373                while(total < LARGE_DATA_SIZE && (r = conns[c]->Read(buf, sizeof(buf))) != 0) 
     374                { 
     375                        total += r; 
     376                } 
     377                TEST_THAT(total == LARGE_DATA_SIZE); 
     378        } 
    348379 
    349380        for(unsigned int c = 0; c < conns.size(); ++c) 
     
    408439        if(argc >= 2) 
    409440        { 
    410                 if(strcmp(argv[1], "srv1") == 0) 
     441                // this is a quick hack to allow passing some options 
     442                // to the daemon 
     443 
     444                const char* mode = argv[1]; 
     445 
     446                if (test_args.length() > 0) 
     447                { 
     448                        argv[1] = test_args.c_str(); 
     449                } 
     450                else 
     451                { 
     452                        argc--; 
     453                        argv++; 
     454                } 
     455 
     456                if(strcmp(mode, "srv1") == 0) 
    411457                { 
    412458                        // Run very basic daemon 
    413459                        basicdaemon daemon; 
    414                         return daemon.Main("doesnotexist", argc - 1, argv + 1); 
    415                 } 
    416                 else if(strcmp(argv[1], "srv2") == 0) 
     460                        return daemon.Main("doesnotexist", argc, argv); 
     461                } 
     462                else if(strcmp(mode, "srv2") == 0) 
    417463                { 
    418464                        // Run daemon which accepts connections 
    419465                        testserver daemon; 
    420                         return daemon.Main("doesnotexist", argc - 1, argv + 1); 
     466                        return daemon.Main("doesnotexist", argc, argv); 
    421467                }                
    422                 else if(strcmp(argv[1], "srv3") == 0) 
     468                else if(strcmp(mode, "srv3") == 0) 
    423469                { 
    424470                        testTLSserver daemon; 
    425                         return daemon.Main("doesnotexist", argc - 1, argv + 1); 
    426                 } 
    427                 else if(strcmp(argv[1], "srv4") == 0) 
     471                        return daemon.Main("doesnotexist", argc, argv); 
     472                } 
     473                else if(strcmp(mode, "srv4") == 0) 
    428474                { 
    429475                        testProtocolServer daemon; 
    430                         return daemon.Main("doesnotexist", argc - 1, argv + 1); 
     476                        return daemon.Main("doesnotexist", argc, argv); 
    431477                } 
    432478        } 
     
    437483        // Launch a basic server 
    438484        { 
    439                 std::string cmd = "./test"; 
     485                std::string cmd = "./test --test-daemon-args="; 
    440486                cmd += test_args; 
    441487                cmd += " srv1 testfiles/srv1.conf"; 
     
    483529        // Launch a test forking server 
    484530        { 
    485                 std::string cmd = "./test"; 
     531                std::string cmd = "./test --test-daemon-args="; 
    486532                cmd += test_args; 
    487533                cmd += " srv2 testfiles/srv2.conf"; 
     
    553599        // Launch a test SSL server 
    554600        { 
    555                 std::string cmd = "./test"; 
     601                std::string cmd = "./test --test-daemon-args="; 
    556602                cmd += test_args; 
    557603                cmd += " srv3 testfiles/srv3.conf"; 
     
    634680        // Launch a test protocol handling server 
    635681        { 
    636                 std::string cmd = "./test"; 
     682                std::string cmd = "./test --test-daemon-args="; 
    637683                cmd += test_args; 
    638684                cmd += " srv4 testfiles/srv4.conf"; 
Note: See TracChangeset for help on using the changeset viewer.