blob: 897153ab435df97ba8c1dd2afa009af19d168c53 [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{
Roger Meier5f9614c2010-11-21 16:59:05 +000045 int64_t ret;
Mark Slee95771002006-06-07 06:53:25 +000046 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
David Reisse71115b2010-10-06 17:09:56 +000078 shared_ptr<TBufferBase> 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
David Reisse71115b2010-10-06 17:09:56 +000090 shared_ptr< TBinaryProtocolT<TBufferBase> > protocol(
91 new TBinaryProtocolT<TBufferBase>(transport));
David Reissb7762a02010-10-06 17:10:00 +000092 ThriftTestClientT< TBinaryProtocolT<TBufferBase> > testClient(protocol);
Mark Sleed788b2e2006-09-07 01:26:35 +000093
94 uint64_t time_min = 0;
95 uint64_t time_max = 0;
96 uint64_t time_tot = 0;
David Reiss0c90f6f2008-02-06 22:18:40 +000097
Mark Sleee8540632006-05-30 09:24:40 +000098 int test = 0;
99 for (test = 0; test < numTests; ++test) {
Mark Slee95771002006-06-07 06:53:25 +0000100
Mark Slee95771002006-06-07 06:53:25 +0000101 try {
Mark Sleea3302652006-10-25 19:03:32 +0000102 transport->open();
Mark Slee95771002006-06-07 06:53:25 +0000103 } catch (TTransportException& ttx) {
Mark Sleeb9ff32a2006-11-16 01:00:24 +0000104 printf("Connect failed: %s\n", ttx.what());
Mark Sleee8540632006-05-30 09:24:40 +0000105 continue;
106 }
David Reiss0c90f6f2008-02-06 22:18:40 +0000107
Mark Sleed788b2e2006-09-07 01:26:35 +0000108 /**
109 * CONNECT TEST
110 */
111 printf("Test #%d, connect %s:%d\n", test+1, host.c_str(), port);
Mark Slee95771002006-06-07 06:53:25 +0000112
113 uint64_t start = now();
David Reiss0c90f6f2008-02-06 22:18:40 +0000114
Mark Sleee8540632006-05-30 09:24:40 +0000115 /**
116 * VOID TEST
117 */
Mark Sleee129a2d2007-02-21 05:17:48 +0000118 try {
119 printf("testVoid()");
120 testClient.testVoid();
121 printf(" = void\n");
122 } catch (TApplicationException tax) {
123 printf("%s\n", tax.what());
124 }
David Reiss0c90f6f2008-02-06 22:18:40 +0000125
Mark Sleee8540632006-05-30 09:24:40 +0000126 /**
127 * STRING TEST
128 */
129 printf("testString(\"Test\")");
Mark Slee1921d202007-01-24 19:43:06 +0000130 string s;
131 testClient.testString(s, "Test");
Mark Sleee8540632006-05-30 09:24:40 +0000132 printf(" = \"%s\"\n", s.c_str());
David Reiss0c90f6f2008-02-06 22:18:40 +0000133
Mark Sleee8540632006-05-30 09:24:40 +0000134 /**
135 * BYTE TEST
136 */
137 printf("testByte(1)");
138 uint8_t u8 = testClient.testByte(1);
139 printf(" = %d\n", (int)u8);
David Reiss0c90f6f2008-02-06 22:18:40 +0000140
Mark Sleee8540632006-05-30 09:24:40 +0000141 /**
142 * I32 TEST
143 */
144 printf("testI32(-1)");
145 int32_t i32 = testClient.testI32(-1);
146 printf(" = %d\n", i32);
147
148 /**
Mark Sleee8540632006-05-30 09:24:40 +0000149 * I64 TEST
150 */
151 printf("testI64(-34359738368)");
Marc Slemkobf4fd192006-08-15 21:29:39 +0000152 int64_t i64 = testClient.testI64(-34359738368LL);
David Reissbc3dddb2007-08-22 23:20:24 +0000153 printf(" = %"PRId64"\n", i64);
Mark Sleec98d0502006-09-06 02:42:25 +0000154
155 /**
156 * DOUBLE TEST
157 */
158 printf("testDouble(-5.2098523)");
159 double dub = testClient.testDouble(-5.2098523);
160 printf(" = %lf\n", dub);
David Reiss0c90f6f2008-02-06 22:18:40 +0000161
Mark Sleee8540632006-05-30 09:24:40 +0000162 /**
163 * STRUCT TEST
164 */
Mark Slee6e536442006-06-30 18:28:50 +0000165 printf("testStruct({\"Zero\", 1, -3, -5})");
Mark Sleee8540632006-05-30 09:24:40 +0000166 Xtruct out;
167 out.string_thing = "Zero";
168 out.byte_thing = 1;
Mark Sleee8540632006-05-30 09:24:40 +0000169 out.i32_thing = -3;
Mark Sleee8540632006-05-30 09:24:40 +0000170 out.i64_thing = -5;
Mark Slee1921d202007-01-24 19:43:06 +0000171 Xtruct in;
172 testClient.testStruct(in, out);
David Reissbc3dddb2007-08-22 23:20:24 +0000173 printf(" = {\"%s\", %d, %d, %"PRId64"}\n",
Mark Sleee8540632006-05-30 09:24:40 +0000174 in.string_thing.c_str(),
175 (int)in.byte_thing,
Mark Sleee8540632006-05-30 09:24:40 +0000176 in.i32_thing,
Mark Sleee8540632006-05-30 09:24:40 +0000177 in.i64_thing);
David Reiss0c90f6f2008-02-06 22:18:40 +0000178
Mark Sleee8540632006-05-30 09:24:40 +0000179 /**
180 * NESTED STRUCT TEST
181 */
Mark Slee6e536442006-06-30 18:28:50 +0000182 printf("testNest({1, {\"Zero\", 1, -3, -5}), 5}");
Mark Sleee8540632006-05-30 09:24:40 +0000183 Xtruct2 out2;
184 out2.byte_thing = 1;
185 out2.struct_thing = out;
186 out2.i32_thing = 5;
Mark Slee1921d202007-01-24 19:43:06 +0000187 Xtruct2 in2;
188 testClient.testNest(in2, out2);
Mark Sleee8540632006-05-30 09:24:40 +0000189 in = in2.struct_thing;
David Reissbc3dddb2007-08-22 23:20:24 +0000190 printf(" = {%d, {\"%s\", %d, %d, %"PRId64"}, %d}\n",
Mark Sleee8540632006-05-30 09:24:40 +0000191 in2.byte_thing,
192 in.string_thing.c_str(),
193 (int)in.byte_thing,
Mark Sleee8540632006-05-30 09:24:40 +0000194 in.i32_thing,
Mark Sleee8540632006-05-30 09:24:40 +0000195 in.i64_thing,
David Reiss0c90f6f2008-02-06 22:18:40 +0000196 in2.i32_thing);
Mark Sleee8540632006-05-30 09:24:40 +0000197
198 /**
199 * MAP TEST
200 */
201 map<int32_t,int32_t> mapout;
202 for (int32_t i = 0; i < 5; ++i) {
203 mapout.insert(make_pair(i, i-10));
204 }
205 printf("testMap({");
206 map<int32_t, int32_t>::const_iterator m_iter;
207 bool first = true;
208 for (m_iter = mapout.begin(); m_iter != mapout.end(); ++m_iter) {
209 if (first) {
210 first = false;
211 } else {
212 printf(", ");
213 }
214 printf("%d => %d", m_iter->first, m_iter->second);
215 }
216 printf("})");
Mark Slee1921d202007-01-24 19:43:06 +0000217 map<int32_t,int32_t> mapin;
218 testClient.testMap(mapin, mapout);
Mark Sleee8540632006-05-30 09:24:40 +0000219 printf(" = {");
220 first = true;
221 for (m_iter = mapin.begin(); m_iter != mapin.end(); ++m_iter) {
222 if (first) {
223 first = false;
224 } else {
225 printf(", ");
226 }
227 printf("%d => %d", m_iter->first, m_iter->second);
228 }
229 printf("}\n");
230
231 /**
232 * SET TEST
233 */
234 set<int32_t> setout;
235 for (int32_t i = -2; i < 3; ++i) {
236 setout.insert(i);
237 }
238 printf("testSet({");
239 set<int32_t>::const_iterator s_iter;
240 first = true;
241 for (s_iter = setout.begin(); s_iter != setout.end(); ++s_iter) {
242 if (first) {
243 first = false;
244 } else {
245 printf(", ");
246 }
247 printf("%d", *s_iter);
248 }
249 printf("})");
Mark Slee1921d202007-01-24 19:43:06 +0000250 set<int32_t> setin;
251 testClient.testSet(setin, setout);
Mark Sleee8540632006-05-30 09:24:40 +0000252 printf(" = {");
253 first = true;
254 for (s_iter = setin.begin(); s_iter != setin.end(); ++s_iter) {
255 if (first) {
256 first = false;
257 } else {
258 printf(", ");
259 }
260 printf("%d", *s_iter);
261 }
262 printf("}\n");
263
264 /**
265 * LIST TEST
266 */
Mark Sleeb9acf982006-10-10 01:57:32 +0000267 vector<int32_t> listout;
Mark Sleee8540632006-05-30 09:24:40 +0000268 for (int32_t i = -2; i < 3; ++i) {
269 listout.push_back(i);
270 }
271 printf("testList({");
Mark Sleeb9acf982006-10-10 01:57:32 +0000272 vector<int32_t>::const_iterator l_iter;
Mark Sleee8540632006-05-30 09:24:40 +0000273 first = true;
274 for (l_iter = listout.begin(); l_iter != listout.end(); ++l_iter) {
275 if (first) {
276 first = false;
277 } else {
278 printf(", ");
279 }
280 printf("%d", *l_iter);
281 }
282 printf("})");
Mark Slee1921d202007-01-24 19:43:06 +0000283 vector<int32_t> listin;
284 testClient.testList(listin, listout);
Mark Sleee8540632006-05-30 09:24:40 +0000285 printf(" = {");
286 first = true;
287 for (l_iter = listin.begin(); l_iter != listin.end(); ++l_iter) {
288 if (first) {
289 first = false;
290 } else {
291 printf(", ");
292 }
293 printf("%d", *l_iter);
294 }
295 printf("}\n");
296
297 /**
298 * ENUM TEST
299 */
300 printf("testEnum(ONE)");
Bryan Duxbury833ae492010-09-27 17:26:02 +0000301 Numberz::type ret = testClient.testEnum(Numberz::ONE);
Mark Sleee8540632006-05-30 09:24:40 +0000302 printf(" = %d\n", ret);
303
304 printf("testEnum(TWO)");
Bryan Duxbury833ae492010-09-27 17:26:02 +0000305 ret = testClient.testEnum(Numberz::TWO);
Mark Sleee8540632006-05-30 09:24:40 +0000306 printf(" = %d\n", ret);
307
308 printf("testEnum(THREE)");
Bryan Duxbury833ae492010-09-27 17:26:02 +0000309 ret = testClient.testEnum(Numberz::THREE);
Mark Sleee8540632006-05-30 09:24:40 +0000310 printf(" = %d\n", ret);
311
312 printf("testEnum(FIVE)");
Bryan Duxbury833ae492010-09-27 17:26:02 +0000313 ret = testClient.testEnum(Numberz::FIVE);
Mark Sleee8540632006-05-30 09:24:40 +0000314 printf(" = %d\n", ret);
315
316 printf("testEnum(EIGHT)");
Bryan Duxbury833ae492010-09-27 17:26:02 +0000317 ret = testClient.testEnum(Numberz::EIGHT);
Mark Sleee8540632006-05-30 09:24:40 +0000318 printf(" = %d\n", ret);
319
320 /**
321 * TYPEDEF TEST
322 */
323 printf("testTypedef(309858235082523)");
Marc Slemkobf4fd192006-08-15 21:29:39 +0000324 UserId uid = testClient.testTypedef(309858235082523LL);
David Reissbc3dddb2007-08-22 23:20:24 +0000325 printf(" = %"PRId64"\n", uid);
Mark Sleee8540632006-05-30 09:24:40 +0000326
327 /**
328 * NESTED MAP TEST
329 */
330 printf("testMapMap(1)");
Mark Slee1921d202007-01-24 19:43:06 +0000331 map<int32_t, map<int32_t, int32_t> > mm;
332 testClient.testMapMap(mm, 1);
Mark Sleee8540632006-05-30 09:24:40 +0000333 printf(" = {");
334 map<int32_t, map<int32_t, int32_t> >::const_iterator mi;
335 for (mi = mm.begin(); mi != mm.end(); ++mi) {
336 printf("%d => {", mi->first);
337 map<int32_t, int32_t>::const_iterator mi2;
338 for (mi2 = mi->second.begin(); mi2 != mi->second.end(); ++mi2) {
339 printf("%d => %d, ", mi2->first, mi2->second);
340 }
341 printf("}, ");
342 }
343 printf("}\n");
344
345 /**
346 * INSANITY TEST
347 */
348 Insanity insane;
Bryan Duxbury833ae492010-09-27 17:26:02 +0000349 insane.userMap.insert(make_pair(Numberz::FIVE, 5000));
Mark Sleee8540632006-05-30 09:24:40 +0000350 Xtruct truck;
351 truck.string_thing = "Truck";
352 truck.byte_thing = 8;
Mark Sleee8540632006-05-30 09:24:40 +0000353 truck.i32_thing = 8;
Mark Sleee8540632006-05-30 09:24:40 +0000354 truck.i64_thing = 8;
355 insane.xtructs.push_back(truck);
356 printf("testInsanity()");
Bryan Duxbury833ae492010-09-27 17:26:02 +0000357 map<UserId, map<Numberz::type,Insanity> > whoa;
Mark Slee1921d202007-01-24 19:43:06 +0000358 testClient.testInsanity(whoa, insane);
Mark Sleee8540632006-05-30 09:24:40 +0000359 printf(" = {");
Bryan Duxbury833ae492010-09-27 17:26:02 +0000360 map<UserId, map<Numberz::type,Insanity> >::const_iterator i_iter;
Mark Sleee8540632006-05-30 09:24:40 +0000361 for (i_iter = whoa.begin(); i_iter != whoa.end(); ++i_iter) {
David Reissbc3dddb2007-08-22 23:20:24 +0000362 printf("%"PRId64" => {", i_iter->first);
Bryan Duxbury833ae492010-09-27 17:26:02 +0000363 map<Numberz::type,Insanity>::const_iterator i2_iter;
Mark Sleee8540632006-05-30 09:24:40 +0000364 for (i2_iter = i_iter->second.begin();
365 i2_iter != i_iter->second.end();
366 ++i2_iter) {
367 printf("%d => {", i2_iter->first);
Bryan Duxbury833ae492010-09-27 17:26:02 +0000368 map<Numberz::type, UserId> userMap = i2_iter->second.userMap;
369 map<Numberz::type, UserId>::const_iterator um;
Mark Sleee8540632006-05-30 09:24:40 +0000370 printf("{");
371 for (um = userMap.begin(); um != userMap.end(); ++um) {
David Reissbc3dddb2007-08-22 23:20:24 +0000372 printf("%d => %"PRId64", ", um->first, um->second);
Mark Sleee8540632006-05-30 09:24:40 +0000373 }
374 printf("}, ");
375
Mark Sleeb9acf982006-10-10 01:57:32 +0000376 vector<Xtruct> xtructs = i2_iter->second.xtructs;
377 vector<Xtruct>::const_iterator x;
Mark Sleee8540632006-05-30 09:24:40 +0000378 printf("{");
379 for (x = xtructs.begin(); x != xtructs.end(); ++x) {
David Reissbc3dddb2007-08-22 23:20:24 +0000380 printf("{\"%s\", %d, %d, %"PRId64"}, ",
Mark Sleee8540632006-05-30 09:24:40 +0000381 x->string_thing.c_str(),
382 (int)x->byte_thing,
Mark Sleee8540632006-05-30 09:24:40 +0000383 x->i32_thing,
Mark Sleee8540632006-05-30 09:24:40 +0000384 x->i64_thing);
385 }
386 printf("}");
387
388 printf("}, ");
389 }
390 printf("}, ");
391 }
392 printf("}\n");
393
Marc Slemko71d4e472006-08-15 22:34:04 +0000394 /* test exception */
Mark Slee95771002006-06-07 06:53:25 +0000395
Marc Slemkobf4fd192006-08-15 21:29:39 +0000396 try {
Marc Slemko71d4e472006-08-15 22:34:04 +0000397 printf("testClient.testException(\"Xception\") =>");
398 testClient.testException("Xception");
399 printf(" void\nFAILURE\n");
David Reiss0c90f6f2008-02-06 22:18:40 +0000400
Mark Sleeb9ff32a2006-11-16 01:00:24 +0000401 } catch(Xception& e) {
Marc Slemko71d4e472006-08-15 22:34:04 +0000402 printf(" {%u, \"%s\"}\n", e.errorCode, e.message.c_str());
Marc Slemkobf4fd192006-08-15 21:29:39 +0000403 }
David Reiss0c90f6f2008-02-06 22:18:40 +0000404
Marc Slemkobf4fd192006-08-15 21:29:39 +0000405 try {
Marc Slemko71d4e472006-08-15 22:34:04 +0000406 printf("testClient.testException(\"success\") =>");
407 testClient.testException("success");
408 printf(" void\n");
409 } catch(...) {
410 printf(" exception\nFAILURE\n");
411 }
David Reiss0c90f6f2008-02-06 22:18:40 +0000412
Marc Slemko71d4e472006-08-15 22:34:04 +0000413 /* test multi exception */
David Reiss0c90f6f2008-02-06 22:18:40 +0000414
Marc Slemko71d4e472006-08-15 22:34:04 +0000415 try {
416 printf("testClient.testMultiException(\"Xception\", \"test 1\") =>");
Mark Slee1921d202007-01-24 19:43:06 +0000417 Xtruct result;
418 testClient.testMultiException(result, "Xception", "test 1");
Marc Slemko71d4e472006-08-15 22:34:04 +0000419 printf(" result\nFAILURE\n");
Mark Sleed3d733a2006-09-01 22:19:06 +0000420 } catch(Xception& e) {
Marc Slemko71d4e472006-08-15 22:34:04 +0000421 printf(" {%u, \"%s\"}\n", e.errorCode, e.message.c_str());
422 }
423
424 try {
425 printf("testClient.testMultiException(\"Xception2\", \"test 2\") =>");
Mark Slee1921d202007-01-24 19:43:06 +0000426 Xtruct result;
427 testClient.testMultiException(result, "Xception2", "test 2");
Marc Slemko71d4e472006-08-15 22:34:04 +0000428 printf(" result\nFAILURE\n");
David Reiss0c90f6f2008-02-06 22:18:40 +0000429
Mark Sleed3d733a2006-09-01 22:19:06 +0000430 } catch(Xception2& e) {
Marc Slemko71d4e472006-08-15 22:34:04 +0000431 printf(" {%u, {\"%s\"}}\n", e.errorCode, e.struct_thing.string_thing.c_str());
Marc Slemkobf4fd192006-08-15 21:29:39 +0000432 }
David Reiss0c90f6f2008-02-06 22:18:40 +0000433
Marc Slemko71d4e472006-08-15 22:34:04 +0000434 try {
435 printf("testClient.testMultiException(\"success\", \"test 3\") =>");
Mark Slee1921d202007-01-24 19:43:06 +0000436 Xtruct result;
437 testClient.testMultiException(result, "success", "test 3");
Marc Slemko71d4e472006-08-15 22:34:04 +0000438 printf(" {{\"%s\"}}\n", result.string_thing.c_str());
439 } catch(...) {
440 printf(" exception\nFAILURE\n");
441 }
David Reiss0c90f6f2008-02-06 22:18:40 +0000442
David Reissc51986f2009-03-24 20:01:25 +0000443 /* test oneway void */
David Reiss2ab6fe82008-02-18 02:11:44 +0000444 {
David Reiss6ce401d2009-03-24 20:01:58 +0000445 printf("testClient.testOneway(3) =>");
446 uint64_t startOneway = now();
447 testClient.testOneway(3);
448 uint64_t elapsed = now() - startOneway;
David Reiss2ab6fe82008-02-18 02:11:44 +0000449 if (elapsed > 200 * 1000) { // 0.2 seconds
450 printf(" FAILURE - took %.2f ms\n", (double)elapsed/1000.0);
451 } else {
452 printf(" success - took %.2f ms\n", (double)elapsed/1000.0);
453 }
454 }
455
David Reiss2845b522008-02-18 02:11:52 +0000456 /**
David Reissc51986f2009-03-24 20:01:25 +0000457 * redo a simple test after the oneway to make sure we aren't "off by one" --
458 * if the server treated oneway void like normal void, this next test will
David Reiss2845b522008-02-18 02:11:52 +0000459 * fail since it will get the void confirmation rather than the correct
460 * result. In this circumstance, the client will throw the exception:
461 *
462 * TApplicationException: Wrong method namea
463 */
464 /**
465 * I32 TEST
466 */
467 printf("re-test testI32(-1)");
468 i32 = testClient.testI32(-1);
469 printf(" = %d\n", i32);
470
471
Marc Slemkobf4fd192006-08-15 21:29:39 +0000472 uint64_t stop = now();
Mark Sleed788b2e2006-09-07 01:26:35 +0000473 uint64_t tot = stop-start;
474
David Reissbc3dddb2007-08-22 23:20:24 +0000475 printf("Total time: %"PRIu64" us\n", stop-start);
David Reiss0c90f6f2008-02-06 22:18:40 +0000476
Mark Sleed788b2e2006-09-07 01:26:35 +0000477 time_tot += tot;
478 if (time_min == 0 || tot < time_min) {
479 time_min = tot;
480 }
481 if (tot > time_max) {
482 time_max = tot;
483 }
484
Mark Sleea3302652006-10-25 19:03:32 +0000485 transport->close();
Mark Sleee8540632006-05-30 09:24:40 +0000486 }
487
Marc Slemko6be374b2006-08-04 03:16:25 +0000488 // printf("\nSocket syscalls: %u", g_socket_syscalls);
Mark Sleee8540632006-05-30 09:24:40 +0000489 printf("\nAll tests done.\n");
Mark Sleed788b2e2006-09-07 01:26:35 +0000490
491 uint64_t time_avg = time_tot / numTests;
492
David Reissbc3dddb2007-08-22 23:20:24 +0000493 printf("Min time: %"PRIu64" us\n", time_min);
494 printf("Max time: %"PRIu64" us\n", time_max);
495 printf("Avg time: %"PRIu64" us\n", time_avg);
Mark Sleed788b2e2006-09-07 01:26:35 +0000496
Mark Sleee8540632006-05-30 09:24:40 +0000497 return 0;
498}