blob: 6d49f1da1d8fb12ad9cfda9a1c914ed708a44155 [file] [log] [blame]
T Jake Luciani41687fc2008-12-23 03:45:43 +00001#!/usr/bin/env perl
Mark Slee3e3d7ad2007-05-16 02:35:58 +00002
David Reissea2cba82009-03-30 21:35:00 +00003#
4# Licensed to the Apache Software Foundation (ASF) under one
5# or more contributor license agreements. See the NOTICE file
6# distributed with this work for additional information
7# regarding copyright ownership. The ASF licenses this file
8# to you under the Apache License, Version 2.0 (the
9# "License"); you may not use this file except in compliance
10# with the License. You may obtain a copy of the License at
11#
12# http://www.apache.org/licenses/LICENSE-2.0
13#
14# Unless required by applicable law or agreed to in writing,
15# software distributed under the License is distributed on an
16# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17# KIND, either express or implied. See the License for the
18# specific language governing permissions and limitations
19# under the License.
20#
21
James E. King, III177c37c2017-03-30 17:09:04 -040022use 5.10.0;
Mark Slee3e3d7ad2007-05-16 02:35:58 +000023use strict;
24use warnings;
25use Data::Dumper;
Jim Kingf5f1b352015-06-24 13:47:24 -040026use Getopt::Long qw(GetOptions);
Mark Slee3e3d7ad2007-05-16 02:35:58 +000027use Time::HiRes qw(gettimeofday);
28
29use lib '../../lib/perl/lib';
T Jake Luciani41687fc2008-12-23 03:45:43 +000030use lib 'gen-perl';
Mark Slee3e3d7ad2007-05-16 02:35:58 +000031
32use Thrift;
33use Thrift::BinaryProtocol;
Mark Slee3e3d7ad2007-05-16 02:35:58 +000034use Thrift::BufferedTransport;
Jim Kingf5f1b352015-06-24 13:47:24 -040035use Thrift::FramedTransport;
James E. King, III20e16bc2017-11-18 22:37:54 -050036use Thrift::MultiplexedProtocol;
Jim Kingf5f1b352015-06-24 13:47:24 -040037use Thrift::SSLSocket;
38use Thrift::Socket;
James E. King, III49f4dc02015-10-29 15:52:23 -040039use Thrift::UnixSocket;
Mark Slee3e3d7ad2007-05-16 02:35:58 +000040
James E. King, III20e16bc2017-11-18 22:37:54 -050041use ThriftTest::SecondService;
T Jake Luciani41687fc2008-12-23 03:45:43 +000042use ThriftTest::ThriftTest;
Mark Slee27ed6ec2007-08-16 01:26:31 +000043use ThriftTest::Types;
Mark Slee3e3d7ad2007-05-16 02:35:58 +000044
45$|++;
46
Jim Kingf5f1b352015-06-24 13:47:24 -040047sub usage {
Dean Hamstead8a130f62018-10-17 18:48:42 +110048 print <<"EOF";
Jim Kingf5f1b352015-06-24 13:47:24 -040049Usage: $0 [OPTIONS]
Mark Slee3e3d7ad2007-05-16 02:35:58 +000050
Jim Kingf5f1b352015-06-24 13:47:24 -040051Options: (default)
James E. King, III377719c2017-02-15 14:33:20 -050052 --ca CA to validate server with.
Jim Kingf5f1b352015-06-24 13:47:24 -040053 --cert Certificate to use.
54 Required if using --ssl.
James E. King, III377719c2017-02-15 14:33:20 -050055 --ciphers Acceptable cipher list.
James E. King, III49f4dc02015-10-29 15:52:23 -040056 --domain-socket <file> Use a unix domain socket.
Jim Kingf5f1b352015-06-24 13:47:24 -040057 --help Show usage.
James E. King, III377719c2017-02-15 14:33:20 -050058 --key Certificate key.
59 Required if using --ssl.
Jim Kingf5f1b352015-06-24 13:47:24 -040060 --port <portnum> 9090 Port to use.
61 --protocol {binary} binary Protocol to use.
62 --ssl If present, use SSL.
63 --transport {buffered|framed} buffered Transport to use.
James E. King, III377719c2017-02-15 14:33:20 -050064
Jim Kingf5f1b352015-06-24 13:47:24 -040065EOF
Roger Meier41ad4342015-03-24 22:30:40 +010066}
Mark Slee3e3d7ad2007-05-16 02:35:58 +000067
Jim Kingf5f1b352015-06-24 13:47:24 -040068my %opts = (
69 'port' => 9090,
70 'protocol' => 'binary',
71 'transport' => 'buffered'
72);
Mark Slee3e3d7ad2007-05-16 02:35:58 +000073
Jim Kingf5f1b352015-06-24 13:47:24 -040074GetOptions(\%opts, qw (
James E. King, III377719c2017-02-15 14:33:20 -050075 ca=s
Jim Kingf5f1b352015-06-24 13:47:24 -040076 cert=s
James E. King, III377719c2017-02-15 14:33:20 -050077 ciphers=s
78 key=s
James E. King, III49f4dc02015-10-29 15:52:23 -040079 domain-socket=s
Jim Kingf5f1b352015-06-24 13:47:24 -040080 help
81 host=s
82 port=i
83 protocol=s
84 ssl
85 transport=s
86)) || exit 1;
87
88if ($opts{help}) {
89 usage();
90 exit 0;
91}
92
Jim Kingf5f1b352015-06-24 13:47:24 -040093my $socket = undef;
Dean Hamstead8a130f62018-10-17 18:48:42 +110094if ($opts{'domain-socket'}) {
95 $socket = Thrift::UnixSocket->new($opts{'domain-socket'});
96}
97elsif ($opts{ssl}) {
98 $socket = Thrift::SSLSocket->new(\%opts);
99}
100else {
101 $socket = Thrift::Socket->new($opts{host}, $opts{port});
Jim Kingf5f1b352015-06-24 13:47:24 -0400102}
103
104my $transport;
105if ($opts{transport} eq 'buffered') {
Dean Hamstead8a130f62018-10-17 18:48:42 +1100106 $transport = Thrift::BufferedTransport->new($socket, 1024, 1024);
107}
108elsif ($opts{transport} eq 'framed') {
109 $transport = Thrift::FramedTransport->new($socket);
110}
111else {
Jim Kingf5f1b352015-06-24 13:47:24 -0400112 usage();
113 exit 1;
114}
115
116my $protocol;
James E. King, III20e16bc2017-11-18 22:37:54 -0500117my $protocol2;
118if ($opts{protocol} eq 'binary' || $opts{protocol} eq 'multi') {
Dean Hamstead8a130f62018-10-17 18:48:42 +1100119 $protocol = Thrift::BinaryProtocol->new($transport);
120}
121else {
Jim Kingf5f1b352015-06-24 13:47:24 -0400122 usage();
123 exit 1;
124}
125
James E. King, III20e16bc2017-11-18 22:37:54 -0500126my $secondService = undef;
127if (index($opts{protocol}, 'multi') == 0) {
Dean Hamstead8a130f62018-10-17 18:48:42 +1100128 $protocol2 = Thrift::MultiplexedProtocol->new($protocol, 'SecondService');
129 $protocol = Thrift::MultiplexedProtocol->new($protocol, 'ThriftTest');
130 $secondService = ThriftTest::SecondServiceClient->new($protocol2);
James E. King, III20e16bc2017-11-18 22:37:54 -0500131}
132
Dean Hamstead8a130f62018-10-17 18:48:42 +1100133my $testClient = ThriftTest::ThriftTestClient->new($protocol);
Mark Slee3e3d7ad2007-05-16 02:35:58 +0000134
Jim Kingf5f1b352015-06-24 13:47:24 -0400135eval {
136 $transport->open();
James E. King, III377719c2017-02-15 14:33:20 -0500137};
Jim Kingf5f1b352015-06-24 13:47:24 -0400138if($@){
Mark Slee3e3d7ad2007-05-16 02:35:58 +0000139 die(Dumper($@));
140}
James E. King, III20e16bc2017-11-18 22:37:54 -0500141
142use constant ERR_BASETYPES => 1;
143use constant ERR_STRUCTS => 2;
144use constant ERR_CONTAINERS => 4;
145use constant ERR_EXCEPTIONS => 8;
146use constant ERR_PROTOCOL => 16;
147use constant ERR_UNKNOWN => 64;
148
Mark Slee3e3d7ad2007-05-16 02:35:58 +0000149my $start = gettimeofday();
150
151#
152# VOID TEST
153#
Dean Hamstead8a130f62018-10-17 18:48:42 +1100154print('testVoid()');
Mark Slee3e3d7ad2007-05-16 02:35:58 +0000155$testClient->testVoid();
156print(" = void\n");
157
158#
159# STRING TEST
160#
Dean Hamstead8a130f62018-10-17 18:48:42 +1100161print('testString("Test")');
162my $s = $testClient->testString('Test');
163print(qq| = "$s"\n|);
James E. King, III20e16bc2017-11-18 22:37:54 -0500164exit(ERR_BASETYPES) if ($s ne 'Test');
165
166#
167# MULTIPLEXED TEST
168#
169if (index($opts{protocol}, 'multi') == 0) {
Dean Hamstead8a130f62018-10-17 18:48:42 +1100170 print('secondtestString("Test2")');
171 $s = $secondService->secondtestString('Test2');
172 print(qq| = "$s"\n|);
James E. King, III20e16bc2017-11-18 22:37:54 -0500173 exit(ERR_PROTOCOL) if ($s ne 'testString("Test2")');
174}
Mark Slee3e3d7ad2007-05-16 02:35:58 +0000175
176#
Nobuaki Sukegawaa649e742015-09-21 13:53:25 +0900177# BOOL TEST
178#
Dean Hamstead8a130f62018-10-17 18:48:42 +1100179print('testBool(1)');
Jens Geyerd629ea02015-09-23 21:16:50 +0200180my $t = $testClient->testBool(1);
181print(" = $t\n");
James E. King, III20e16bc2017-11-18 22:37:54 -0500182exit(ERR_BASETYPES) if ($t ne 1);
Dean Hamstead8a130f62018-10-17 18:48:42 +1100183print('testBool(0)');
Jens Geyerd629ea02015-09-23 21:16:50 +0200184my $f = $testClient->testBool(0);
185print(" = $f\n");
Dean Hamstead8a130f62018-10-17 18:48:42 +1100186exit(ERR_BASETYPES) if ($f ne q||);
Nobuaki Sukegawaa649e742015-09-21 13:53:25 +0900187
188
189#
Mark Slee3e3d7ad2007-05-16 02:35:58 +0000190# BYTE TEST
191#
Dean Hamstead8a130f62018-10-17 18:48:42 +1100192print('testByte(1)');
Mark Slee3e3d7ad2007-05-16 02:35:58 +0000193my $u8 = $testClient->testByte(1);
194print(" = $u8\n");
195
196#
197# I32 TEST
198#
Dean Hamstead8a130f62018-10-17 18:48:42 +1100199print('testI32(-1)');
Mark Slee3e3d7ad2007-05-16 02:35:58 +0000200my $i32 = $testClient->testI32(-1);
201print(" = $i32\n");
James E. King, III20e16bc2017-11-18 22:37:54 -0500202exit(ERR_BASETYPES) if ($i32 ne -1);
Mark Slee3e3d7ad2007-05-16 02:35:58 +0000203
204#
James E. King, III20e16bc2017-11-18 22:37:54 -0500205# I64 TEST
Mark Slee3e3d7ad2007-05-16 02:35:58 +0000206#
Dean Hamstead8a130f62018-10-17 18:48:42 +1100207print('testI64(-34359738368)');
Mark Slee3e3d7ad2007-05-16 02:35:58 +0000208my $i64 = $testClient->testI64(-34359738368);
209print(" = $i64\n");
James E. King, III20e16bc2017-11-18 22:37:54 -0500210exit(ERR_BASETYPES) if ($i64 ne -34359738368);
Mark Slee3e3d7ad2007-05-16 02:35:58 +0000211
212#
213# DOUBLE TEST
214#
Dean Hamstead8a130f62018-10-17 18:48:42 +1100215print('testDouble(-852.234234234)');
Mark Slee3e3d7ad2007-05-16 02:35:58 +0000216my $dub = $testClient->testDouble(-852.234234234);
217print(" = $dub\n");
James E. King, III20e16bc2017-11-18 22:37:54 -0500218exit(ERR_BASETYPES) if ($dub ne -852.234234234);
Mark Slee3e3d7ad2007-05-16 02:35:58 +0000219
220#
Kengo Sekid858a8d2020-01-13 23:11:10 +0900221# BINARY TEST
Jens Geyer8bcfdd92014-12-14 03:14:26 +0100222#
Kengo Sekid858a8d2020-01-13 23:11:10 +0900223print("testBinary(pack('C*', 0..255))");
224my $bin = $testClient->testBinary(pack('C*', 0..255));
225printf(" = %s\n", join ' ', map { sprintf '%02x', $_ } unpack('C*', $bin));
226exit(ERR_BASETYPES) if ($bin ne pack('C*', 0..255));
Jens Geyer8bcfdd92014-12-14 03:14:26 +0100227
228#
Mark Slee3e3d7ad2007-05-16 02:35:58 +0000229# STRUCT TEST
230#
Dean Hamstead8a130f62018-10-17 18:48:42 +1100231print('testStruct({"Zero", 1, -3, -5})');
232my $out = ThriftTest::Xtruct->new();
233$out->string_thing('Zero');
Mark Slee82664432007-09-19 06:49:30 +0000234$out->byte_thing(1);
235$out->i32_thing(-3);
236$out->i64_thing(-5);
Mark Slee3e3d7ad2007-05-16 02:35:58 +0000237my $in = $testClient->testStruct($out);
Dean Hamstead8a130f62018-10-17 18:48:42 +1100238print(' = {"'.$in->string_thing.'", '.
239 $in->byte_thing.', '.
240 $in->i32_thing.', '.
Mark Slee82664432007-09-19 06:49:30 +0000241 $in->i64_thing."}\n");
Mark Slee3e3d7ad2007-05-16 02:35:58 +0000242
243#
244# NESTED STRUCT TEST
245#
Dean Hamstead8a130f62018-10-17 18:48:42 +1100246print('testNest({1, {"Zero", 1, -3, -5}, 5}');
247my $out2 = ThriftTest::Xtruct2->new();
Mark Slee82664432007-09-19 06:49:30 +0000248$out2->byte_thing(1);
249$out2->struct_thing($out);
250$out2->i32_thing(5);
Mark Slee3e3d7ad2007-05-16 02:35:58 +0000251my $in2 = $testClient->testNest($out2);
Mark Slee82664432007-09-19 06:49:30 +0000252$in = $in2->struct_thing;
Dean Hamstead8a130f62018-10-17 18:48:42 +1100253print(' = {'.$in2->byte_thing.', {"'.
254 $in->string_thing.'", '.
255 $in->byte_thing.', '.
256 $in->i32_thing.', '.
257 $in->i64_thing.'}, '.
Mark Slee82664432007-09-19 06:49:30 +0000258 $in2->i32_thing."}\n");
Mark Slee3e3d7ad2007-05-16 02:35:58 +0000259
260#
261# MAP TEST
262#
263my $mapout = {};
264for (my $i = 0; $i < 5; ++$i) {
265 $mapout->{$i} = $i-10;
266}
Dean Hamstead8a130f62018-10-17 18:48:42 +1100267print('testMap({');
Mark Slee3e3d7ad2007-05-16 02:35:58 +0000268my $first = 1;
269while( my($key,$val) = each %$mapout) {
270 if ($first) {
271 $first = 0;
Dean Hamstead8a130f62018-10-17 18:48:42 +1100272 }
273 else {
274 print(', ');
Mark Slee3e3d7ad2007-05-16 02:35:58 +0000275 }
276 print("$key => $val");
277}
Dean Hamstead8a130f62018-10-17 18:48:42 +1100278print('})');
Mark Slee3e3d7ad2007-05-16 02:35:58 +0000279
280
281my $mapin = $testClient->testMap($mapout);
Dean Hamstead8a130f62018-10-17 18:48:42 +1100282print(' = {');
Mark Slee3e3d7ad2007-05-16 02:35:58 +0000283
284$first = 1;
285while( my($key,$val) = each %$mapin){
286 if ($first) {
287 $first = 0;
Dean Hamstead8a130f62018-10-17 18:48:42 +1100288 }
289 else {
290 print(', ');
Mark Slee3e3d7ad2007-05-16 02:35:58 +0000291 }
292 print("$key => $val");
293}
294print("}\n");
295
296#
297# SET TEST
298#
299my $setout = [];
300for (my $i = -2; $i < 3; ++$i) {
301 push(@$setout, $i);
302}
303
Dean Hamstead8a130f62018-10-17 18:48:42 +1100304print('testSet({'.join(',',@$setout).'})');
Mark Slee3e3d7ad2007-05-16 02:35:58 +0000305
306my $setin = $testClient->testSet($setout);
307
Dean Hamstead8a130f62018-10-17 18:48:42 +1100308print(' = {'.join(',',@$setout)."}\n");
Mark Slee3e3d7ad2007-05-16 02:35:58 +0000309
310#
311# LIST TEST
312#
313my $listout = [];
314for (my $i = -2; $i < 3; ++$i) {
315 push(@$listout, $i);
316}
317
Dean Hamstead8a130f62018-10-17 18:48:42 +1100318print('testList({'.join(',',@$listout).'})');
Mark Slee3e3d7ad2007-05-16 02:35:58 +0000319
320my $listin = $testClient->testList($listout);
321
Dean Hamstead8a130f62018-10-17 18:48:42 +1100322print(' = {'.join(',',@$listin)."}\n");
Mark Slee3e3d7ad2007-05-16 02:35:58 +0000323
324#
325# ENUM TEST
326#
Dean Hamstead8a130f62018-10-17 18:48:42 +1100327print('testEnum(ONE)');
T Jake Luciani41687fc2008-12-23 03:45:43 +0000328my $ret = $testClient->testEnum(ThriftTest::Numberz::ONE);
Mark Slee3e3d7ad2007-05-16 02:35:58 +0000329print(" = $ret\n");
330
Dean Hamstead8a130f62018-10-17 18:48:42 +1100331print('testEnum(TWO)');
T Jake Luciani41687fc2008-12-23 03:45:43 +0000332$ret = $testClient->testEnum(ThriftTest::Numberz::TWO);
Mark Slee3e3d7ad2007-05-16 02:35:58 +0000333print(" = $ret\n");
334
Dean Hamstead8a130f62018-10-17 18:48:42 +1100335print('testEnum(THREE)');
T Jake Luciani41687fc2008-12-23 03:45:43 +0000336$ret = $testClient->testEnum(ThriftTest::Numberz::THREE);
Mark Slee3e3d7ad2007-05-16 02:35:58 +0000337print(" = $ret\n");
338
Dean Hamstead8a130f62018-10-17 18:48:42 +1100339print('testEnum(FIVE)');
T Jake Luciani41687fc2008-12-23 03:45:43 +0000340$ret = $testClient->testEnum(ThriftTest::Numberz::FIVE);
Mark Slee3e3d7ad2007-05-16 02:35:58 +0000341print(" = $ret\n");
342
Dean Hamstead8a130f62018-10-17 18:48:42 +1100343print('testEnum(EIGHT)');
T Jake Luciani41687fc2008-12-23 03:45:43 +0000344$ret = $testClient->testEnum(ThriftTest::Numberz::EIGHT);
Mark Slee3e3d7ad2007-05-16 02:35:58 +0000345print(" = $ret\n");
346
347#
348# TYPEDEF TEST
349#
Dean Hamstead8a130f62018-10-17 18:48:42 +1100350print('testTypedef(309858235082523)');
Mark Slee3e3d7ad2007-05-16 02:35:58 +0000351my $uid = $testClient->testTypedef(309858235082523);
352print(" = $uid\n");
353
354#
355# NESTED MAP TEST
356#
Dean Hamstead8a130f62018-10-17 18:48:42 +1100357print('testMapMap(1)');
Mark Slee3e3d7ad2007-05-16 02:35:58 +0000358my $mm = $testClient->testMapMap(1);
Dean Hamstead8a130f62018-10-17 18:48:42 +1100359print(' = {');
Mark Slee3e3d7ad2007-05-16 02:35:58 +0000360while( my ($key,$val) = each %$mm) {
361 print("$key => {");
362 while( my($k2,$v2) = each %$val) {
363 print("$k2 => $v2, ");
364 }
Dean Hamstead8a130f62018-10-17 18:48:42 +1100365 print('}, ');
Mark Slee3e3d7ad2007-05-16 02:35:58 +0000366}
367print("}\n");
368
369#
370# INSANITY TEST
371#
Dean Hamstead8a130f62018-10-17 18:48:42 +1100372my $insane = ThriftTest::Insanity->new();
T Jake Luciani41687fc2008-12-23 03:45:43 +0000373$insane->{userMap}->{ThriftTest::Numberz::FIVE} = 5000;
Dean Hamstead8a130f62018-10-17 18:48:42 +1100374my $truck = ThriftTest::Xtruct->new();
375$truck->string_thing('Hello2');
Jens Geyerd629ea02015-09-23 21:16:50 +0200376$truck->byte_thing(2);
377$truck->i32_thing(2);
378$truck->i64_thing(2);
Dean Hamstead8a130f62018-10-17 18:48:42 +1100379my $truck2 = ThriftTest::Xtruct->new();
380$truck2->string_thing('Goodbye4');
Jens Geyerd629ea02015-09-23 21:16:50 +0200381$truck2->byte_thing(4);
382$truck2->i32_thing(4);
383$truck2->i64_thing(4);
Mark Slee3e3d7ad2007-05-16 02:35:58 +0000384push(@{$insane->{xtructs}}, $truck);
Jens Geyerd629ea02015-09-23 21:16:50 +0200385push(@{$insane->{xtructs}}, $truck2);
Mark Slee3e3d7ad2007-05-16 02:35:58 +0000386
Dean Hamstead8a130f62018-10-17 18:48:42 +1100387print('testInsanity()');
Mark Slee3e3d7ad2007-05-16 02:35:58 +0000388my $whoa = $testClient->testInsanity($insane);
Dean Hamstead8a130f62018-10-17 18:48:42 +1100389print(' = {');
Mark Slee3e3d7ad2007-05-16 02:35:58 +0000390while( my ($key,$val) = each %$whoa) {
391 print("$key => {");
392 while( my($k2,$v2) = each %$val) {
393 print("$k2 => {");
394 my $userMap = $v2->{userMap};
Dean Hamstead8a130f62018-10-17 18:48:42 +1100395 print('{');
396 if (ref($userMap) eq 'HASH') {
Mark Slee3e3d7ad2007-05-16 02:35:58 +0000397 while( my($k3,$v3) = each %$userMap) {
398 print("$k3 => $v3, ");
399 }
400 }
Dean Hamstead8a130f62018-10-17 18:48:42 +1100401 print('}, ');
Mark Slee3e3d7ad2007-05-16 02:35:58 +0000402
403 my $xtructs = $v2->{xtructs};
Dean Hamstead8a130f62018-10-17 18:48:42 +1100404 print('{');
405 if (ref($xtructs) eq 'ARRAY') {
Mark Slee3e3d7ad2007-05-16 02:35:58 +0000406 foreach my $x (@$xtructs) {
Dean Hamstead8a130f62018-10-17 18:48:42 +1100407 print('{"'.$x->{string_thing}.'", '.
408 $x->{byte_thing}.', '.$x->{i32_thing}.', '.$x->{i64_thing}.'}, ');
Mark Slee3e3d7ad2007-05-16 02:35:58 +0000409 }
410 }
Dean Hamstead8a130f62018-10-17 18:48:42 +1100411 print('}');
Mark Slee3e3d7ad2007-05-16 02:35:58 +0000412
Dean Hamstead8a130f62018-10-17 18:48:42 +1100413 print('}, ');
Mark Slee3e3d7ad2007-05-16 02:35:58 +0000414 }
Dean Hamstead8a130f62018-10-17 18:48:42 +1100415 print('}, ');
Mark Slee3e3d7ad2007-05-16 02:35:58 +0000416}
417print("}\n");
418
419#
420# EXCEPTION TEST
421#
Dean Hamstead8a130f62018-10-17 18:48:42 +1100422print(q|testException('Xception')|);
Mark Slee3e3d7ad2007-05-16 02:35:58 +0000423eval {
424 $testClient->testException('Xception');
425 print(" void\nFAILURE\n");
Mark Slee82664432007-09-19 06:49:30 +0000426}; if($@ && $@->UNIVERSAL::isa('ThriftTest::Xception')) {
Mark Slee3e3d7ad2007-05-16 02:35:58 +0000427 print(' caught xception '.$@->{errorCode}.': '.$@->{message}."\n");
428}
429
430
431#
432# Normal tests done.
433#
434my $stop = gettimeofday();
Dean Hamstead8a130f62018-10-17 18:48:42 +1100435my $elp = sprintf('%d',1000*($stop - $start), 0);
Mark Slee3e3d7ad2007-05-16 02:35:58 +0000436print("Total time: $elp ms\n");
437
438#
439# Extraneous "I don't trust PHP to pack/unpack integer" tests
440#
441
442# Max I32
443my $num = 2**30 + 2**30 - 1;
444my $num2 = $testClient->testI32($num);
445if ($num != $num2) {
446 print "Missed max32 $num = $num2\n";
447}
448
449# Min I32
450$num = 0 - 2**31;
451$num2 = $testClient->testI32($num);
452if ($num != $num2) {
453 print "Missed min32 $num = $num2\n";
454}
455
456# Max Number I can get out of my perl
457$num = 2**40;
458$num2 = $testClient->testI64($num);
459if ($num != $num2) {
460 print "Missed max64 $num = $num2\n";
461}
462
463# Max Number I can get out of my perl
464$num = 0 - 2**40;
465$num2 = $testClient->testI64($num);
466if ($num != $num2) {
467 print "Missed min64 $num = $num2\n";
468}
469
470$transport->close();
471
472
473