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
),
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"),
93 catch (const CORBA::Exception
& ex
)
95 ex
._tao_print_exception ("Driver::init");
103 Driver::parse_args (int argc
, ACE_TCHAR
*argv
[])
106 ACE_ERROR_RETURN ((LM_ERROR
,
108 " -t [dynany|dynarray|dynenum|dynsequence|dynstruct|dynunion]\n"
113 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("t:d"));
115 const ACE_TCHAR
*test_str
= 0;
117 while ((c
= get_opts ()) != -1)
121 test_str
= get_opts
.opt_arg ();
123 if (!ACE_OS::strcmp (test_str
, ACE_TEXT ("dynany")))
124 this->test_type_
= TEST_DYNANY
;
125 else if (!ACE_OS::strcmp (test_str
, ACE_TEXT ("dynarray")))
126 this->test_type_
= TEST_DYNARRAY
;
127 else if (!ACE_OS::strcmp (test_str
, ACE_TEXT ("dynenum")))
128 this->test_type_
= TEST_DYNENUM
;
129 else if (!ACE_OS::strcmp (test_str
, ACE_TEXT ("dynsequence")))
130 this->test_type_
= TEST_DYNSEQUENCE
;
131 else if (!ACE_OS::strcmp (test_str
, ACE_TEXT ("dynstruct")))
132 this->test_type_
= TEST_DYNSTRUCT
;
133 else if (!ACE_OS::strcmp (test_str
, ACE_TEXT ("dynunion")))
134 this->test_type_
= TEST_DYNUNION
;
136 ACE_DEBUG ((LM_DEBUG
,
137 "I don't recognize test type %s\n",
147 ACE_ERROR_RETURN ((LM_ERROR
,
149 " -t [dynany|dynarray|dynenum|dynsequence|dynstruct|dynunion]"
156 // Indicates successful parsing of command line.
165 switch (this->test_type_
)
169 Test_Wrapper
<Test_DynAny
>* wrapper
=
170 new Test_Wrapper
<Test_DynAny
> (new Test_DynAny (this->orb_
, debug_
));
171 error_count
= wrapper
->run_test ();
177 Test_Wrapper
<Test_DynArray
>* wrapper
=
178 new Test_Wrapper
<Test_DynArray
> (new Test_DynArray (this->orb_
, debug_
));
179 error_count
= wrapper
->run_test ();
185 Test_Wrapper
<Test_DynEnum
>* wrapper
=
186 new Test_Wrapper
<Test_DynEnum
> (new Test_DynEnum (this->orb_
, debug_
));
187 error_count
= wrapper
->run_test ();
191 case TEST_DYNSEQUENCE
:
193 Test_Wrapper
<Test_DynSequence
>* wrapper
=
194 new Test_Wrapper
<Test_DynSequence
> (new Test_DynSequence (this->orb_
, debug_
));
195 error_count
= wrapper
->run_test ();
201 Test_Wrapper
<Test_DynStruct
>* wrapper
=
202 new Test_Wrapper
<Test_DynStruct
> (new Test_DynStruct (this->orb_
, debug_
));
203 error_count
= wrapper
->run_test ();
209 Test_Wrapper
<Test_DynUnion
>* wrapper
=
210 new Test_Wrapper
<Test_DynUnion
> (new Test_DynUnion (this->orb_
, debug_
));
211 error_count
= wrapper
->run_test ();