aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ic/test/java_client_erl_server_SUITE_data/JavaClient.java
blob: 8092d7c6273a5bf51aea3a8bc35ee8b2f9f68245 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
/*
 * %CopyrightBegin%
 * 
 * Copyright Ericsson AB 2003-2016. All Rights Reserved.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 * %CopyrightEnd%
 *
 */
public class JavaClient {

    public static void main(String[] argv) 
    {
	System.out.println("Hello World!");
	if (argv.length < 4) {
	    System.out.println("Too few arguments!");
	    System.exit(1);
	}
	//      for (int j = 0; j < argv.length; j++)
	//        System.out.println(argv[j]);
	try {
	    if (argv[3].equals("marshal_ll")) {
		System.out.println("marshal_ll");
		marshal_ll(argv[0], argv[1], argv[2], argv[3]);
	    } 
	    else if (argv[3].equals("marshal_ull")) {
		marshal_ull(argv[0], argv[1], argv[2], argv[3]);
	    } 
	    else if (argv[3].equals("marshal_l")) {
		marshal_l(argv[0], argv[1], argv[2], argv[3]);
	    } 
	    else if (argv[3].equals("marshal_ul")) {
		marshal_ul(argv[0], argv[1], argv[2], argv[3]);
	    } 
	    else if (argv[3].equals("marshal_s")) {
		marshal_s(argv[0], argv[1], argv[2], argv[3]);
	    } 
	    else if (argv[3].equals("marshal_us")) {
		marshal_us(argv[0], argv[1], argv[2], argv[3]);
	    } 
	    else if (argv[3].equals("marshal_c")) {
		marshal_c(argv[0], argv[1], argv[2], argv[3]);
	    } 
	    else if (argv[3].equals("marshal_wc")) {
		marshal_wc(argv[0], argv[1], argv[2], argv[3]);
	    } 
	    else if (argv[3].equals("marshal_str")) {
		marshal_str(argv[0], argv[1], argv[2], argv[3]);
	    } 
	    else if (argv[3].equals("marshal_any_3")) {
		marshal_any_3(argv[0], argv[1], argv[2], argv[3]);
	    } 
	    else if (argv[3].equals("marshal_any_2")) {
		marshal_any_2(argv[0], argv[1], argv[2], argv[3]);
	    } 
	    else {
		System.out.println("Unknown test: "+argv[3]);
		System.exit(2);
	    }
	} catch (java.lang.Exception e) {
	    System.out.println("Exception!: "+e);
	    System.exit(3);
	}
	System.exit(0);
    }



    static void marshal_ll(String selfNode, String peerNode,
			   String cookie, String serverName)
	throws java.lang.Exception
    {
	m._iStub i = new m._iStub(selfNode, peerNode, cookie, serverName);
	// Just warming up..
	System.out.println("Just warming up.."+i);
	verify_ll(i, 3, 2, 1);
	verify_ll(i, 5, 4, 3);
	verify_ll(i, -128, 0, 1);
	// The small integer border
	verify_ll(i, 255, 0, 1);
	verify_ll(i, 256, 0, 1);
	// The integer border
	verify_ll(i, (1L<<26)-1L, 0L, 1);
	verify_ll(i, 1L<<26, 0L, 1);
	verify_ll(i, -(1L<<26), 0L, 1);
	verify_ll(i, (1L<<27)-1L, 0L, 1);
	verify_ll(i, 1L<<27, 0L, 1);
	verify_ll(i, -(1L<<27), 0L, 1);
	// Bignum byte borders
	verify_ll(i, (1L<<32)-1L, 0L, 1);
	verify_ll(i, 1L<<32, 0L, 1);
	verify_ll(i, -(1L<<32)+1L, 0L, 1);
	verify_ll(i, -(1L<<32), 0L, 1);
	verify_ll(i, (1L<<40)-1L, 0L, 1);
	verify_ll(i, 1L<<40, 0L, 1);
	verify_ll(i, -(1L<<40)+1L, 0L, 1);
	verify_ll(i, -(1L<<40), 0L, 1);
	verify_ll(i, (1L<<48)-1L, 0L, 1);
	verify_ll(i, 1L<<48, 0L, 1);
	verify_ll(i, -(1L<<48)+1L, 0L, 1);
	verify_ll(i, -(1L<<48), 0L, 1);
	// Java long border
	verify_ll(i, java.lang.Long.MAX_VALUE, 0L, 1);
	verify_ll(i, java.lang.Long.MIN_VALUE, 0L, 1);
	verify_ll(i, -1L, 0L, 1);
	// Impossible decodes
	verify_ll_bad(i, java.lang.Long.MAX_VALUE, -1L, 1);
	verify_ll_bad(i, java.lang.Long.MIN_VALUE, 1L, 1);
	verify_ll_bad(i, java.lang.Long.MIN_VALUE, 0L, -1);
	verify_ll_bad(i, java.lang.Long.MAX_VALUE, -1L, 2);
	verify_ll_bad(i, java.lang.Long.MIN_VALUE, 0L, 2);
    }

