00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "config.h"
00019
00020 #if !defined(DEBUG)
00021 #define DEBUG 1
00022 #endif
00023
00024 #include <assert_pp.h>
00025
00026 #include <timesFile.h>
00027
00028 #include <iostream>
00029
00030 #include <rk_stub.h>
00031
00032 #include <RealTimeTaskImpl.hh>
00033 #include <ManagerImpl.hh>
00034 #include <BasicDelegate.hh>
00035 #include <StrictPolicyImpl.hh>
00036
00037 #include <BasicTaskKernelImpl.h>
00038
00039 #include <StubBasicTaskQosket.hh>
00040 #include <StrictPolicyCallbackImpl.hh>
00041
00042
00043
00044
00045
00046
00047
00048
00049 static int contract_region(quo::Contract_ptr contract,
00050 const char *expected_name)
00051 {
00052 quo::strings_var result;
00053 unsigned int lpc;
00054 int retval = 0;
00055
00056 require(contract != NULL);
00057 require(expected_name != NULL);
00058
00059 contract->eval();
00060
00061 result = contract->getCurrentRegionName();
00062 for( lpc = 0; lpc < result->length(); lpc++ )
00063 {
00064 if( strcmp(result[lpc], expected_name) == 0 )
00065 {
00066 retval = 1;
00067 }
00068 }
00069
00070 return( retval );
00071 }
00072
00073 int main(int argc, char *argv[])
00074 {
00075 int retval = 0;
00076
00077 rk_stub_set_mode(RK_STUB_LOG);
00078
00079 #if defined(HAVE_ACE)
00080
00081 ACE_Log_Msg::instance()->priority_mask(0, ACE_Log_Msg::PROCESS);
00082 #endif
00083
00084
00085 CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
00086 CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
00087
00088 PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj.in());
00089 PortableServer::POAManager_var mgr = root_poa->the_POAManager();
00090 mgr->activate();
00091
00092
00093 Qosket::Basic::BasicTaskKernelImpl *btki;
00094 quo::QuoKernel_var qk;
00095
00096 btki = new Qosket::Basic::BasicTaskKernelImpl(orb);
00097 qk = btki->_this();
00098
00099
00100 StubBasicTaskQosket *btqi;
00101 quo::Contract_var contract;
00102 quo::ValueSC_var last_status;
00103
00104 btqi = new StubBasicTaskQosket();
00105 btqi->initSysconds(qk);
00106 btqi->initCallbacks(orb);
00107 contract = btqi->initContract(qk);
00108
00109 last_status = btqi->LastStatus();
00110
00111
00112 assert(contract_region(contract.in(), "OnTime"));
00113
00114 assert(btqi->btq_Callback->btc_Missed == 0);
00115 assert(btqi->btq_Callback->btc_Made == 1);
00116
00117
00118 last_status->longValue(11);
00119
00120 #if 0
00121
00122 assert(contract_region(contract.in(), "Late"));
00123 assert(btqi->btq_Callback->btc_Missed == 1);
00124 assert(btqi->btq_Callback->btc_Made == 1);
00125
00126
00127 last_status->longValue(10);
00128
00129
00130 assert(contract_region(contract.in(), "OnTime"));
00131 assert(btqi->btq_Callback->btc_Missed == 1);
00132 assert(btqi->btq_Callback->btc_Made == 2);
00133 #endif
00134
00135
00136 assert(tfMakeTimesFile("c1_cpu_times",
00137 (const float[]){
00138 55.0,
00139
00140
00141
00142
00143 TIMES_FILE_TERMINATOR
00144 }));
00145
00146
00147 Broker::Manager_var manager;
00148 ManagerImpl *mi;
00149
00150 mi = new ManagerImpl("dummy");
00151 manager = mi->_this();
00152
00153 BrokerPolicies::StrictPolicy_var policy;
00154 StrictPolicyImpl *spi;
00155
00156 spi = new StrictPolicyImpl("StrictPolicy");
00157 policy = spi->_this();
00158
00159 Qosket::StrictPolicy::StrictPolicyCallback_var spc;
00160 StrictPolicyCallbackImpl *spci;
00161
00162 spci = new StrictPolicyCallbackImpl(policy.in());
00163 spc = spci->_this();
00164
00165 mi->CurrentPolicy(policy.in());
00166
00167 BasicDelegate c1("c1", 10000, 10000);
00168
00169
00170 RealTimeTaskImpl *rtti;
00171
00172
00173 rtti = new RealTimeTaskImpl(c1.bd_TaskDescription);
00174 c1.bd_Advocate = Broker::RealTimeTask::_narrow(rtti->_this());
00175 assert(!CORBA::is_nil(c1.bd_Advocate.in()));
00176 manager->AddTask(c1.bd_Advocate.in(), c1.bd_CPUSchedule);
00177
00178 assert(spc->GetPriorityOf("c1") == 0);
00179
00180 spc->SetPriorityOf("c1", 5);
00181
00182 assert(spc->GetPriorityOf("c1") == 5);
00183
00184 try
00185 {
00186 spc->GetPriorityOf("c2");
00187
00188 ensure(0);
00189 }
00190 catch(const CORBA::BAD_PARAM &e)
00191 {
00192 }
00193
00194 return( retval );
00195 }