blob: 4764a4c3cd84efb7e0d3951d9f1ab0a152c91205 [file] [log] [blame]
David Reissea2cba82009-03-30 21:35:00 +00001/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
Mark Sleee8540632006-05-30 09:24:40 +000020#include <stdio.h>
21#include <unistd.h>
Mark Slee95771002006-06-07 06:53:25 +000022#include <sys/time.h>
Marc Slemko6be374b2006-08-04 03:16:25 +000023#include <protocol/TBinaryProtocol.h>
Mark Sleea3302652006-10-25 19:03:32 +000024#include <transport/TTransportUtils.h>
Marc Slemko6be374b2006-08-04 03:16:25 +000025#include <transport/TSocket.h>
Mark Sleee8540632006-05-30 09:24:40 +000026
Marc Slemko6be374b2006-08-04 03:16:25 +000027#include <boost/shared_ptr.hpp>
28#include "ThriftTest.h"
29
David Reissbc3dddb2007-08-22 23:20:24 +000030#define __STDC_FORMAT_MACROS
31#include <inttypes.h>
32
Marc Slemko6be374b2006-08-04 03:16:25 +000033using namespace boost;
34using namespace std;
T Jake Lucianib5e62212009-01-31 22:36:20 +000035using namespace apache::thrift;
36using namespace apache::thrift::protocol;
37using namespace apache::thrift::transport;
Marc Slemkobf4fd192006-08-15 21:29:39 +000038using namespace thrift::test;
Marc Slemko6be374b2006-08-04 03:16:25 +000039
40//extern uint32_t g_socket_syscalls;
Mark Slee95771002006-06-07 06:53:25 +000041
42// Current time, microseconds since the epoch
43uint64_t now()
44{
45 long long ret;
46 struct timeval tv;
David Reiss0c90f6f2008-02-06 22:18:40 +000047
Mark Slee95771002006-06-07 06:53:25 +000048 gettimeofday(&tv, NULL);
49 ret = tv.tv_sec;
50 ret = ret*1000*1000 + tv.tv_usec;
51 return ret;
52}
53
Mark Sleee8540632006-05-30 09:24:40 +000054int main(int argc, char** argv) {
55 string host = "localhost";
56 int port = 9090;
57 int numTests = 1;
Mark Sleea3302652006-10-25 19:03:32 +000058 bool framed = false;
Mark Sleee8540632006-05-30 09:24:40 +000059
Mark Sleea3302652006-10-25 19:03:32 +000060 for (int i = 0; i < argc; ++i) {
61 if (strcmp(argv[i], "-h") == 0) {
62 char* pch = strtok(argv[++i], ":");
63 if (pch != NULL) {
64 host = string(pch);
65 }
66 pch = strtok(NULL, ":");
67 if (pch != NULL) {
68 port = atoi(pch);
69 }
70 } else if (strcmp(argv[i], "-n") == 0) {
71 numTests = atoi(argv[++i]);
72 } else if (strcmp(argv[i], "-f") == 0) {
73 framed = true;
Mark Sleea3302652006-10-25 19:03:32 +000074 }
Mark Sleee8540632006-05-30 09:24:40 +000075 }
Mark Sleea3302652006-10-25 19:03:32 +000076
77
78 shared_ptr<TTransport> transport;
Mark Sleee8540632006-05-30 09:24:40 +000079
Marc Slemko6be374b2006-08-04 03:16:25 +000080 shared_ptr<TSocket> socket(new TSocket(host, port));
David Reiss0c90f6f2008-02-06 22:18:40 +000081
Mark Sleea3302652006-10-25 19:03:32 +000082 if (framed) {
83 shared_ptr<TFramedTransport> framedSocket(new TFramedTransport(socket));
Mark Sleea3302652006-10-25 19:03:32 +000084 transport = framedSocket;
Mark Sleea3302652006-10-25 19:03:32 +000085 } else {
86 shared_ptr<TBufferedTransport> bufferedSocket(new TBufferedTransport(socket));
87 transport = bufferedSocket;
88 }
89
Mark Slee9e288d42007-01-24 23:42:12 +000090 shared_ptr<TBinaryProtocol> protocol(new TBinaryProtocol(transport));
Mark Sleea3302652006-10-25 19:03:32 +000091 ThriftTestClient testClient(protocol);
Mark Sleed788b2e2006-09-07 01:26:35 +000092
93 uint64_t time_min = 0;
94 uint64_t time_max = 0;
95 uint64_t time_tot = 0;
David Reiss0c90f6f2008-02-06 22:18:40 +000096
Mark Sleee8540632006-05-30 09:24:40 +000097 int test = 0;
98 for (test = 0; test < numTests; ++test) {
Mark Slee95771002006-06-07 06:53:25 +000099
Mark Slee95771002006-06-07 06:53:25 +0000100 try {
Mark Sleea3302652006-10-25 19:03:32 +0000101 transport->open();
Mark Slee95771002006-06-07 06:53:25 +0000102 } catch (TTransportException& ttx) {
Mark Sleeb9ff32a2006-11-16 01:00:24 +0000103 printf("Connect failed: %s\n", ttx.what());
Mark Sleee8540632006-05-30 09:24:40 +0000104 continue;
105 }
David Reiss0c90f6f2008-02-06 22:18:40 +0000106
Mark Sleed788b2e2006-09-07 01:26:35 +0000107 /**
108 * CONNECT TEST
109 */
110 printf("Test #%d, connect %s:%d\n", test+1, host.c_str(), port);
Mark Slee95771002006-06-07 06:53:25 +0000111
112 uint64_t start = now();
David Reiss0c90f6f2008-02-06 22:18:40 +0000113
Mark Sleee8540632006-05-30 09:24:40 +0000114 /**
115 * VOID TEST
116 */
Mark Sleee129a2d2007-02-21 05:17:48 +0000117 try {
118 printf("testVoid()");
119 testClient.testVoid();
120 printf(" = void\n");
121 } catch (TApplicationException tax) {
122 printf("%s\n", tax.what());
123 }
David Reiss0c90f6f2008-02-06 22:18:40 +0000124
Mark Sleee8540632006-05-30 09:24:40 +0000125 /**
126 * STRING TEST
127 */
128 printf("testString(\"Test\")");
Mark Slee1921d202007-01-24 19:43:06 +0000129 string s;
130 testClient.testString(s, "Test");
Mark Sleee8540632006-05-30 09:24:40 +0000131 printf(" = \"%s\"\n", s.c_str());
David Reiss0c90f6f2008-02-06 22:18:40 +0000132
Mark Sleee8540632006-05-30 09:24:40 +0000133 /**
134 * BYTE TEST
135 */
136 printf("testByte(1)");
137 uint8_t u8 = testClient.testByte(1);
138 printf(" = %d\n", (int)u8);
David Reiss0c90f6f2008-02-06 22:18:40 +0000139
Mark Sleee8540632006-05-30 09:24:40 +0000140 /**
141 * I32 TEST
142 */
143 printf("testI32(-1)");
144 int32_t i32 = testClient.testI32(-1);
145 printf(" = %d\n", i32);
146
147 /**
Mark Sleee8540632006-05-30 09:24:40 +0000148 * I64 TEST
149 */
150 printf("testI64(-34359738368)");
Marc Slemkobf4fd192006-08-15 21:29:39 +0000151 int64_t i64 = testClient.testI64(-34359738368LL);
David Reissbc3dddb2007-08-22 23:20:24 +0000152 printf(" = %"PRId64"\n", i64);
Mark Sleec98d0502006-09-06 02:42:25 +0000153
154 /**
155 * DOUBLE TEST
156 */
157 printf("testDouble(-5.2098523)");
158 double dub = testClient.testDouble(-5.2098523);
159 printf(" = %lf\n", dub);
David Reiss0c90f6f2008-02-06 22:18:40 +0000160
Mark Sleee8540632006-05-30 09:24:40 +0000161 /**
162 * STRUCT TEST
163 */
Mark Slee6e536442006-06-30 18:28:50 +0000164 printf("testStruct({\"Zero\", 1, -3, -5})");
Mark Sleee8540632006-05-30 09:24:40 +0000165 Xtruct out;
166 out.string_thing = "Zero";
167 out.byte_thing = 1;
Mark Sleee8540632006-05-30 09:24:40 +0000168 out.i32_thing = -3;
Mark Sleee8540632006-05-30 09:24:40 +0000169 out.i64_thing = -5;
Mark Slee1921d202007-01-24 19:43:06 +0000170 Xtruct in;
171 testClient.testStruct(in, out);
David Reissbc3dddb2007-08-22 23:20:24 +0000172 printf(" = {\"%s\", %d, %d, %"PRId64"}\n",
Mark Sleee8540632006-05-30 09:24:40 +0000173 in.string_thing.c_str(),
174 (int)in.byte_thing,
Mark Sleee8540632006-05-30 09:24:40 +0000175 in.i32_thing,
Mark Sleee8540632006-05-30 09:24:40 +0000176 in.i64_thing);
David Reiss0c90f6f2008-02-06 22:18:40 +0000177
Mark Sleee8540632006-05-30 09:24:40 +0000178 /**
179 * NESTED STRUCT TEST
180 */
Mark Slee6e536442006-06-30 18:28:50 +0000181 printf("testNest({1, {\"Zero\", 1, -3, -5}), 5}");
Mark Sleee8540632006-05-30 09:24:40 +0000182 Xtruct2 out2;
183 out2.byte_thing = 1;
184 out2.struct_thing = out;
185 out2.i32_thing = 5;
Mark Slee1921d202007-01-24 19:43:06 +0000186 Xtruct2 in2;
187 testClient.testNest(in2, out2);
Mark Sleee8540632006-05-30 09:24:40 +0000188 in = in2.struct_thing;
David Reissbc3dddb2007-08-22 23:20:24 +0000189 printf(" = {%d, {\"%s\", %d, %d, %"PRId64"}, %d}\n",
Mark Sleee8540632006-05-30 09:24:40 +0000190 in2.byte_thing,
191 in.string_thing.c_str(),
192 (int)in.byte_thing,
Mark Sleee8540632006-05-30 09:24:40 +0000193 in.i32_thing,
Mark Sleee8540632006-05-30 09:24:40 +0000194 in.i64_thing,
David Reiss0c90f6f2008-02-06 22:18:40 +0000195 in2.i32_thing);
Mark Sleee8540632006-05-30 09:24:40 +0000196
197 /**
198 * MAP TEST
199 */
200 map<int32_t,int32_t> mapout;
201 for (int32_t i = 0; i < 5; ++i) {
202 mapout.insert(make_pair(i, i-10));
203 }
204 printf("testMap({");
205 map<int32_t, int32_t>::const_iterator m_iter;
206 bool first = true;
207 for (m_iter = mapout.begin(); m_iter != mapout.end(); ++m_iter) {
208 if (first) {
209 first = false;
210 } else {
211 printf(", ");
212 }
213 printf("%d => %d", m_iter->first, m_iter->second);
214 }
215 printf("})");
Mark Slee1921d202007-01-24 19:43:06 +0000216 map<int32_t,int32_t> mapin;
217 testClient.testMap(mapin, mapout);
Mark Sleee8540632006-05-30 09:24:40 +0000218 printf(" = {");
219 first = true;
220 for (m_iter = mapin.begin(); m_iter != mapin.end(); ++m_iter) {
221 if (first) {
222 first = false;
223 } else {
224 printf(", ");
225 }
226 printf("%d => %d", m_iter->first, m_iter->second);
227 }
228 printf("}\n");
229
230 /**
231 * SET TEST
232 */
233 set<int32_t> setout;
234 for (int32_t i = -2; i < 3; ++i) {
235 setout.insert(i);
236 }
237 printf("testSet({");
238 set<int32_t>::const_iterator s_iter;
239 first = true;
240 for (s_iter = setout.begin(); s_iter != setout.end(); ++s_iter) {
241 if (first) {
242 first = false;
243 } else {
244 printf(", ");
245 }
246 printf("%d", *s_iter);
247 }
248 printf("})");
Mark Slee1921d202007-01-24 19:43:06 +0000249 set<int32_t> setin;
250 testClient.testSet(setin, setout);
Mark Sleee8540632006-05-30 09:24:40 +0000251 printf(" = {");
252 first = true;
253 for (s_iter = setin.begin(); s_iter != setin.end(); ++s_iter) {
254 if (first) {
255 first = false;
256 } else {
257 printf(", ");
258 }
259 printf("%d", *s_iter);
260 }
261 printf("}\n");
262
263 /**
264 * LIST TEST
265 */
Mark Sleeb9acf982006-10-10 01:57:32 +0000266 vector<int32_t> listout;
Mark Sleee8540632006-05-30 09:24:40 +0000267 for (int32_t i = -2; i < 3; ++i) {
268 listout.push_back(i);
269 }
270 printf("testList({");
Mark Sleeb9acf982006-10-10 01:57:32 +0000271 vector<int32_t>::const_iterator l_iter;
Mark Sleee8540632006-05-30 09:24:40 +0000272 first = true;
273 for (l_iter = listout.begin(); l_iter != listout.end(); ++l_iter) {
274 if (first) {
275 first = false;
276 } else {
277 printf(", ");
278 }
279 printf("%d", *l_iter);
280 }
281 printf("})");
Mark Slee1921d202007-01-24 19:43:06 +0000282 vector<int32_t> listin;
283 testClient.testList(listin, listout);
Mark Sleee8540632006-05-30 09:24:40 +0000284 printf(" = {");
285 first = true;
286 for (l_iter = listin.begin(); l_iter != listin.end(); ++l_iter) {
287 if (first) {
288 first = false;
289 } else {
290 printf(", ");
291 }
292 printf("%d", *l_iter);
293 }
294 printf("}\n");
295
296 /**
297 * ENUM TEST
298 */
299 printf("testEnum(ONE)");
Bryan Duxbury833ae492010-09-27 17:26:02 +0000300 Numberz::type ret = testClient.testEnum(Numberz::ONE);
Mark Sleee8540632006-05-30 09:24:40 +0000301 printf(" = %d\n", ret);
302
303 printf("testEnum(TWO)");
Bryan Duxbury833ae492010-09-27 17:26:02 +0000304 ret = testClient.testEnum(Numberz::TWO);
Mark Sleee8540632006-05-30 09:24:40 +0000305 printf(" = %d\n", ret);
306
307 printf("testEnum(THREE)");
Bryan Duxbury833ae492010-09-27 17:26:02 +0000308 ret = testClient.testEnum(Numberz::THREE);
Mark Sleee8540632006-05-30 09:24:40 +0000309 printf(" = %d\n", ret);
310
311 printf("testEnum(FIVE)");
Bryan Duxbury833ae492010-09-27 17:26:02 +0000312 ret = testClient.testEnum(Numberz::FIVE);
Mark Sleee8540632006-05-30 09:24:40 +0000313 printf(" = %d\n", ret);
314
315 printf("testEnum(EIGHT)");
Bryan Duxbury833ae492010-09-27 17:26:02 +0000316 ret = testClient.testEnum(Numberz::EIGHT);
Mark Sleee8540632006-05-30 09:24:40 +0000317 printf(" = %d\n", ret);
318
319 /**
320 * TYPEDEF TEST
321 */
322 printf("testTypedef(309858235082523)");
Marc Slemkobf4fd192006-08-15 21:29:39 +0000323 UserId uid = testClient.testTypedef(309858235082523LL);
David Reissbc3dddb2007-08-22 23:20:24 +0000324 printf(" = %"PRId64"\n", uid);
Mark Sleee8540632006-05-30 09:24:40 +0000325
326 /**
327 * NESTED MAP TEST
328 */
329 printf("testMapMap(1)");
Mark Slee1921d202007-01-24 19:43:06 +0000330 map<int32_t, map<int32_t, int32_t> > mm;
331 testClient.testMapMap(mm, 1);
Mark Sleee8540632006-05-30 09:24:40 +0000332 printf(" = {");
333 map<int32_t, map<int32_t, int32_t> >::const_iterator mi;
334 for (mi = mm.begin(); mi != mm.end(); ++mi) {
335 printf("%d => {", mi->first);
336 map<int32_t, int32_t>::const_iterator mi2;
337 for (mi2 = mi->second.begin(); mi2 != mi->second.end(); ++mi2) {
338 printf("%d => %d, ", mi2->first, mi2->second);
339 }
340 printf("}, ");
341 }
342 printf("}\n");
343
344 /**
345 * INSANITY TEST
346 */
347 Insanity insane;
Bryan Duxbury833ae492010-09-27 17:26:02 +0000348 insane.userMap.insert(make_pair(Numberz::FIVE, 5000));
Mark Sleee8540632006-05-30 09:24:40 +0000349 Xtruct truck;
350 truck.string_thing = "Truck";
351 truck.byte_thing = 8;
Mark Sleee8540632006-05-30 09:24:40 +0000352 truck.i32_thing = 8;
Mark Sleee8540632006-05-30 09:24:40 +0000353 truck.i64_thing = 8;
354 insane.xtructs.push_back(truck);
355 printf("testInsanity()");
Bryan Duxbury833ae492010-09-27 17:26:02 +0000356 map<UserId, map<Numberz::type,Insanity> > whoa;
Mark Slee1921d202007-01-24 19:43:06 +0000357 testClient.testInsanity(whoa, insane);
Mark Sleee8540632006-05-30 09:24:40 +0000358 printf(" = {");
Bryan Duxbury833ae492010-09-27 17:26:02 +0000359 map<UserId, map<Numberz::type,Insanity> >::const_iterator i_iter;
Mark Sleee8540632006-05-30 09:24:40 +0000360 for (i_iter = whoa.begin(); i_iter != whoa.end(); ++i_iter) {
David Reissbc3dddb2007-08-22 23:20:24 +0000361 printf("%"PRId64" => {", i_iter->first);
Bryan Duxbury833ae492010-09-27 17:26:02 +0000362 map<Numberz::type,Insanity>::const_iterator i2_iter;
Mark Sleee8540632006-05-30 09:24:40 +0000363 for (i2_iter = i_iter->second.begin();
364 i2_iter != i_iter->second.end();
365 ++i2_iter) {
366 printf("%d => {", i2_iter->first);
Bryan Duxbury833ae492010-09-27 17:26:02 +0000367 map<Numberz::type, UserId> userMap = i2_iter->second.userMap;
368 map<Numberz::type, UserId>::const_iterator um;
Mark Sleee8540632006-05-30 09:24:40 +0000369 printf("{");
370 for (um = userMap.begin(); um != userMap.end(); ++um) {
David Reissbc3dddb2007-08-22 23:20:24 +0000371 printf("%d => %"PRId64", ", um->first, um->second);
Mark Sleee8540632006-05-30 09:24:40 +0000372 }
373 printf("}, ");
374
Mark Sleeb9acf982006-10-10 01:57:32 +0000375 vector<Xtruct> xtructs = i2_iter->second.xtructs;
376 vector<Xtruct>::const_iterator x;
Mark Sleee8540632006-05-30 09:24:40 +0000377 printf("{");
378 for (x = xtructs.begin(); x != xtructs.end(); ++x) {
David Reissbc3dddb2007-08-22 23:20:24 +0000379 printf("{\"%s\", %d, %d, %"PRId64"}, ",
Mark Sleee8540632006-05-30 09:24:40 +0000380 x->string_thing.c_str(),
381 (int)x->byte_thing,
Mark Sleee8540632006-05-30 09:24:40 +0000382 x->i32_thing,
Mark Sleee8540632006-05-30 09:24:40 +0000383 x->i64_thing);
384 }
385 printf("}");
386
387 printf("}, ");
388 }
389 printf("}, ");
390 }
391 printf("}\n");
392
Marc Slemko71d4e472006-08-15 22:34:04 +0000393 /* test exception */
Mark Slee95771002006-06-07 06:53:25 +0000394
Marc Slemkobf4fd192006-08-15 21:29:39 +0000395 try {
Marc Slemko71d4e472006-08-15 22:34:04 +0000396 printf("testClient.testException(\"Xception\") =>");
397 testClient.testException("Xception");
398 printf(" void\nFAILURE\n");
David Reiss0c90f6f2008-02-06 22:18:40 +0000399
Mark Sleeb9ff32a2006-11-16 01:00:24 +0000400 } catch(Xception& e) {
Marc Slemko71d4e472006-08-15 22:34:04 +0000401 printf(" {%u, \"%s\"}\n", e.errorCode, e.message.c_str());
Marc Slemkobf4fd192006-08-15 21:29:39 +0000402 }
David Reiss0c90f6f2008-02-06 22:18:40 +0000403
Marc Slemkobf4fd192006-08-15 21:29:39 +0000404 try {
Marc Slemko71d4e472006-08-15 22:34:04 +0000405 printf("testClient.testException(\"success\") =>");
406 testClient.testException("success");
407 printf(" void\n");
408 } catch(...) {
409 printf(" exception\nFAILURE\n");
410 }
David Reiss0c90f6f2008-02-06 22:18:40 +0000411
Marc Slemko71d4e472006-08-15 22:34:04 +0000412 /* test multi exception */
David Reiss0c90f6f2008-02-06 22:18:40 +0000413
Marc Slemko71d4e472006-08-15 22:34:04 +0000414 try {
415 printf("testClient.testMultiException(\"Xception\", \"test 1\") =>");
Mark Slee1921d202007-01-24 19:43:06 +0000416 Xtruct result;
417 testClient.testMultiException(result, "Xception", "test 1");
Marc Slemko71d4e472006-08-15 22:34:04 +0000418 printf(" result\nFAILURE\n");
Mark Sleed3d733a2006-09-01 22:19:06 +0000419 } catch(Xception& e) {
Marc Slemko71d4e472006-08-15 22:34:04 +0000420 printf(" {%u, \"%s\"}\n", e.errorCode, e.message.c_str());
421 }
422
423 try {
424 printf("testClient.testMultiException(\"Xception2\", \"test 2\") =>");
Mark Slee1921d202007-01-24 19:43:06 +0000425 Xtruct result;
426 testClient.testMultiException(result, "Xception2", "test 2");
Marc Slemko71d4e472006-08-15 22:34:04 +0000427 printf(" result\nFAILURE\n");
David Reiss0c90f6f2008-02-06 22:18:40 +0000428
Mark Sleed3d733a2006-09-01 22:19:06 +0000429 } catch(Xception2& e) {
Marc Slemko71d4e472006-08-15 22:34:04 +0000430 printf(" {%u, {\"%s\"}}\n", e.errorCode, e.struct_thing.string_thing.c_str());
Marc Slemkobf4fd192006-08-15 21:29:39 +0000431 }
David Reiss0c90f6f2008-02-06 22:18:40 +0000432
Marc Slemko71d4e472006-08-15 22:34:04 +0000433 try {
434 printf("testClient.testMultiException(\"success\", \"test 3\") =>");
Mark Slee1921d202007-01-24 19:43:06 +0000435 Xtruct result;
436 testClient.testMultiException(result, "success", "test 3");
Marc Slemko71d4e472006-08-15 22:34:04 +0000437 printf(" {{\"%s\"}}\n", result.string_thing.c_str());
438 } catch(...) {
439 printf(" exception\nFAILURE\n");
440 }
David Reiss0c90f6f2008-02-06 22:18:40 +0000441
David Reissc51986f2009-03-24 20:01:25 +0000442 /* test oneway void */
David Reiss2ab6fe82008-02-18 02:11:44 +0000443 {
David Reiss6ce401d2009-03-24 20:01:58 +0000444 printf("testClient.testOneway(3) =>");
445 uint64_t startOneway = now();
446 testClient.testOneway(3);
447 uint64_t elapsed = now() - startOneway;
David Reiss2ab6fe82008-02-18 02:11:44 +0000448 if (elapsed > 200 * 1000) { // 0.2 seconds
449 printf(" FAILURE - took %.2f ms\n", (double)elapsed/1000.0);
450 } else {
451 printf(" success - took %.2f ms\n", (double)elapsed/1000.0);
452 }
453 }
454
David Reiss2845b522008-02-18 02:11:52 +0000455 /**
David Reissc51986f2009-03-24 20:01:25 +0000456 * redo a simple test after the oneway to make sure we aren't "off by one" --
457 * if the server treated oneway void like normal void, this next test will
David Reiss2845b522008-02-18 02:11:52 +0000458 * fail since it will get the void confirmation rather than the correct
459 * result. In this circumstance, the client will throw the exception:
460 *
461 * TApplicationException: Wrong method namea
462 */
463 /**
464 * I32 TEST
465 */
466 printf("re-test testI32(-1)");
467 i32 = testClient.testI32(-1);
468 printf(" = %d\n", i32);
469
470
Marc Slemkobf4fd192006-08-15 21:29:39 +0000471 uint64_t stop = now();
Mark Sleed788b2e2006-09-07 01:26:35 +0000472 uint64_t tot = stop-start;
473
David Reissbc3dddb2007-08-22 23:20:24 +0000474 printf("Total time: %"PRIu64" us\n", stop-start);
David Reiss0c90f6f2008-02-06 22:18:40 +0000475
Mark Sleed788b2e2006-09-07 01:26:35 +0000476 time_tot += tot;
477 if (time_min == 0 || tot < time_min) {
478 time_min = tot;
479 }
480 if (tot > time_max) {
481 time_max = tot;
482 }
483
Mark Sleea3302652006-10-25 19:03:32 +0000484 transport->close();
Mark Sleee8540632006-05-30 09:24:40 +0000485 }
486
Marc Slemko6be374b2006-08-04 03:16:25 +0000487 // printf("\nSocket syscalls: %u", g_socket_syscalls);
Mark Sleee8540632006-05-30 09:24:40 +0000488 printf("\nAll tests done.\n");
Mark Sleed788b2e2006-09-07 01:26:35 +0000489
490 uint64_t time_avg = time_tot / numTests;
491
David Reissbc3dddb2007-08-22 23:20:24 +0000492 printf("Min time: %"PRIu64" us\n", time_min);
493 printf("Max time: %"PRIu64" us\n", time_max);
494 printf("Avg time: %"PRIu64" us\n", time_avg);
Mark Sleed788b2e2006-09-07 01:26:35 +0000495
Mark Sleee8540632006-05-30 09:24:40 +0000496 return 0;
497}