    static void marshal_ull(String selfNode, String peerNode,
			    String cookie, String serverName)
	throws java.lang.Exception
    {
	m._iStub i = new m._iStub(selfNode, peerNode, cookie, serverName);
	// Just warming up..
	verify_ull(i, 3, 2, 1);
	verify_ull(i, 5, 4, 3);
	// The small integer border
	verify_ull(i, 255, 0, 1);
	verify_ull(i, 256, 0, 1);
	// The integer border
	verify_ull(i, (1L<<26)-1L, 0L, 1);
	verify_ull(i, 1L<<26, 0L, 1);
	verify_ull(i, (1L<<27)-1L, 0L, 1);
	verify_ull(i, 1L<<27, 0L, 1);
	// Bignum byte borders
	verify_ull(i, (1L<<32)-1L, 0L, 1);
	verify_ull(i, 1L<<32, 0L, 1);
	verify_ull(i, (1L<<40)-1L, 0L, 1);
	verify_ull(i, 1L<<40, 0L, 1);
	verify_ull(i, (1L<<48)-1L, 0L, 1);
	verify_ull(i, 1L<<48, 0L, 1);
	// Java long border
	verify_ull(i, java.lang.Long.MAX_VALUE, 0L, 1);
	verify_ull(i, java.lang.Long.MIN_VALUE, 0L, 1);
	verify_ull(i, -1L, 0L, 1);
	verify_ull(i, java.lang.Long.MAX_VALUE, 
		   java.lang.Long.MIN_VALUE, 1);
	// Impossible decodes
	verify_ull_bad(i, -1L, -1L, 1);
	verify_ull_bad(i, java.lang.Long.MAX_VALUE, -1L, 2);
    }

    static void marshal_l(String selfNode, String peerNode,
			  String cookie, String serverName)
	throws java.lang.Exception
    {
	m._iStub i = new m._iStub(selfNode, peerNode, cookie, serverName);
	// Just warming up..
	verify_l(i, 3, 2, 1);
	verify_l(i, 5, 4, 3);
	verify_l(i, -128, 0, 1);
	// The small integer border
	verify_l(i, 255, 0, 1);
	verify_l(i, 256, 0, 1);
	// The integer border
	verify_l(i, (1<<26)-1, 0, 1);
	verify_l(i, 1<<26, 0, 1);
	verify_l(i, -(1<<26), 0, 1);
	verify_l(i, (1<<27)-1, 0, 1);
	verify_l(i, 1<<27, 0, 1);
	verify_l(i, -(1<<27), 0, 1);
	// Java int border
	verify_l(i, java.lang.Integer.MAX_VALUE, 0, 1);
	verify_l(i, java.lang.Integer.MIN_VALUE, 0, 1);
	// Impossible decodes
	verify_l_bad(i, java.lang.Integer.MAX_VALUE, -1, 1);
	verify_l_bad(i, java.lang.Integer.MIN_VALUE, 1, 1);
	verify_l_bad(i, java.lang.Integer.MIN_VALUE, 0, -1);
    }

