1 #include "../Scheduler.h"
2 #include "tao/RTScheduling/RTScheduler_Manager.h"
4 #include "ace/Get_Opt.h"
5 #include "ace/OS_NS_stdio.h"
7 const ACE_TCHAR
* filename
= ACE_TEXT("test.ior");
9 class test_impl
: public POA_test
12 test_impl (CORBA::ORB_ptr orb
,
13 RTScheduling::Current_ptr current
)
15 current_ (RTScheduling::Current::_duplicate (current
))
19 virtual void one_way (const char * message
)
22 "One-Way Message = %s\n",
26 virtual char * two_way (const char * message
)
29 "Two-Way Message = %s\n",
32 RTScheduling::Current::IdType_var id
= this->current_
->id ();
33 RTScheduling::DistributableThread_var DT
=
34 this->current_
->lookup (id
.in ());
38 return CORBA::string_dup (message
);
41 //FUZZ: disable check_for_lack_ACE_OS
42 virtual void shutdown ()
46 //FUZZ: enable check_for_lack_ACE_OS
50 RTScheduling::Current_var current_
;
57 // Parse command line arguments
58 ACE_Get_Opt
opts (argc
, argv
, ACE_TEXT("f:"));
61 while ((c
= opts ()) != -1)
66 filename
= opts
.opt_arg ();
69 ACE_DEBUG ((LM_DEBUG
, "Unknown Option\n"));
77 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
82 CORBA::ORB_init (argc
,
85 parse_args (argc
, argv
);
87 CORBA::Object_var object
=
88 orb
->resolve_initial_references ("RootPOA");
90 PortableServer::POA_var root_poa
=
91 PortableServer::POA::_narrow (object
.in ());
93 PortableServer::POAManager_var poa_manager
=
94 root_poa
->the_POAManager ();
96 poa_manager
->activate ();
98 CORBA::Object_var current_obj
= orb
->resolve_initial_references ("RTScheduler_Current");
100 RTScheduling::Current_var current
= RTScheduling::Current::_narrow (current_obj
.in ());
103 ACE_NEW_RETURN (test_i
,
104 test_impl (orb
.in (),
107 PortableServer::ServantBase_var
safe (test_i
);
109 PortableServer::ObjectId_var id
;
111 id
= root_poa
->activate_object (test_i
);
113 CORBA::Object_var server
=
114 root_poa
->id_to_reference (id
.in ());
116 CORBA::String_var ior
;
117 if (!CORBA::is_nil (server
.in ()))
119 ior
= orb
->object_to_string (server
.in ());
123 ACE_ERROR_RETURN ((LM_ERROR
,
124 "Failed to activate test object\n"),
128 ACE_DEBUG ((LM_DEBUG
,
132 CORBA::Object_var manager_obj
= orb
->resolve_initial_references ("RTSchedulerManager");
134 TAO_RTScheduler_Manager_var manager
= TAO_RTScheduler_Manager::_narrow (manager_obj
.in ());
136 TAO_Scheduler
scheduler (orb
.in ());
137 manager
->rtscheduler (&scheduler
);
139 // Print ior to the file.
142 FILE* output_file
= ACE_OS::fopen (filename
, "w");
143 if (output_file
== 0)
144 ACE_ERROR_RETURN ((LM_ERROR
,
145 "Cannot open output file for writing IOR: %s",
148 ACE_OS::fprintf (output_file
, "%s", ior
.in ());
149 ACE_OS::fclose (output_file
);
156 catch (const CORBA::Exception
& ex
)
158 ex
._tao_print_exception ("Caught exception:");