1 #include "tao/ORB_Core.h"
2 #include "tao/RTCORBA/RTCORBA.h"
3 #include "tao/RTCORBA/Priority_Mapping_Manager.h"
4 #include "ace/Get_Opt.h"
7 ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
11 ACE_DEBUG ((LM_DEBUG
, "Testing : "));
13 for (int arg_i
= 0; arg_i
< argc
; ++arg_i
)
15 ACE_DEBUG ((LM_DEBUG
, "%s ", argv
[arg_i
]));
18 ACE_DEBUG ((LM_DEBUG
, "\n\n"));
23 CORBA::ORB_init (argc
, argv
);
25 CORBA::Object_var object
=
26 orb
->resolve_initial_references ("RTCurrent");
28 RTCORBA::Current_var current
=
29 RTCORBA::Current::_narrow (object
.in ());
31 object
= orb
->resolve_initial_references ("PriorityMappingManager");
33 RTCORBA::PriorityMappingManager_var mapping_manager
=
34 RTCORBA::PriorityMappingManager::_narrow (object
.in ());
36 RTCORBA::PriorityMapping
*pm
=
37 mapping_manager
->mapping ();
39 ACE_DEBUG ((LM_DEBUG
, "Testing part #1\n\n"));
41 // Check for this priority mapping that we are kosher
42 RTCORBA::Priority i
= RTCORBA::minPriority
;
45 CORBA::Short native1
= -1, corba1
= -1, native2
= -1, corba2
= -1;
47 if (pm
->to_native (i
, native1
))
49 if (! (pm
->to_CORBA (native1
, corba1
) &&
50 pm
->to_native (corba1
, native2
) &&
51 pm
->to_CORBA (native2
, corba2
)))
53 ACE_DEBUG ((LM_DEBUG
, "ERROR : Mapping reported false during CORBA %d -> Native %d -> CORBA %d -> Native %d\n",
60 else if (! (corba2
== corba1
&& native1
== native2
))
63 ACE_DEBUG ((LM_DEBUG
, "ERROR - Not idem-thingy. Mapping went: CORBA %d -> Native %d -> CORBA %d -> Native %d - CORBA %d\n",
73 i
= i
+ 1; // There's a reason to not use unary increment
75 while (i
!= RTCORBA::minPriority
);
77 ACE_DEBUG ((LM_DEBUG
, "\n\nTesting part #2\n\n"));
79 // Accessing the priority when it hasn't been set should throw an exception
82 i
= current
->the_priority ();
83 ACE_DEBUG ((LM_DEBUG
, "ERROR: Unexpectedly was able to access thread CORBA priority of %d when it hadn't been set\n", i
));
86 catch (const CORBA::INITIALIZE
&)
88 // This is what should happen
90 catch (const CORBA::Exception
& ex
)
92 ex
._tao_print_exception ("ERROR: Unexpected exception type accessing thread CORBA priority when it hadn't been set: ");
97 ACE_DEBUG ((LM_DEBUG
, "ERROR: Wildly unexpected exception type accessing thread CORBA priority when it hadn't been set\n", i
));
101 ACE_DEBUG ((LM_DEBUG
, "\nTesting part #3\n\n"));
103 // Setting an invalid CORBA priority should generate a BAD_PARAM if the mapping has rejected it
106 current
->the_priority (-1);
107 ACE_DEBUG ((LM_DEBUG
, "ERROR: Unexpectedly was able to set a thread CORBA priority\n"));
110 catch (const CORBA::BAD_PARAM
&)
112 // This is what should happen
114 catch (const CORBA::Exception
& ex
)
116 ex
._tao_print_exception ("ERROR: Unexpected exception type setting an invalid CORBA priority");
121 ACE_DEBUG ((LM_DEBUG
, "ERROR: Wildly unexpected exception setting an invalid CORBA priority\n"));
125 catch (const CORBA::Exception
& ex
)
127 ex
._tao_print_exception ("ERROR: Unexpected exception ");
132 ACE_DEBUG ((LM_DEBUG
, "ERROR: Unknown exception\n"));