    static void marshal_ul(String selfNode, String peerNode,
			   String cookie, String serverName)
	throws java.lang.Exception
    {
	m._iStub i = new m._iStub(selfNode, peerNode, cookie, serverName);
	// Just warming up..
	verify_ul(i, 3, 2, 1);
	verify_ul(i, 5, 4, 3);
	// The small integer border
	verify_ul(i, 255, 0, 1);
	verify_ul(i, 256, 0, 1);
	// The integer border
	verify_ul(i, (1<<26)-1, 0, 1);
	verify_ul(i, 1<<26, 0, 1);
	verify_ul(i, (1<<27)-1, 0, 1);
	verify_ul(i, 1<<27, 0, 1);
	// Java int border
	verify_ul(i, java.lang.Integer.MAX_VALUE, 0, 1);
	verify_ul(i, java.lang.Integer.MIN_VALUE, 0, 1);
	verify_ul(i, -1, 0, 1);
	verify_ul(i, java.lang.Integer.MAX_VALUE, 
		  java.lang.Integer.MIN_VALUE, 1);
	// Impossible decodes
	verify_ul_bad(i, -1, -1, 1);
    }

    static void marshal_s(String selfNode, String peerNode,
			  String cookie, String serverName)
	throws java.lang.Exception
    {
	m._iStub i = new m._iStub(selfNode, peerNode, cookie, serverName);
	// Just warming up..
	verify_s(i, 3, 2, 1);
	verify_s(i, 5, 4, 3);
	verify_s(i, -128, 0, 1);
	// The small integer border
	verify_s(i, 255, 0, 1);
	verify_s(i, 256, 0, 1);
	// Java short border
	verify_s(i, java.lang.Short.MAX_VALUE, 0, 1);
	verify_s(i, java.lang.Short.MIN_VALUE, 0, 1);
	// Impossible decodes
	verify_s_bad(i, java.lang.Short.MAX_VALUE, -1, 1);
	verify_s_bad(i, java.lang.Short.MIN_VALUE, 1, 1);
	verify_s_bad(i, java.lang.Short.MIN_VALUE, 0, -1);
    }

    static void marshal_us(String selfNode, String peerNode,
			   String cookie, String serverName)
	throws java.lang.Exception
    {
	m._iStub i = new m._iStub(selfNode, peerNode, cookie, serverName);
	// Just warming up..
	verify_us(i, 3, 2, 1);
	verify_us(i, 5, 4, 3);
	// The small integer border
	verify_us(i, 255, 0, 1);
	verify_us(i, 256, 0, 1);
	// Java short border
	verify_us(i, java.lang.Short.MAX_VALUE, 0, 1);
	verify_us(i, java.lang.Short.MIN_VALUE, 0, 1);
	verify_us(i, -1, 0, 1);
	verify_us(i, java.lang.Short.MAX_VALUE, 
		  java.lang.Short.MIN_VALUE, 1);
	// Impossible decodes
	verify_us_bad(i, -1, -1, 1);
    }

    static void marshal_c(String selfNode, String peerNode,
			   String cookie, String serverName)
	throws java.lang.Exception
    {
	m._iStub i = new m._iStub(selfNode, peerNode, cookie, serverName);
	// Just warming up..
	verify_c(i, '\3', '\2', 1);
	verify_c(i, '\5', '\4', 3);
	// The small integer border
	verify_c(i, '\u00FF', '\0', 1);
	verify_c(i, '\u0100', '\0', 1);
	// Java char border
	verify_c(i, java.lang.Character.MAX_VALUE, '\0', 1);
	verify_c(i, java.lang.Character.MIN_VALUE, '\0', 1);
	verify_c(i, java.lang.Character.MAX_VALUE, 
		  java.lang.Character.MIN_VALUE, 1);
	// Impossible decodes
	verify_c_bad(i, '\u8000', '\0', 2);
    }

    static void marshal_wc(String selfNode, String peerNode,
			   String cookie, String serverName)
	throws java.lang.Exception
    {
	m._iStub i = new m._iStub(selfNode, peerNode, cookie, serverName);
	// Just warming up..
	verify_wc(i, '\3', '\2', 1);
	verify_wc(i, '\5', '\4', 3);
	// The small integer border
	verify_wc(i, '\u00FF', '\0', 1);
	verify_wc(i, '\u0100', '\0', 1);
	// Java char border
	verify_wc(i, java.lang.Character.MAX_VALUE, '\0', 1);
	verify_wc(i, java.lang.Character.MIN_VALUE, '\0', 1);
	verify_wc(i, java.lang.Character.MAX_VALUE, 
		  java.lang.Character.MIN_VALUE, 1);
	// Impossible decodes
	verify_c_bad(i, '\u8000', '\0', 2);
    }

