2 //=============================================================================
6 * Implementation file for the driver program.
8 * @author Jeff Parsons <parsons@cs.wustl.edu>
10 //=============================================================================
14 #include "test_dynany.h"
15 #include "test_dynarray.h"
16 #include "test_dynenum.h"
17 #include "test_dynsequence.h"
18 #include "test_dynstruct.h"
19 #include "test_dynunion.h"
20 #include "test_wrapper.h"
21 #include "tao/PortableServer/PortableServer.h"
22 #include "ace/Get_Opt.h"
23 #include "ace/OS_NS_string.h"
25 int ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
32 // initialize the driver
33 if (driver
.init (argc
, argv
) == -1)
34 ACE_ERROR_RETURN ((LM_ERROR
,
35 "(%N:%l) driver.cpp - "
36 "Driver initialization failed\n"),
40 error_count
= driver
.run ();
44 "(%N:%l) driver.cpp - "
49 catch (const CORBA::Exception
& ex
)
51 ex
._tao_print_exception ("Caught unexpected CORBA exception:");
61 : test_type_ (NO_TEST
),
67 Driver::~Driver (void)
69 if (this->orb_
.in () != 0)
71 this->orb_
->shutdown ();
72 this->orb_
->destroy ();
76 // initialize the driver
78 Driver::init (int argc
, ACE_TCHAR
*argv
[])
82 // Retrieve the underlying ORB
83 this->orb_
= CORBA::ORB_init (argc
, argv
, "local");
86 // Parse command line and verify parameters.
87 if (this->parse_args (argc
, argv
) == -1)
88 ACE_ERROR_RETURN ((LM_ERROR
,
89 "(%N:%l) driver.cpp - "
90 "parse_args failed\n"),
94 catch (const CORBA::Exception
& ex
)
96 ex
._tao_print_exception ("Driver::init");
104 Driver::parse_args (int argc
, ACE_TCHAR
*argv
[])
107 ACE_ERROR_RETURN ((LM_ERROR
,
109 " -t [dynany|dynarray|dynenum|dynsequence|dynstruct|dynunion]\n"
114 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("t:d"));
116 const ACE_TCHAR
*test_str
= 0;
118 while ((c
= get_opts ()) != -1)
122 test_str
= get_opts
.opt_arg ();
124 if (!ACE_OS::strcmp (test_str
, ACE_TEXT ("dynany")))
125 this->test_type_
= TEST_DYNANY
;
126 else if (!ACE_OS::strcmp (test_str
, ACE_TEXT ("dynarray")))
127 this->test_type_
= TEST_DYNARRAY
;
128 else if (!ACE_OS::strcmp (test_str
, ACE_TEXT ("dynenum")))
129 this->test_type_
= TEST_DYNENUM
;
130 else if (!ACE_OS::strcmp (test_str
, ACE_TEXT ("dynsequence")))
131 this->test_type_
= TEST_DYNSEQUENCE
;
132 else if (!ACE_OS::strcmp (test_str
, ACE_TEXT ("dynstruct")))
133 this->test_type_
= TEST_DYNSTRUCT
;
134 else if (!ACE_OS::strcmp (test_str
, ACE_TEXT ("dynunion")))
135 this->test_type_
= TEST_DYNUNION
;
137 ACE_DEBUG ((LM_DEBUG
,
138 "I don't recognize test type %s\n",
148 ACE_ERROR_RETURN ((LM_ERROR
,
150 " -t [dynany|dynarray|dynenum|dynsequence|dynstruct|dynunion]"
157 // Indicates successful parsing of command line.
166 switch (this->test_type_
)
170 Test_Wrapper
<Test_DynAny
>* wrapper
=
171 new Test_Wrapper
<Test_DynAny
> (new Test_DynAny (this->orb_
, debug_
));
172 error_count
= wrapper
->run_test ();
178 Test_Wrapper
<Test_DynArray
>* wrapper
=
179 new Test_Wrapper
<Test_DynArray
> (new Test_DynArray (this->orb_
, debug_
));
180 error_count
= wrapper
->run_test ();
186 Test_Wrapper
<Test_DynEnum
>* wrapper
=
187 new Test_Wrapper
<Test_DynEnum
> (new Test_DynEnum (this->orb_
, debug_
));
188 error_count
= wrapper
->run_test ();
192 case TEST_DYNSEQUENCE
:
194 Test_Wrapper
<Test_DynSequence
>* wrapper
=
195 new Test_Wrapper
<Test_DynSequence
> (new Test_DynSequence (this->orb_
, debug_
));
196 error_count
= wrapper
->run_test ();
202 Test_Wrapper
<Test_DynStruct
>* wrapper
=
203 new Test_Wrapper
<Test_DynStruct
> (new Test_DynStruct (this->orb_
, debug_
));
204 error_count
= wrapper
->run_test ();
210 Test_Wrapper
<Test_DynUnion
>* wrapper
=
211 new Test_Wrapper
<Test_DynUnion
> (new Test_DynUnion (this->orb_
, debug_
));
212 error_count
= wrapper
->run_test ();