1 // Regression test Bug 2234
3 // The bug manifests itself in the server.
6 #include "ace/Get_Opt.h"
7 #include "ace/OS_NS_string.h"
9 const ACE_TCHAR
*ior
= ACE_TEXT ("file://test.ior");
12 parse_args (int argc
, ACE_TCHAR
*argv
[])
14 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:"));
17 while ((c
= get_opts ()) != -1)
21 ior
= get_opts
.opt_arg ();
26 ACE_ERROR_RETURN ((LM_ERROR
,
33 // Indicates successful parsing of the command line
43 CORBA::Boolean testFailed
= 0;
44 ACE_DEBUG( (LM_INFO
, "Regression test for Bug 2234 (Interceptor arg list with var len out params)\n"));
48 orb
= CORBA::ORB_init (argc
, argv
);
50 if (parse_args (argc
, argv
) != 0)
54 object
= orb
->string_to_object( ior
);
56 foo
= Test::Foo::_narrow( object
.in() );
58 //-----------------------------------------------------------------------
64 ACE_DEBUG( (LM_INFO
, ". Long() ") );
65 rL
= foo
->TestLong( aL
, bL
, cL
);
66 ACE_DEBUG( (LM_INFO
, "a is %d, b is %d, c is %d, r is %d: ", aL
, bL
, cL
, rL
) );
67 if (static_cast<CORBA::Long
>(1) != aL
) {
68 ACE_DEBUG( (LM_ERROR
, "a is wrong\n") ); testFailed
= 1;}
69 else if (static_cast<CORBA::Long
>(2) != bL
) {
70 ACE_DEBUG( (LM_ERROR
, "b is wrong\n") ); testFailed
= 1;}
71 else if (static_cast<CORBA::Long
>(4) != cL
) {
72 ACE_DEBUG( (LM_ERROR
, "c is wrong\n") ); testFailed
= 1;}
73 else if (static_cast<CORBA::Long
>(7) != rL
) {
74 ACE_DEBUG( (LM_ERROR
, "r is wrong\n") ); testFailed
= 1;}
76 ACE_DEBUG( (LM_INFO
, "OK\n") );
78 //-----------------------------------------------------------------------
80 aS
= CORBA::string_dup("1"),
82 cS
= CORBA::string_dup("3"),
84 ACE_DEBUG( (LM_INFO
, ". String() ") );
85 rS
= foo
->TestString( aS
.in(), bS
.out(), cS
.inout());
86 ACE_DEBUG( (LM_INFO
, "a is %C, b is %C, c is %C, r is %C: ", aS
.in (), bS
.in (), cS
.in (), rS
.in ()));
87 if ((0 != *aS
.in()) && (0 != ACE_OS::strcmp(aS
.in(), "1"))) {
88 ACE_DEBUG( (LM_ERROR
, "a is wrong\n") ); testFailed
= 1;}
89 else if ((0 != *aS
.in()) && (0 != ACE_OS::strcmp(bS
.in(), "2"))) {
90 ACE_DEBUG( (LM_ERROR
, "b is wrong\n") ); testFailed
= 1;}
91 else if ((0 != *aS
.in()) && (0 != ACE_OS::strcmp(cS
.in(), "4"))) {
92 ACE_DEBUG( (LM_ERROR
, "c is wrong\n") ); testFailed
= 1;}
93 else if ((0 != *aS
.in()) && (0 != ACE_OS::strcmp(rS
.in(), "7"))) {
94 ACE_DEBUG( (LM_ERROR
, "r is wrong\n") ); testFailed
= 1;}
96 ACE_DEBUG( (LM_INFO
, "OK\n") );
98 //-----------------------------------------------------------------------
99 Test::MyNonVarStruct_var
100 aFS
= new Test::MyNonVarStruct(),
101 bFS
= new Test::MyNonVarStruct(),
102 cFS
= new Test::MyNonVarStruct(),
106 ACE_DEBUG( (LM_INFO
, ". MyNonVarStruct() ") );
107 rFS
= foo
->TestNonVarStruct( aFS
.in(), bFS
.out(), cFS
.inout());
108 ACE_DEBUG( (LM_INFO
, "a is %d, b is %d, c is %d, r is %d: ", aFS
.in().val
, bFS
.in().val
, cFS
.in().val
, rFS
.in().val
) );
109 if (static_cast<CORBA::Long
>(1) != aFS
->val
) {
110 ACE_DEBUG( (LM_ERROR
, "a is wrong\n") ); testFailed
= 1;}
111 else if (static_cast<CORBA::Long
>(2) != bFS
->val
) {
112 ACE_DEBUG( (LM_ERROR
, "b is wrong\n") ); testFailed
= 1;}
113 else if (static_cast<CORBA::Long
>(4) != cFS
->val
) {
114 ACE_DEBUG( (LM_ERROR
, "c is wrong\n") ); testFailed
= 1;}
115 else if (static_cast<CORBA::Long
>(7) != rFS
->val
) {
116 ACE_DEBUG( (LM_ERROR
, "r is wrong\n") ); testFailed
= 1;}
118 ACE_DEBUG( (LM_INFO
, "OK\n") );
120 //-----------------------------------------------------------------------
121 Test::MyVarStruct_var
122 aVS
= new Test::MyVarStruct(),
124 cVS
= new Test::MyVarStruct(),
126 aVS
->val
= CORBA::string_dup("1");
127 cVS
->val
= CORBA::string_dup("3");
128 ACE_DEBUG( (LM_INFO
, ". MyVarStruct() ") );
129 rVS
= foo
->TestVarStruct( aVS
.in(), bVS
.out(), cVS
.inout());
130 ACE_DEBUG( (LM_INFO
, "a is %C, b is %C, c is %C, r is %C: ", aVS
->val
.in(), bVS
->val
.in (), cVS
->val
.in (), rVS
->val
.in ()));
131 if ((0 != *aVS
->val
) && (0 != ACE_OS::strcmp(aVS
->val
, "1"))) {
132 ACE_DEBUG( (LM_ERROR
, "a is wrong\n") ); testFailed
= 1;}
133 else if ((0 != *bVS
->val
) && (0 != ACE_OS::strcmp(bVS
->val
, "2"))) {
134 ACE_DEBUG( (LM_ERROR
, "b is wrong\n") ); testFailed
= 1;}
135 else if ((0 != *cVS
->val
) && (0 != ACE_OS::strcmp(cVS
->val
, "4"))) {
136 ACE_DEBUG( (LM_ERROR
, "c is wrong\n") ); testFailed
= 1;}
137 else if ((0 != *rVS
->val
) && (0 != ACE_OS::strcmp(rVS
->val
, "7"))) {
138 ACE_DEBUG( (LM_ERROR
, "r is wrong\n") ); testFailed
= 1;}
140 ACE_DEBUG( (LM_INFO
, "OK\n") );
142 //-----------------------------------------------------------------------
143 Test::MyNonVarUnion_var
144 aFU
= new Test::MyNonVarUnion(),
145 bFU
= new Test::MyNonVarUnion(),
146 cFU
= new Test::MyNonVarUnion(),
148 aFU
->valLong( static_cast<CORBA::Long
>(1) );
149 cFU
->valLong( static_cast<CORBA::Long
>(3) );
150 ACE_DEBUG( (LM_INFO
, ". MyNonVarUnion() ") );
151 rFU
= foo
->TestNonVarUnion( aFU
.in(), bFU
.out(), cFU
.inout());
152 ACE_DEBUG( (LM_INFO
, "a is ") );
153 if (static_cast<CORBA::Short
>(1) != aFU
->_d())
154 ACE_DEBUG( (LM_INFO
, "?") );
156 ACE_DEBUG( (LM_INFO
, "%d", aFU
->valLong()) );
157 ACE_DEBUG( (LM_INFO
, ", b is ") );
158 if (static_cast<CORBA::Short
>(1) != bFU
->_d())
159 ACE_DEBUG( (LM_INFO
, "?") );
161 ACE_DEBUG( (LM_INFO
, "%d", bFU
->valLong()) );
162 ACE_DEBUG( (LM_INFO
, ", c is ") );
163 if (static_cast<CORBA::Short
>(1) != cFU
->_d())
164 ACE_DEBUG( (LM_INFO
, "?") );
166 ACE_DEBUG( (LM_INFO
, "%d", cFU
->valLong()) );
167 ACE_DEBUG( (LM_INFO
, ", r is ") );
168 if (static_cast<CORBA::Short
>(1) != rFU
->_d())
169 ACE_DEBUG( (LM_INFO
, "?") );
171 ACE_DEBUG( (LM_INFO
, "%d", rFU
->valLong()) );
172 ACE_DEBUG( (LM_INFO
, ": ") );
173 if ((static_cast<CORBA::Short
>(1) != aFU
->_d()) || (static_cast<CORBA::Long
>(1) != aFU
->valLong())) {
174 ACE_DEBUG( (LM_ERROR
, "a is wrong\n") ); testFailed
= 1;}
175 else if ((static_cast<CORBA::Short
>(1) != bFU
->_d()) || (static_cast<CORBA::Long
>(2) != bFU
->valLong())) {
176 ACE_DEBUG( (LM_ERROR
, "b is wrong\n") ); testFailed
= 1;}
177 else if ((static_cast<CORBA::Short
>(1) != cFU
->_d()) || (static_cast<CORBA::Long
>(4) != cFU
->valLong())) {
178 ACE_DEBUG( (LM_ERROR
, "c is wrong\n") ); testFailed
= 1;}
179 else if ((static_cast<CORBA::Short
>(1) != rFU
->_d()) || (static_cast<CORBA::Long
>(7) != rFU
->valLong())) {
180 ACE_DEBUG( (LM_ERROR
, "r is wrong\n") ); testFailed
= 1;}
182 ACE_DEBUG( (LM_INFO
, "OK\n") );
184 //-----------------------------------------------------------------------
186 aVU
= new Test::MyVarUnion(),
188 cVU
= new Test::MyVarUnion(),
190 aVU
->valLong( static_cast<CORBA::Long
>(1) );
191 cVU
->valLong( static_cast<CORBA::Long
>(3) );
192 ACE_DEBUG( (LM_INFO
, ". MyVarUnion() ") );
193 rVU
= foo
->TestVarUnion( aVU
.in(), bVU
.out(), cVU
.inout());
194 ACE_DEBUG( (LM_INFO
, "a is ") );
195 if (static_cast<CORBA::Short
>(1) != aVU
->_d())
196 ACE_DEBUG( (LM_INFO
, "?") );
198 ACE_DEBUG( (LM_INFO
, "%d", aVU
->valLong()) );
199 ACE_DEBUG( (LM_INFO
, ", b is ") );
200 if (static_cast<CORBA::Short
>(1) != bVU
->_d())
201 ACE_DEBUG( (LM_INFO
, "?") );
203 ACE_DEBUG( (LM_INFO
, "%d", bVU
->valLong()) );
204 ACE_DEBUG( (LM_INFO
, ", c is ") );
205 if (static_cast<CORBA::Short
>(1) != cVU
->_d())
206 ACE_DEBUG( (LM_INFO
, "?") );
208 ACE_DEBUG( (LM_INFO
, "%d", cVU
->valLong()) );
209 ACE_DEBUG( (LM_INFO
, ", r is ") );
210 if (static_cast<CORBA::Short
>(1) != rVU
->_d())
211 ACE_DEBUG( (LM_INFO
, "?") );
213 ACE_DEBUG( (LM_INFO
, "%d", rVU
->valLong()) );
214 ACE_DEBUG( (LM_INFO
, ": ") );
215 if ((static_cast<CORBA::Short
>(1) != aVU
->_d()) || (static_cast<CORBA::Long
>(1) != aVU
->valLong())) {
216 ACE_DEBUG( (LM_ERROR
, "a is wrong\n") ); testFailed
= 1;}
217 else if ((static_cast<CORBA::Short
>(1) != bVU
->_d()) || (static_cast<CORBA::Long
>(2) != bVU
->valLong())) {
218 ACE_DEBUG( (LM_ERROR
, "b is wrong\n") ); testFailed
= 1;}
219 else if ((static_cast<CORBA::Short
>(1) != cVU
->_d()) || (static_cast<CORBA::Long
>(4) != cVU
->valLong())) {
220 ACE_DEBUG( (LM_ERROR
, "c is wrong\n") ); testFailed
= 1;}
221 else if ((static_cast<CORBA::Short
>(1) != rVU
->_d()) || (static_cast<CORBA::Long
>(7) != rVU
->valLong())) {
222 ACE_DEBUG( (LM_ERROR
, "r is wrong\n") ); testFailed
= 1;}
224 ACE_DEBUG( (LM_INFO
, "OK\n") );
226 //-----------------------------------------------------------------------
227 Test::MySeqOfLong_var
228 aSL
= new Test::MySeqOfLong(1),
230 cSL
= new Test::MySeqOfLong(1),
233 aSL
[0]= static_cast<CORBA::Long
>(1);
235 cSL
[0]= static_cast<CORBA::Long
>(3);
236 ACE_DEBUG( (LM_INFO
, ". MySeqOfLong() ") );
237 rSL
= foo
->TestSeqOfLong( aSL
.in(), bSL
.out(), cSL
.inout());
238 ACE_DEBUG( (LM_INFO
, "a is ") );
239 if (1u != aSL
->length())
240 ACE_DEBUG( (LM_INFO
, "?") );
242 ACE_DEBUG( (LM_INFO
, "%d", aSL
[0]) );
243 ACE_DEBUG( (LM_INFO
, ", b is ") );
244 if (1u != bSL
->length())
245 ACE_DEBUG( (LM_INFO
, "?") );
247 ACE_DEBUG( (LM_INFO
, "%d", bSL
[0]) );
248 ACE_DEBUG( (LM_INFO
, ", c is ") );
249 if (1u != cSL
->length())
250 ACE_DEBUG( (LM_INFO
, "?") );
252 ACE_DEBUG( (LM_INFO
, "%d", cSL
[0]) );
253 ACE_DEBUG( (LM_INFO
, ", r is ") );
254 if (1u != rSL
->length())
255 ACE_DEBUG( (LM_INFO
, "?") );
257 ACE_DEBUG( (LM_INFO
, "%d", rSL
[0]) );
258 ACE_DEBUG( (LM_INFO
, ": ") );
259 if ((1u != aSL
->length()) || (static_cast<CORBA::Long
>(1) != aSL
[0])) {
260 ACE_DEBUG( (LM_ERROR
, "a is wrong\n") ); testFailed
= 1;}
261 else if ((1u != bSL
->length()) || (static_cast<CORBA::Long
>(2) != bSL
[0])) {
262 ACE_DEBUG( (LM_ERROR
, "b is wrong\n") ); testFailed
= 1;}
263 else if ((1u != cSL
->length()) || (static_cast<CORBA::Long
>(4) != cSL
[0])) {
264 ACE_DEBUG( (LM_ERROR
, "c is wrong\n") ); testFailed
= 1;}
265 else if ((1u != rSL
->length()) || (static_cast<CORBA::Long
>(7) != rSL
[0])) {
266 ACE_DEBUG( (LM_ERROR
, "r is wrong\n") ); testFailed
= 1;}
268 ACE_DEBUG( (LM_INFO
, "OK\n") );
270 //-----------------------------------------------------------------------
272 aA
= new CORBA::Any(),
274 cA
= new CORBA::Any(),
276 aA
<<= static_cast<CORBA::Long
>(1);
277 cA
<<= static_cast<CORBA::Long
>(3);
278 ACE_DEBUG( (LM_INFO
, ". Any() ") );
279 rA
= foo
->TestAny( aA
.in(), bA
.out(), cA
.inout());
285 ACE_DEBUG( (LM_INFO
, "a is ") );
286 if (0 != (aB
= (aA
>>= aL
)))
287 ACE_DEBUG( (LM_INFO
, "%d", aL
) );
289 ACE_DEBUG( (LM_INFO
, "?") );
290 ACE_DEBUG( (LM_INFO
, ", b is ") );
291 if (0 != (bB
= (bA
>>= bL
)))
292 ACE_DEBUG( (LM_INFO
, "%d", bL
) );
294 ACE_DEBUG( (LM_INFO
, "?") );
295 ACE_DEBUG( (LM_INFO
, ", c is ") );
296 if (0 != (cB
= (cA
>>= cL
)))
297 ACE_DEBUG( (LM_INFO
, "%d", cL
) );
299 ACE_DEBUG( (LM_INFO
, "?") );
300 ACE_DEBUG( (LM_INFO
, ", r is ") );
301 if (0 != (rB
= (rA
>>= rL
)))
302 ACE_DEBUG( (LM_INFO
, "%d", rL
) );
304 ACE_DEBUG( (LM_INFO
, "?") );
305 ACE_DEBUG( (LM_INFO
, ": ") );
306 if (!aB
|| (static_cast<CORBA::Long
>(1) != aL
)) {
307 ACE_DEBUG( (LM_ERROR
, "a is wrong\n") ); testFailed
= 1;}
308 else if (!bB
|| (static_cast<CORBA::Long
>(2) != bL
)) {
309 ACE_DEBUG( (LM_ERROR
, "b is wrong\n") ); testFailed
= 1;}
310 else if (!cB
|| (static_cast<CORBA::Long
>(4) != cL
)) {
311 ACE_DEBUG( (LM_ERROR
, "c is wrong\n") ); testFailed
= 1;}
312 else if (!rB
|| (static_cast<CORBA::Long
>(7) != rL
)) {
313 ACE_DEBUG( (LM_ERROR
, "r is wrong\n") ); testFailed
= 1;}
315 ACE_DEBUG( (LM_INFO
, "OK\n") );
317 //-----------------------------------------------------------------------
325 Test::MyArray_var arr_b
;
333 ACE_DEBUG( (LM_INFO
, ". MyArray() ") );
334 Test::MyArray_var arr_ret
= foo
->TestArray (arr_a
, arr_b
.out (), arr_c
);
335 CORBA::ULong
zero (0), one (1); //Use ULong to avoid ambiguity
336 if (arr_c
[0].length () != 1 || arr_c
[0][0] != 24)
338 ACE_DEBUG( (LM_ERROR
, "arr_c[0] is wrong\n") ); testFailed
= 1;
340 else if (arr_c
[1].length () != 1 || arr_c
[1][0] != 10)
342 ACE_DEBUG( (LM_ERROR
, "arr_c[1] is wrong\n") ); testFailed
= 1;
344 else if (arr_b
[zero
].length () != 1 || arr_b
[zero
][0] != 8)
346 ACE_DEBUG( (LM_ERROR
, "arr_b[0] is wrong\n") ); testFailed
= 1;
348 else if (arr_b
[one
].length () != 1 || arr_b
[one
][0] != 22)
350 ACE_DEBUG( (LM_ERROR
, "arr_b[1] is wrong\n") ); testFailed
= 1;
352 else if (arr_ret
[zero
].length () != 1 || arr_ret
[zero
][0] != 7)
354 ACE_DEBUG( (LM_ERROR
, "arr_ret[0] is wrong\n") ); testFailed
= 1;
356 else if (arr_ret
[one
].length () != 1 || arr_ret
[one
][0] != 21)
358 ACE_DEBUG( (LM_ERROR
, "arr_ret[1] is wrong\n") ); testFailed
= 1;
361 ACE_DEBUG( (LM_INFO
, "OK\n") );
364 //-----------------------------------------------------------------------
366 CORBA::Object_var a
= CORBA::Object::_duplicate (foo
.in ());
368 CORBA::Object_var c
= CORBA::Object::_duplicate (a
.in ());
369 CORBA::Object_var ret
= foo
->TestObject (a
.in (), b
.out (), c
.inout ());
372 //-----------------------------------------------------------------------
373 foo
->ShutdownServer( );
375 //-----------------------------------------------------------------------
376 orb
->shutdown( true );
379 catch (const CORBA::SystemException
& ex
)
381 ex
._tao_print_exception ("CORBA::SystemException: ");
384 catch (const CORBA::Exception
& ex
)
386 ex
._tao_print_exception ("CORBA::Exception: ");
391 ACE_DEBUG( (LM_ERROR
, "Unexpected general exception!\n") );
395 ACE_DEBUG( (LM_INFO
, "Regression test for Bug 2234 ") );
397 ACE_DEBUG( (LM_ERROR
, "Failed\n") );
399 ACE_DEBUG( (LM_INFO
, "Passed\n") );
401 return testFailed
? -1 : 0;