    static void marshal_str(String selfNode, String peerNode,
			    String cookie, String serverName)
	throws java.lang.Exception
    {
	m._iStub i = new m._iStub(selfNode, peerNode, cookie, serverName);
	// Just warming up..
	verify_str(i, 100, 100);
	verify_str(i, 100, 1);
	// Erlang string border
	verify_str(i, 65535, 1);
	verify_str(i, 2, 65535);
	// Erlang string border out
	verify_str(i, 65536, 1);
	verify_str(i, 65536, 65536);
    }

    static void marshal_any_3(String selfNode, String peerNode,
			      String cookie, String serverName)
	throws java.lang.Exception
    {
	m._iStub i = new m._iStub(selfNode, peerNode, cookie, serverName);
	com.ericsson.otp.ic.Any x = new com.ericsson.otp.ic.Any();
	com.ericsson.otp.ic.Any y = new com.ericsson.otp.ic.Any();
	com.ericsson.otp.ic.Any z = new com.ericsson.otp.ic.Any();
	
	x.insert_longlong(java.lang.Long.MAX_VALUE);
	y.insert_longlong(1L);
	z.insert_longlong(java.lang.Long.MAX_VALUE-1L);
	System.out.println("verify_any_3 longlong max");
	verify_any_3(i, x, y, 1, z);
	
	x.insert_longlong(java.lang.Long.MIN_VALUE);
	y.insert_longlong(-1L);
	z.insert_longlong(java.lang.Long.MIN_VALUE+1L);
	System.out.println("verify_any_3 longlong min");
	verify_any_3(i, x, y, 1, z);
	
	x.insert_ulonglong(-1L);
	y.insert_longlong(1L);
	z.insert_ulonglong(-2L);
	System.out.println("verify_any_3 ulonglong max");
	verify_any_3(i, x, y, 1, z);
	
	x.insert_ulonglong(0L);
	y.insert_longlong(-1L);
	z.insert_ulonglong(1L);
	System.out.println("verify_any_3 ulonglong min");
	verify_any_3(i, x, y, 1, z);
	
	x.insert_long(java.lang.Integer.MAX_VALUE);
	y.insert_long(1);
	z.insert_long(java.lang.Integer.MAX_VALUE-1);
	System.out.println("verify_any_3 long max");
	verify_any_3(i, x, y, 1, z);
	
	x.insert_long(java.lang.Integer.MIN_VALUE);
	y.insert_long(-1);
	z.insert_long(java.lang.Integer.MIN_VALUE+1);
	System.out.println("verify_any_3 long min");
	verify_any_3(i, x, y, 1, z);
	
	x.insert_ulong(-1);
	y.insert_long(1);
	z.insert_ulong(-2);
	System.out.println("verify_any_3 ulong max");
	verify_any_3(i, x, y, 1, z);
	
	x.insert_ulong(0);
	y.insert_long(-1);
	z.insert_ulong(1);
	System.out.println("verify_any_3 ulong min");
	verify_any_3(i, x, y, 1, z);
	
	x.insert_short(java.lang.Short.MAX_VALUE);
	y.insert_short((short)1);
	z.insert_short((short)(java.lang.Short.MAX_VALUE-1));
	System.out.println("verify_any_3 short max");
	verify_any_3(i, x, y, 1, z);
	
	x.insert_short(java.lang.Short.MIN_VALUE);
	y.insert_short((short)-1);
	z.insert_short((short)(java.lang.Short.MIN_VALUE+1));
	System.out.println("verify_any_3 short min");
	verify_any_3(i, x, y, 1, z);
	
	x.insert_ushort((short)-1);
	y.insert_short((short)1);
	z.insert_ushort((short)-2);
	System.out.println("verify_any_3 ushort max");
	verify_any_3(i, x, y, 1, z);
	
	x.insert_ushort((short)0);
	y.insert_short((short)-1);
	z.insert_ushort((short)1);
	System.out.println("verify_any_3 ushort min");
	verify_any_3(i, x, y, 1, z);
	
	x.insert_char('\377');
	y.insert_char('\1');
	z.insert_char('\376');
	System.out.println("verify_any_3 char max");
	verify_any_3(i, x, y, 1, z);
	
	x.insert_wchar('\uFFFF');
	y.insert_wchar('\u0001');
	z.insert_wchar('\uFFFE');
	System.out.println("verify_any_3 char max");
	verify_any_3(i, x, y, 1, z);
    }

