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
|
//=============================================================================
/**
* @file driver.cpp
*
* $Id$
*
* Driver program
*
*
* @author Aniruddha Gokhale
*/
//=============================================================================
#include "client.h"
#include "driver.h"
#include "results.h"
#include "tests.h"
#include "ace/Get_Opt.h"
// This function runs the test (main program)
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
// get an instance of the driver object
try
{
Driver drv;
// initialize the driver
if (drv.init (argc, argv) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) driver.cpp - "
"Driver initialization failed\n"),
-1);
// run various tests
if (drv.run () == -1)
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) driver.cpp - "
"tests failed\n"),
-1);
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Caught unexpected CORBA exception:");
return 1;
}
return 0;
}
// constructor
Driver::Driver (void)
{
}
Driver::~Driver (void)
{
}
// initialize the driver
int
Driver::init (int argc, ACE_TCHAR **argv)
{
// environment to track exceptions
// retrieve the instance of Options
Options *opt = OPTIONS::instance ();
char exception_string[256];
try
{
ACE_OS::strcpy (exception_string, "ORB Initialization");
// Retrieve the underlying ORB
this->orb_ = CORBA::ORB_init (argc,
argv,
"internet");
// Parse command line and verify parameters.
if (opt->parse_args (argc, argv) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) driver.cpp - "
"parse_args failed\n"),
-1);
// Retrieve a Param_Test object reference
ACE_OS::strcpy (exception_string,"ORB::string_to_object() failed.");
CORBA::Object_var temp =
this->orb_->string_to_object (opt->param_test_ior ());
if (CORBA::is_nil (temp.in()))
ACE_ERROR_RETURN ((LM_ERROR,
"ORB::string_to_object() returned null object for IOR <%s>\n",
opt->param_test_ior ()),
-1);
// Get the object reference
ACE_OS::strcpy (exception_string,"Param_Test::_narrow () failed.");
this->objref_ = Param_Test::_narrow (temp.in());
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception (exception_string);
return -1;
}
return 0;
}
int
Driver::run (void)
{
// serves as a factory of Param_Client objects. It is also responsible to
// start the test
Options *opt = OPTIONS::instance (); // get the options object
int retstatus = -1;
switch (opt->test_type ())
{
case Options::TEST_SHORT:
{
Param_Test_Client<Test_Short> *client = new
Param_Test_Client<Test_Short> (this->orb_.in (),
this->objref_.in(),
new Test_Short);
if (opt->invoke_type () == Options::SII)
retstatus = client->run_sii_test ();
else
retstatus = client->run_dii_test ();
delete client;
}
break;
case Options::TEST_ULONGLONG:
{
Param_Test_Client<Test_ULongLong> *client = new
Param_Test_Client<Test_ULongLong> (this->orb_.in (),
this->objref_.in(),
new Test_ULongLong);
if (opt->invoke_type () == Options::SII)
retstatus = client->run_sii_test ();
else
retstatus = client->run_dii_test ();
delete client;
}
break;
case Options::TEST_UB_STRING:
{
Param_Test_Client<Test_Unbounded_String> *client = new
Param_Test_Client<Test_Unbounded_String> (this->orb_.in (),
this->objref_.in(),
new Test_Unbounded_String);
if (opt->invoke_type () == Options::SII)
retstatus = client->run_sii_test ();
else
retstatus = client->run_dii_test ();
delete client;
}
break;
case Options::TEST_BD_STRING:
{
Param_Test_Client<Test_Bounded_String> *client = new
Param_Test_Client<Test_Bounded_String> (this->orb_.in (),
this->objref_.in(),
new Test_Bounded_String);
if (opt->invoke_type () == Options::SII)
retstatus = client->run_sii_test ();
else
retstatus = client->run_dii_test ();
delete client;
}
break;
case Options::TEST_UB_WSTRING:
{
Param_Test_Client<Test_Unbounded_WString> *client = new
Param_Test_Client<Test_Unbounded_WString> (this->orb_.in (),
this->objref_.in(),
new Test_Unbounded_WString);
if (opt->invoke_type () == Options::SII)
retstatus = client->run_sii_test ();
else
retstatus = client->run_dii_test ();
delete client;
}
break;
case Options::TEST_BD_WSTRING:
{
Param_Test_Client<Test_Bounded_WString> *client = new
Param_Test_Client<Test_Bounded_WString> (this->orb_.in (),
this->objref_.in(),
new Test_Bounded_WString);
if (opt->invoke_type () == Options::SII)
retstatus = client->run_sii_test ();
else
retstatus = client->run_dii_test ();
delete client;
}
break;
case Options::TEST_FIXED_STRUCT:
{
Param_Test_Client<Test_Fixed_Struct> *client = new
Param_Test_Client<Test_Fixed_Struct> (this->orb_.in (),
this->objref_.in(),
new Test_Fixed_Struct);
if (opt->invoke_type () == Options::SII)
retstatus = client->run_sii_test ();
else
retstatus = client->run_dii_test ();
delete client;
}
break;
case Options::TEST_UB_STRING_SEQUENCE:
{
Param_Test_Client<Test_String_Sequence> *client = new
Param_Test_Client<Test_String_Sequence> (this->orb_.in (),
this->objref_.in(),
new Test_String_Sequence);
if (opt->invoke_type () == Options::SII)
retstatus = client->run_sii_test ();
else
retstatus = client->run_dii_test ();
delete client;
}
break;
case Options::TEST_BD_STRING_SEQUENCE:
{
Param_Test_Client<Test_Bounded_String_Sequence> *client = new
Param_Test_Client<Test_Bounded_String_Sequence> (this->orb_.in (),
this->objref_.in(),
new Test_Bounded_String_Sequence);
if (opt->invoke_type () == Options::SII)
retstatus = client->run_sii_test ();
else
retstatus = client->run_dii_test ();
delete client;
}
break;
case Options::TEST_UB_WSTRING_SEQUENCE:
{
Param_Test_Client<Test_WString_Sequence> *client = new
Param_Test_Client<Test_WString_Sequence> (this->orb_.in (),
this->objref_.in(),
new Test_WString_Sequence);
if (opt->invoke_type () == Options::SII)
retstatus = client->run_sii_test ();
else
retstatus = client->run_dii_test ();
delete client;
}
break;
case Options::TEST_BD_WSTRING_SEQUENCE:
{
Param_Test_Client<Test_Bounded_WString_Sequence> *client = new
Param_Test_Client<Test_Bounded_WString_Sequence> (this->orb_.in (),
this->objref_.in(),
new Test_Bounded_WString_Sequence);
if (opt->invoke_type () == Options::SII)
retstatus = client->run_sii_test ();
else
retstatus = client->run_dii_test ();
delete client;
}
break;
case Options::TEST_VAR_STRUCT:
{
Param_Test_Client<Test_Var_Struct> *client = new
Param_Test_Client<Test_Var_Struct> (this->orb_.in (),
this->objref_.in(),
new Test_Var_Struct);
if (opt->invoke_type () == Options::SII)
retstatus = client->run_sii_test ();
else
retstatus = client->run_dii_test ();
delete client;
}
break;
case Options::TEST_NESTED_STRUCT:
{
Param_Test_Client<Test_Nested_Struct> *client = new
Param_Test_Client<Test_Nested_Struct> (this->orb_.in (),
this->objref_.in(),
new Test_Nested_Struct);
if (opt->invoke_type () == Options::SII)
retstatus = client->run_sii_test ();
else
retstatus = client->run_dii_test ();
delete client;
}
break;
case Options::TEST_RECURSIVE_STRUCT:
{
Param_Test_Client<Test_Recursive_Struct> *client = new
Param_Test_Client<Test_Recursive_Struct> (this->orb_.in (),
this->objref_.in(),
new Test_Recursive_Struct);
if (opt->invoke_type () == Options::SII)
retstatus = client->run_sii_test ();
else
retstatus = client->run_dii_test ();
delete client;
}
break;
case Options::TEST_OBJREF_STRUCT:
{
Param_Test_Client<Test_Objref_Struct> *client = new
Param_Test_Client<Test_Objref_Struct> (this->orb_.in (),
this->objref_.in(),
new Test_Objref_Struct);
if (opt->invoke_type () == Options::SII)
retstatus = client->run_sii_test ();
else
retstatus = client->run_dii_test ();
delete client;
}
break;
case Options::TEST_UB_STRUCT_SEQUENCE:
{
Param_Test_Client<Test_Struct_Sequence> *client = new
Param_Test_Client<Test_Struct_Sequence> (this->orb_.in (),
this->objref_.in(),
new Test_Struct_Sequence);
if (opt->invoke_type () == Options::SII)
retstatus = client->run_sii_test ();
else
retstatus = client->run_dii_test ();
delete client;
Param_Test_Client<Test_Unbounded_Struct_Sequence> *client2 = new
Param_Test_Client<Test_Unbounded_Struct_Sequence>
(this->orb_.in (),
this->objref_.in(),
new Test_Unbounded_Struct_Sequence);
if (opt->invoke_type () == Options::SII)
retstatus = client2->run_sii_test ();
else
retstatus = client2->run_dii_test ();
delete client2;
}
break;
case Options::TEST_BD_STRUCT_SEQUENCE:
{
Param_Test_Client<Test_Bounded_Struct_Sequence> *client = new
Param_Test_Client<Test_Bounded_Struct_Sequence> (this->orb_.in (),
this->objref_.in (),
new Test_Bounded_Struct_Sequence);
if (opt->invoke_type () == Options::SII)
retstatus = client->run_sii_test ();
else
retstatus = client->run_dii_test ();
delete client;
}
break;
case Options::TEST_UB_ARRAY_SEQUENCE:
{
Param_Test_Client<Test_Array_Sequence> *client = new
Param_Test_Client<Test_Array_Sequence> (this->orb_.in (),
this->objref_.in (),
new Test_Array_Sequence);
if (opt->invoke_type () == Options::SII)
retstatus = client->run_sii_test ();
else
retstatus = client->run_dii_test ();
delete client;
}
break;
case Options::TEST_BD_ARRAY_SEQUENCE:
{
Param_Test_Client<Test_Bounded_Array_Sequence> *client = new
Param_Test_Client<Test_Bounded_Array_Sequence> (this->orb_.in (),
this->objref_.in (),
new Test_Bounded_Array_Sequence);
if (opt->invoke_type () == Options::SII)
retstatus = client->run_sii_test ();
else
retstatus = client->run_dii_test ();
delete client;
}
break;
case Options::TEST_OBJREF:
{
Param_Test_Client<Test_ObjRef> *client = new
Param_Test_Client<Test_ObjRef> (this->orb_.in (),
this->objref_.in (),
new Test_ObjRef);
if (opt->invoke_type () == Options::SII)
retstatus = client->run_sii_test ();
else
retstatus = client->run_dii_test ();
delete client;
}
break;
case Options::TEST_TYPECODE:
{
Param_Test_Client<Test_TypeCode> *client = new
Param_Test_Client<Test_TypeCode> (this->orb_.in (),
this->objref_.in(),
new Test_TypeCode);
if (opt->invoke_type () == Options::SII)
retstatus = client->run_sii_test ();
else
retstatus = client->run_dii_test ();
delete client;
}
break;
case Options::TEST_ANY:
{
Param_Test_Client<Test_Any> *client = new
Param_Test_Client<Test_Any> (this->orb_.in (),
this->objref_.in(),
new Test_Any);
if (opt->invoke_type () == Options::SII)
retstatus = client->run_sii_test ();
else
retstatus = client->run_dii_test ();
delete client;
}
break;
case Options::TEST_OBJREF_SEQUENCE:
{
Param_Test_Client<Test_ObjRef_Sequence> *client = new
Param_Test_Client<Test_ObjRef_Sequence> (this->orb_.in (),
this->objref_.in(),
new Test_ObjRef_Sequence);
if (opt->invoke_type () == Options::SII)
retstatus = client->run_sii_test ();
else
retstatus = client->run_dii_test ();
delete client;
}
break;
case Options::TEST_ANYSEQ:
{
Param_Test_Client<Test_AnySeq> *client = new
Param_Test_Client<Test_AnySeq> (this->orb_.in (),
this->objref_.in(),
new Test_AnySeq);
if (opt->invoke_type () == Options::SII)
retstatus = client->run_sii_test ();
else
retstatus = client->run_dii_test ();
delete client;
}
break;
case Options::TEST_UB_SHORTSEQ:
{
Param_Test_Client<Test_Short_Sequence> *client = new
Param_Test_Client<Test_Short_Sequence> (this->orb_.in (),
this->objref_.in(),
new Test_Short_Sequence);
if (opt->invoke_type () == Options::SII)
retstatus = client->run_sii_test ();
else
retstatus = client->run_dii_test ();
delete client;
}
break;
case Options::TEST_BD_SHORTSEQ:
{
Param_Test_Client<Test_Bounded_Short_Sequence> *client = new
Param_Test_Client<Test_Bounded_Short_Sequence> (this->orb_.in (),
this->objref_.in(),
new Test_Bounded_Short_Sequence);
if (opt->invoke_type () == Options::SII)
retstatus = client->run_sii_test ();
else
retstatus = client->run_dii_test ();
delete client;
}
break;
case Options::TEST_UB_LONGSEQ:
{
Param_Test_Client<Test_Long_Sequence> *client = new
Param_Test_Client<Test_Long_Sequence> (this->orb_.in (),
this->objref_.in(),
new Test_Long_Sequence);
if (opt->invoke_type () == Options::SII)
retstatus = client->run_sii_test ();
else
retstatus = client->run_dii_test ();
delete client;
}
break;
case Options::TEST_BD_LONGSEQ:
{
Param_Test_Client<Test_Bounded_Long_Sequence> *client = new
Param_Test_Client<Test_Bounded_Long_Sequence> (this->orb_.in (),
this->objref_.in(),
new Test_Bounded_Long_Sequence);
if (opt->invoke_type () == Options::SII)
retstatus = client->run_sii_test ();
else
retstatus = client->run_dii_test ();
delete client;
}
break;
case Options::TEST_FIXED_ARRAY:
{
Param_Test_Client<Test_Fixed_Array> *client = new
Param_Test_Client<Test_Fixed_Array> (this->orb_.in (),
this->objref_.in(),
new Test_Fixed_Array);
if (opt->invoke_type () == Options::SII)
retstatus = client->run_sii_test ();
else
retstatus = client->run_dii_test ();
delete client;
}
break;
case Options::TEST_VAR_ARRAY:
{
Param_Test_Client<Test_Var_Array> *client = new
Param_Test_Client<Test_Var_Array> (this->orb_.in (),
this->objref_.in(),
new Test_Var_Array);
if (opt->invoke_type () == Options::SII)
retstatus = client->run_sii_test ();
else
retstatus = client->run_dii_test ();
delete client;
}
break;
case Options::TEST_EXCEPTION:
{
Param_Test_Client<Test_Exception> *client = new
Param_Test_Client<Test_Exception> (this->orb_.in (),
this->objref_.in(),
new Test_Exception);
if (opt->invoke_type () == Options::SII)
retstatus = client->run_sii_test ();
else
retstatus = client->run_dii_test ();
delete client;
}
break;
case Options::TEST_BIG_UNION:
{
Param_Test_Client<Test_Big_Union> *client = new
Param_Test_Client<Test_Big_Union> (this->orb_.in (),
this->objref_.in(),
new Test_Big_Union);
if (opt->invoke_type () == Options::SII)
retstatus = client->run_sii_test ();
else
retstatus = client->run_dii_test ();
delete client;
}
break;
case Options::TEST_SMALL_UNION:
{
Param_Test_Client<Test_Small_Union> *client = new
Param_Test_Client<Test_Small_Union> (this->orb_.in (),
this->objref_.in(),
new Test_Small_Union);
if (opt->invoke_type () == Options::SII)
retstatus = client->run_sii_test ();
else
retstatus = client->run_dii_test ();
delete client;
}
break;
case Options::TEST_RECURSIVE_UNION:
{
Param_Test_Client<Test_Recursive_Union> *client = new
Param_Test_Client<Test_Recursive_Union> (this->orb_.in (),
this->objref_.in(),
new Test_Recursive_Union);
if (opt->invoke_type () == Options::SII)
retstatus = client->run_sii_test ();
else
retstatus = client->run_dii_test ();
delete client;
}
break;
case Options::TEST_COMPLEX_ANY:
{
Param_Test_Client<Test_Complex_Any> *client = new
Param_Test_Client<Test_Complex_Any> (this->orb_.in (),
this->objref_.in(),
new Test_Complex_Any);
if (opt->invoke_type () == Options::SII)
retstatus = client->run_sii_test ();
else
retstatus = client->run_dii_test ();
delete client;
}
break;
case Options::TEST_MULTDIM_ARRAY:
{
Param_Test_Client<Test_Multdim_Array> *client = new
Param_Test_Client<Test_Multdim_Array> (this->orb_.in (),
this->objref_.in(),
new Test_Multdim_Array);
if (opt->invoke_type () == Options::SII)
retstatus = client->run_sii_test ();
else
retstatus = client->run_dii_test ();
delete client;
}
break;
default:
break;
}
// Get in a new environment variable
try
{
if (opt->shutdown ())
{
this->objref_->shutdown ();
}
this->objref_ = Param_Test::_nil ();
this->orb_->destroy ();
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("during shutdown");
}
return retstatus;
}
|