diff options
author | Aaron Brashears <aaronb@lindenlab.com> | 2007-12-05 01:15:45 +0000 |
---|---|---|
committer | Aaron Brashears <aaronb@lindenlab.com> | 2007-12-05 01:15:45 +0000 |
commit | 2a9be0445b82fdca0fb98da20f74c0200a9bffe1 (patch) | |
tree | 7dcc2d3727b33d950aa9ea4026a9c3873eabb5ad /indra/test | |
parent | f8511d77a70bea452cde7270b47044358e58427c (diff) |
Result of svn merge -r74235:74242 svn+ssh://svn/svn/linden/branches/robust-pump into release
Diffstat (limited to 'indra/test')
-rw-r--r-- | indra/test/io.cpp | 64 | ||||
-rw-r--r-- | indra/test/llpipeutil.cpp | 22 | ||||
-rw-r--r-- | indra/test/llpipeutil.h | 20 | ||||
-rw-r--r-- | indra/test/test.cpp | 9 |
4 files changed, 113 insertions, 2 deletions
diff --git a/indra/test/io.cpp b/indra/test/io.cpp index 363f375014..350fc5394b 100644 --- a/indra/test/io.cpp +++ b/indra/test/io.cpp @@ -1080,7 +1080,7 @@ namespace tut mPool, mSocket, factory); - server->setResponseTimeout(SHORT_CHAIN_EXPIRY_SECS + 2.0f); + server->setResponseTimeout(SHORT_CHAIN_EXPIRY_SECS + 1.80f); chain.push_back(LLIOPipe::ptr_t(server)); mPump->addChain(chain, NEVER_CHAIN_EXPIRY_SECS); @@ -1108,6 +1108,68 @@ namespace tut F32 elapsed = pump_loop(mPump, SHORT_CHAIN_EXPIRY_SECS + 3.0f); ensure("Did not take too long", (elapsed < DEFAULT_CHAIN_EXPIRY_SECS)); } + + template<> template<> + void fitness_test_object::test<5>() + { + // Set up the server + LLPumpIO::chain_t chain; + typedef LLCloneIOFactory<LLIOSleeper> sleeper_t; + sleeper_t* sleeper = new sleeper_t(new LLIOSleeper); + boost::shared_ptr<LLChainIOFactory> factory(sleeper); + LLIOServerSocket* server = new LLIOServerSocket( + mPool, + mSocket, + factory); + server->setResponseTimeout(1.0); + chain.push_back(LLIOPipe::ptr_t(server)); + mPump->addChain(chain, NEVER_CHAIN_EXPIRY_SECS); + // We need to tickle the pump a little to set up the listen() + pump_loop(mPump, 0.1f); + U32 count = mPump->runningChains(); + ensure_equals("server chain onboard", count, 1); + lldebugs << "** Server is up." << llendl; + + // Set up the client + LLSocket::ptr_t client = LLSocket::create(mPool, LLSocket::STREAM_TCP); + LLHost server_host("127.0.0.1", SERVER_LISTEN_PORT); + bool connected = client->blockingConnect(server_host); + ensure("Connected to server", connected); + lldebugs << "connected" << llendl; + F32 elapsed = pump_loop(mPump,0.1f); + count = mPump->runningChains(); + ensure_equals("server chain onboard", count, 2); + lldebugs << "** Client is connected." << llendl; + + // We have connected, since the socket reader does not block, + // the first call to read data will return EAGAIN, so we need + // to write something. + chain.clear(); + chain.push_back(LLIOPipe::ptr_t(new LLPipeStringInjector("hi"))); + chain.push_back(LLIOPipe::ptr_t(new LLIOSocketWriter(client))); + chain.push_back(LLIOPipe::ptr_t(new LLIONull)); + mPump->addChain(chain, 0.2); + chain.clear(); + + // pump for a bit and make sure all 3 chains are running + elapsed = pump_loop(mPump,0.1f); + count = mPump->runningChains(); + ensure_equals("client chain onboard", count, 3); + lldebugs << "** request should have been sent." << llendl; + + // pump for long enough the the client socket closes, and the + // server socket should not be closed yet. + elapsed = pump_loop(mPump,0.2f); + count = mPump->runningChains(); + ensure_equals("client chain timed out ", count, 2); + lldebugs << "** client chain should be closed." << llendl; + + // At this point, the socket should be closed by the timeout + elapsed = pump_loop(mPump,1.0f); + count = mPump->runningChains(); + ensure_equals("accepted socked close", count, 1); + lldebugs << "** Sleeper should have timed out.." << llendl; + } } namespace tut diff --git a/indra/test/llpipeutil.cpp b/indra/test/llpipeutil.cpp index b7b9122615..c9c1eeb8b4 100644 --- a/indra/test/llpipeutil.cpp +++ b/indra/test/llpipeutil.cpp @@ -164,3 +164,25 @@ LLIOPipe::EStatus LLIONull::process_impl( { return STATUS_OK; } + +// virtual +LLIOPipe::EStatus LLIOSleeper::process_impl( + const LLChannelDescriptors& channels, + buffer_ptr_t& buffer, + bool& eos, + LLSD& context, + LLPumpIO* pump) +{ + if(!mRespond) + { + lldebugs << "LLIOSleeper::process_impl() sleeping." << llendl; + mRespond = true; + static const F64 SLEEP_TIME = 2.0; + pump->sleepChain(SLEEP_TIME); + return STATUS_BREAK; + } + lldebugs << "LLIOSleeper::process_impl() responding." << llendl; + LLBufferStream ostr(channels, buffer.get()); + ostr << "huh? sorry, I was sleeping." << std::endl; + return STATUS_DONE; +} diff --git a/indra/test/llpipeutil.h b/indra/test/llpipeutil.h index 25311780ac..a52f141d55 100644 --- a/indra/test/llpipeutil.h +++ b/indra/test/llpipeutil.h @@ -145,4 +145,24 @@ protected: LLPumpIO* pump); }; +/** + * @brief Pipe that sleeps, and then responds later. + */ +class LLIOSleeper : public LLIOPipe +{ +public: + LLIOSleeper() : mRespond(false) {} + +protected: + virtual EStatus process_impl( + const LLChannelDescriptors& channels, + buffer_ptr_t& buffer, + bool& eos, + LLSD& context, + LLPumpIO* pump); +private: + bool mRespond; + +}; + #endif // LL_LLPIPEUTIL_H diff --git a/indra/test/test.cpp b/indra/test/test.cpp index fc8f8d9711..f573d53ba8 100644 --- a/indra/test/test.cpp +++ b/indra/test/test.cpp @@ -170,6 +170,7 @@ static const apr_getopt_option_t TEST_CL_OPTIONS[] = {"group", 'g', 1, "Run test group specified by option argument."}, {"skip", 's', 1, "Skip test number specified by option argument. Only works when a specific group is being tested"}, {"wait", 'w', 0, "Wait for input before exit."}, + {"debug", 'd', 0, "Emit full debug logs."}, {0, 0, 0, 0} }; @@ -224,7 +225,8 @@ int main(int argc, char **argv) LLError::initForApplication("."); LLError::setFatalFunction(wouldHaveCrashed); LLError::setDefaultLevel(LLError::LEVEL_ERROR); - // *FIX: should come from error config file + //< *TODO: should come from error config file. Note that we + // have a command line option that sets this to debug. #ifdef CTYPE_WORKAROUND ctype_workaround(); @@ -286,6 +288,11 @@ int main(int argc, char **argv) case 'w': wait_at_exit = true; break; + case 'd': + // *TODO: should come from error config file. We set it to + // ERROR by default, so this allows full debug levels. + LLError::setDefaultLevel(LLError::LEVEL_DEBUG); + break; default: stream_usage(std::cerr, argv[0]); return 1; |