    static void marshal_any_2(String selfNode, String peerNode,
			      String cookie, String serverName)
	throws java.lang.Exception
    {
	m._iStub i = new m._iStub(selfNode, peerNode, cookie, serverName);
	m.s s = new m.s();
	com.ericsson.otp.ic.Any a = new com.ericsson.otp.ic.Any();
	//
	s.ull_x = -1L;
	s.ll_x = java.lang.Long.MAX_VALUE;
	s.ll_y = 1L;
	s.ull_z = -2L;
	s.ll_z = java.lang.Long.MAX_VALUE-1L;
	//
	s.ul_x = -1;
	s.l_x = java.lang.Integer.MAX_VALUE;
	s.l_y = 1;
	s.ul_z = -2;
	s.l_z = java.lang.Integer.MAX_VALUE-1;
	//
	s.us_x = (short)-1;
	s.s_x = java.lang.Short.MAX_VALUE;
	s.s_y = (short)1;
	s.us_z = (short)-2;
	s.s_z = (short)(java.lang.Short.MAX_VALUE-1);
	//
	s.c_x = '\377';
	s.c_y = '\1';
	s.c_z = '\376';
	s.wc_x = '\uFFFF';
	s.wc_y = '\u0001';
	s.wc_z = '\uFFFE';
	m.sHelper.insert(a, s);
	verify_any_2(i, a, 1);
	
	s.ull_x = 0L;
	s.ll_x = java.lang.Long.MIN_VALUE;
	s.ll_y = -1L;
	s.ull_z = 1L;
	s.ll_z = java.lang.Long.MIN_VALUE+1L;
	//
	s.ul_x = 0;
	s.l_x = java.lang.Integer.MIN_VALUE;
	s.l_y = -1;
	s.ul_z = 1;
	s.l_z = java.lang.Integer.MIN_VALUE+1;
	//
	s.us_x = (short)0;
	s.s_x = java.lang.Short.MIN_VALUE;
	s.s_y = (short)-1;
	s.us_z = (short)1;
	s.s_z = (short)(java.lang.Short.MIN_VALUE+1);
	//
	s.c_x = '\0';
	s.c_y = '\0';
	s.c_z = '\0';
	s.wc_x = '\u0000';
	s.wc_y = '\u0000';
	s.wc_z = '\u0000';
	m.sHelper.insert(a, s);
	verify_any_2(i, a, 1);
    }


    static void verify_ll(m._iStub i, long x, long y, int b) 
	throws java.lang.Exception 
    {
	m.s a = new m.s();
	System.out.println("verify_ll "+a);
	a.ll_x = x;
	a.ll_y = y;
	long expected = (x - y)*(short)b;
	long result = i.marshal_ll(a, (short)b);
	if (result == expected) {
	    System.out.println("verify_ll("+x+", "+y+", "+b+") => "
			       +result);
	} else {
	    System.out.println("verify_ll("+x+", "+y+", "+b+") => "
			       +result+" != "+expected);
	    System.exit(4);
	}
    }

    static void verify_ull(m._iStub i, long x, long y, int b) 
	throws java.lang.Exception 
    {
	m.s a = new m.s();
	a.ull_x = x;
	a.ll_y = y;
	long expected = (x - y)*(short)b;
	long result = i.marshal_ull(a, (short)b);
	if (result == expected) {
	    System.out.println("verify_ull("+x+", "+y+", "+b+") => "
			       +result);
	} else {
	    System.out.println("verify_ull("+x+", "+y+", "+b+") => "
			       +result+" != "+expected);
	    System.exit(4);
	}
    }

