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
13 test_impl (CORBA::ORB_ptr orb
,
14 RTScheduling::Current_ptr current
)
16 current_ (RTScheduling::Current::_duplicate (current
))
20 virtual void one_way (const char * message
)
23 "One-Way Message = %s\n",
27 virtual char * two_way (const char * message
)
30 "Two-Way Message = %s\n",
33 RTScheduling::Current::IdType_var id
= this->current_
->id ();
34 RTScheduling::DistributableThread_var DT
=
35 this->current_
->lookup (id
.in ());
39 return CORBA::string_dup (message
);
42 //FUZZ: disable check_for_lack_ACE_OS
43 virtual void shutdown (void)
47 //FUZZ: enable check_for_lack_ACE_OS
51 RTScheduling::Current_var current_
;
58 // Parse command line arguments
59 ACE_Get_Opt
opts (argc
, argv
, ACE_TEXT("f:"));
62 while ((c
= opts ()) != -1)
67 filename
= opts
.opt_arg ();
70 ACE_DEBUG ((LM_DEBUG
, "Unknown Option\n"));
78 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
83 CORBA::ORB_init (argc
,
86 parse_args (argc
, argv
);
88 CORBA::Object_var object
=
89 orb
->resolve_initial_references ("RootPOA");
91 PortableServer::POA_var root_poa
=
92 PortableServer::POA::_narrow (object
.in ());
94 PortableServer::POAManager_var poa_manager
=
95 root_poa
->the_POAManager ();
97 poa_manager
->activate ();
99 CORBA::Object_var current_obj
= orb
->resolve_initial_references ("RTScheduler_Current");
101 RTScheduling::Current_var current
= RTScheduling::Current::_narrow (current_obj
.in ());
104 ACE_NEW_RETURN (test_i
,
105 test_impl (orb
.in (),
108 PortableServer::ServantBase_var
safe (test_i
);
110 PortableServer::ObjectId_var id
;
112 id
= root_poa
->activate_object (test_i
);
114 CORBA::Object_var server
=
115 root_poa
->id_to_reference (id
.in ());
117 CORBA::String_var ior
;
118 if (!CORBA::is_nil (server
.in ()))
120 ior
= orb
->object_to_string (server
.in ());
124 ACE_ERROR_RETURN ((LM_ERROR
,
125 "Failed to activate test object\n"),
129 ACE_DEBUG ((LM_DEBUG
,
133 CORBA::Object_var manager_obj
= orb
->resolve_initial_references ("RTSchedulerManager");
135 TAO_RTScheduler_Manager_var manager
= TAO_RTScheduler_Manager::_narrow (manager_obj
.in ());
137 TAO_Scheduler
scheduler (orb
.in ());
138 manager
->rtscheduler (&scheduler
);
140 // Print ior to the file.
143 FILE* output_file
= ACE_OS::fopen (filename
, "w");
144 if (output_file
== 0)
145 ACE_ERROR_RETURN ((LM_ERROR
,
146 "Cannot open output file for writing IOR: %s",
149 ACE_OS::fprintf (output_file
, "%s", ior
.in ());
150 ACE_OS::fclose (output_file
);
157 catch (const CORBA::Exception
& ex
)
159 ex
._tao_print_exception ("Caught exception:");