aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/test/io.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:27 -0500
committerJacek Antonelli2008-08-15 23:45:27 -0500
commita8a62201ba762e98dff92cf49033e577fc34d8d4 (patch)
tree11f8513c5cdc222f2fac0c93eb724c089803c200 /linden/indra/test/io.cpp
parentSecond Life viewer sources 1.18.6.4-RC (diff)
downloadmeta-impy-a8a62201ba762e98dff92cf49033e577fc34d8d4.zip
meta-impy-a8a62201ba762e98dff92cf49033e577fc34d8d4.tar.gz
meta-impy-a8a62201ba762e98dff92cf49033e577fc34d8d4.tar.bz2
meta-impy-a8a62201ba762e98dff92cf49033e577fc34d8d4.tar.xz
Second Life viewer sources 1.19.0.0
Diffstat (limited to 'linden/indra/test/io.cpp')
-rw-r--r--linden/indra/test/io.cpp68
1 files changed, 65 insertions, 3 deletions
diff --git a/linden/indra/test/io.cpp b/linden/indra/test/io.cpp
index 0a31e3a..facf98d 100644
--- a/linden/indra/test/io.cpp
+++ b/linden/indra/test/io.cpp
@@ -14,12 +14,12 @@
14 * ("GPL"), unless you have obtained a separate licensing agreement 14 * ("GPL"), unless you have obtained a separate licensing agreement
15 * ("Other License"), formally executed by you and Linden Lab. Terms of 15 * ("Other License"), formally executed by you and Linden Lab. Terms of
16 * the GPL can be found in doc/GPL-license.txt in this distribution, or 16 * the GPL can be found in doc/GPL-license.txt in this distribution, or
17 * online at http://secondlife.com/developers/opensource/gplv2 17 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
18 * 18 *
19 * There are special exceptions to the terms and conditions of the GPL as 19 * There are special exceptions to the terms and conditions of the GPL as
20 * it is applied to this Source Code. View the full text of the exception 20 * it is applied to this Source Code. View the full text of the exception
21 * in the file doc/FLOSS-exception.txt in this software distribution, or 21 * in the file doc/FLOSS-exception.txt in this software distribution, or
22 * online at http://secondlife.com/developers/opensource/flossexception 22 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
23 * 23 *
24 * By copying, modifying or distributing this software, you acknowledge 24 * By copying, modifying or distributing this software, you acknowledge
25 * that you have read and understood your obligations described above, 25 * that you have read and understood your obligations described above,
@@ -1080,7 +1080,7 @@ namespace tut
1080 mPool, 1080 mPool,
1081 mSocket, 1081 mSocket,
1082 factory); 1082 factory);
1083 server->setResponseTimeout(SHORT_CHAIN_EXPIRY_SECS + 2.0f); 1083 server->setResponseTimeout(SHORT_CHAIN_EXPIRY_SECS + 1.80f);
1084 chain.push_back(LLIOPipe::ptr_t(server)); 1084 chain.push_back(LLIOPipe::ptr_t(server));
1085 mPump->addChain(chain, NEVER_CHAIN_EXPIRY_SECS); 1085 mPump->addChain(chain, NEVER_CHAIN_EXPIRY_SECS);
1086 1086
@@ -1108,6 +1108,68 @@ namespace tut
1108 F32 elapsed = pump_loop(mPump, SHORT_CHAIN_EXPIRY_SECS + 3.0f); 1108 F32 elapsed = pump_loop(mPump, SHORT_CHAIN_EXPIRY_SECS + 3.0f);
1109 ensure("Did not take too long", (elapsed < DEFAULT_CHAIN_EXPIRY_SECS)); 1109 ensure("Did not take too long", (elapsed < DEFAULT_CHAIN_EXPIRY_SECS));
1110 } 1110 }
1111
1112 template<> template<>
1113 void fitness_test_object::test<5>()
1114 {
1115 // Set up the server
1116 LLPumpIO::chain_t chain;
1117 typedef LLCloneIOFactory<LLIOSleeper> sleeper_t;
1118 sleeper_t* sleeper = new sleeper_t(new LLIOSleeper);
1119 boost::shared_ptr<LLChainIOFactory> factory(sleeper);
1120 LLIOServerSocket* server = new LLIOServerSocket(
1121 mPool,
1122 mSocket,
1123 factory);
1124 server->setResponseTimeout(1.0);
1125 chain.push_back(LLIOPipe::ptr_t(server));
1126 mPump->addChain(chain, NEVER_CHAIN_EXPIRY_SECS);
1127 // We need to tickle the pump a little to set up the listen()
1128 pump_loop(mPump, 0.1f);
1129 U32 count = mPump->runningChains();
1130 ensure_equals("server chain onboard", count, 1);
1131 lldebugs << "** Server is up." << llendl;
1132
1133 // Set up the client
1134 LLSocket::ptr_t client = LLSocket::create(mPool, LLSocket::STREAM_TCP);
1135 LLHost server_host("127.0.0.1", SERVER_LISTEN_PORT);
1136 bool connected = client->blockingConnect(server_host);
1137 ensure("Connected to server", connected);
1138 lldebugs << "connected" << llendl;
1139 F32 elapsed = pump_loop(mPump,0.1f);
1140 count = mPump->runningChains();
1141 ensure_equals("server chain onboard", count, 2);
1142 lldebugs << "** Client is connected." << llendl;
1143
1144 // We have connected, since the socket reader does not block,
1145 // the first call to read data will return EAGAIN, so we need
1146 // to write something.
1147 chain.clear();
1148 chain.push_back(LLIOPipe::ptr_t(new LLPipeStringInjector("hi")));
1149 chain.push_back(LLIOPipe::ptr_t(new LLIOSocketWriter(client)));
1150 chain.push_back(LLIOPipe::ptr_t(new LLIONull));
1151 mPump->addChain(chain, 0.2);
1152 chain.clear();
1153
1154 // pump for a bit and make sure all 3 chains are running
1155 elapsed = pump_loop(mPump,0.1f);
1156 count = mPump->runningChains();
1157 ensure_equals("client chain onboard", count, 3);
1158 lldebugs << "** request should have been sent." << llendl;
1159
1160 // pump for long enough the the client socket closes, and the
1161 // server socket should not be closed yet.
1162 elapsed = pump_loop(mPump,0.2f);
1163 count = mPump->runningChains();
1164 ensure_equals("client chain timed out ", count, 2);
1165 lldebugs << "** client chain should be closed." << llendl;
1166
1167 // At this point, the socket should be closed by the timeout
1168 elapsed = pump_loop(mPump,1.0f);
1169 count = mPump->runningChains();
1170 ensure_equals("accepted socked close", count, 1);
1171 lldebugs << "** Sleeper should have timed out.." << llendl;
1172 }
1111} 1173}
1112 1174
1113namespace tut 1175namespace tut