    static void verify_l(m._iStub i, int x, int y, int b) 
	throws java.lang.Exception 
    {
	m.s a = new m.s();
	a.l_x = x;
	a.l_y = y;
	int expected = (x - y)*(short)b;
	int result = i.marshal_l(a, (short)b);
	if (result == expected) {
	    System.out.println("verify_l("+x+", "+y+", "+b+") => "
			       +result);
	} else {
	    System.out.println("verify_l("+x+", "+y+", "+b+") => "
			       +result+" != "+expected);
	    System.exit(4);
	}
    }

    static void verify_ul(m._iStub i, int x, int y, int b) 
	throws java.lang.Exception 
    {
	m.s a = new m.s();
	a.ul_x = x;
	a.l_y = y;
	int expected = (x - y)*(short)b;
	int result = i.marshal_ul(a, (short)b);
	if (result == expected) {
	    System.out.println("verify_ul("+x+", "+y+", "+b+") => "
			       +result);
	} else {
	    System.out.println("verify_ul("+x+", "+y+", "+b+") => "
			       +result+" != "+expected);
	    System.exit(4);
	}
    }

    static void verify_s(m._iStub i, int x, int y, int b) 
	throws java.lang.Exception 
    {
	m.s a = new m.s();
	a.s_x = (short)x;
	a.s_y = (short)y;
	short expected = (short)((x - y)*(short)b);
	short result = i.marshal_s(a, (short)b);
	if (result == expected) {
	    System.out.println("verify_s("+x+", "+y+", "+b+") => "
			       +result);
	} else {
	    System.out.println("verify_s("+x+", "+y+", "+b+") => "
			       +result+" != "+expected);
	    System.exit(4);
	}
    }

    static void verify_us(m._iStub i, int x, int y, int b) 
	throws java.lang.Exception 
    {
	m.s a = new m.s();
	a.us_x = (short)x;
	a.s_y = (short)y;
	short expected = (short)((x - y)*(short)b);
	short result = i.marshal_us(a, (short)b);
	if (result == expected) {
	    System.out.println("verify_us("+x+", "+y+", "+b+") => "
			       +result);
	} else {
	    System.out.println("verify_us("+x+", "+y+", "+b+") => "
			       +result+" != "+expected);
	    System.exit(4);
	}
    }

    static void verify_c(m._iStub i, char x, char y, int b) 
	throws java.lang.Exception 
    {
	m.s a = new m.s();
	a.c_x = x;
	a.c_y = y;
	char expected = (char)(((int)x - (int)y)*(short)b);
	char result = i.marshal_c(a, (short)b);
	if (result == expected) {
	    System.out.println("verify_c("+x+", "+y+", "+b+") => "
			       +result);
	} else {
	    System.out.println("verify_c("+x+", "+y+", "+b+") => "
			       +result+" != "+expected);
	    System.exit(4);
	}
    }

    static void verify_wc(m._iStub i, char x, char y, int b) 
	throws java.lang.Exception 
    {
	m.s a = new m.s();
	a.wc_x = x;
	a.wc_y = y;
	char expected = (char)(((int)x - (int)y)*(short)b);
	char result = i.marshal_wc(a, (short)b);
	if (result == expected) {
	    System.out.println("verify_wc("+x+", "+y+", "+b+") => "
			       +result);
	} else {
	    System.out.println("verify_wc("+x+", "+y+", "+b+") => "
			       +result+" != "+expected);
	    System.exit(4);
	}
    }

    static void verify_str(m._iStub i, int a_len, int b_len) 
	throws java.lang.Exception 
    {
	String a = mk_str(a_len);
	String b = mk_str(b_len);
	String expected = a + b;
	String result = i.strcat(a, b);
	if (result.equals(expected)) {
	    System.out.println("verify_str(\""+a+"\", \""+b+"\") => \""
			       +result+"\"");
	} else {
	    System.out.println("verify_str(\""+a+"\", \""+b+"\") => \""
			       +result+"\" != \""+expected.length()+"\"");
	    System.exit(4);
	}
    }

    static String mk_str(int len) 
	throws StringIndexOutOfBoundsException
    {
	StringBuffer s = new StringBuffer();
	// 17 characters is prime relative all bases of two - on purpose
	do s.append("qwertyuiopasdfghj"); while (s.length() < len);
	return s.substring(0, len);
    }

    static void verify_any_3(m._iStub i, 
			   com.ericsson.otp.ic.Any x, 
			   com.ericsson.otp.ic.Any y, 
			   int b, 
			   com.ericsson.otp.ic.Any expected) 
	throws java.lang.Exception 
    {
	com.ericsson.otp.ic.Any result = i.marshal_any_3(x, y, (short)b);
	if (! expected.equal(result)) {
	    System.exit(4);
	}
    }

    static void verify_any_2(m._iStub i, com.ericsson.otp.ic.Any a, int b)
	throws java.lang.Exception 
    {
	com.ericsson.otp.ic.Any result = i.marshal_any_2(a, (short)b);
	if (! a.equal(result)) {
	    System.exit(4);
	}
    }



    static void verify_ll_bad(m._iStub i, long x, long y, int b)
	throws java.lang.Exception
    {
	try {
	    verify_ll(i, x, y, b);
	    System.out.println("Expected exception missing!");
	    System.exit(5);
	} catch (com.ericsson.otp.erlang.OtpErlangDecodeException e) {
	    System.out.println("Expected exception: "+e);
	}
    }

    static void verify_ull_bad(m._iStub i, long x, long y, int b)
	throws java.lang.Exception
    {
	try {
	    verify_ull(i, x, y, b);
	    System.out.println("Expected exception missing!");
	    System.exit(5);
	} catch (com.ericsson.otp.erlang.OtpErlangDecodeException e) {
	    System.out.println("Expected exception: "+e);
	}
    }

    static void verify_l_bad(m._iStub i, int x, int y, int b)
	throws java.lang.Exception
    {
	try {
	    verify_l(i, x, y, b);
	    System.out.println("Expected exception missing!");
	    System.exit(5);
	} catch (com.ericsson.otp.erlang.OtpErlangDecodeException e) {
	    System.out.println("Expected exception: "+e);
	}
    }

    static void verify_ul_bad(m._iStub i, int x, int y, int b)
	throws java.lang.Exception
    {
	try {
	    verify_ul(i, x, y, b);
	    System.out.println("Expected exception missing!");
	    System.exit(5);
	} catch (com.ericsson.otp.erlang.OtpErlangDecodeException e) {
	    System.out.println("Expected exception: "+e);
	}
    }

    static void verify_s_bad(m._iStub i, int x, int y, int b)
	throws java.lang.Exception
    {
	try {
	    verify_s(i, x, y, b);
	    System.out.println("Expected exception missing!");
	    System.exit(5);
	} catch (com.ericsson.otp.erlang.OtpErlangDecodeException e) {
	    System.out.println("Expected exception: "+e);
	}
    }

    static void verify_us_bad(m._iStub i, int x, int y, int b)
	throws java.lang.Exception
    {
	try {
	    verify_us(i, x, y, b);
	    System.out.println("Expected exception missing!");
	    System.exit(5);
	} catch (com.ericsson.otp.erlang.OtpErlangDecodeException e) {
	    System.out.println("Expected exception: "+e);
	}
    }

    static void verify_c_bad(m._iStub i, char x, char y, int b)
	throws java.lang.Exception
    {
	try {
	    verify_c(i, x, y, b);
	    System.out.println("Expected exception missing!");
	    System.exit(5);
	} catch (com.ericsson.otp.erlang.OtpErlangDecodeException e) {
	    System.out.println("Expected exception: "+e);
	}
    }

    static void verify_wc_bad(m._iStub i, char x, char y, int b)
	throws java.lang.Exception
    {
	try {
	    verify_wc(i, x, y, b);
	    System.out.println("Expected exception missing!");
	    System.exit(5);
	} catch (com.ericsson.otp.erlang.OtpErlangDecodeException e) {
	    System.out.println("Expected exception: "+e);
	}
    }

}