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 <iostream>
00027
00028 #include <rk_stub.h>
00029
00030 #include <BasicTaskKernelImpl.h>
00031
00032 #include <StubBasicTaskQosket.hh>
00033
00034
00035
00036
00037
00038
00039
00040
00041 static int contract_region(quo::Contract_ptr contract,
00042 const char *expected_name)
00043 {
00044 quo::strings_var result;
00045 unsigned int lpc;
00046 int retval = 0;
00047
00048 require(contract != NULL);
00049 require(expected_name != NULL);
00050
00051 contract->eval();
00052
00053 result = contract->getCurrentRegionName();
00054 for( lpc = 0; lpc < result->length(); lpc++ )
00055 {
00056 if( strcmp(result[lpc], expected_name) == 0 )
00057 {
00058 retval = 1;
00059 }
00060 }
00061
00062 return( retval );
00063 }
00064
00065 int main(int argc, char *argv[])
00066 {
00067 int retval = 0;
00068
00069 rk_stub_set_mode(RK_STUB_LOG);
00070
00071 #if defined(HAVE_ACE)
00072
00073 ACE_Log_Msg::instance()->priority_mask(0, ACE_Log_Msg::PROCESS);
00074 #endif
00075
00076
00077 CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
00078 CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
00079
00080 PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj.in());
00081 PortableServer::POAManager_var mgr = root_poa->the_POAManager();
00082 mgr->activate();
00083
00084
00085 Qosket::Basic::BasicTaskKernelImpl *btki;
00086 quo::QuoKernel_var qk;
00087
00088 btki = new Qosket::Basic::BasicTaskKernelImpl(orb);
00089 qk = btki->_this();
00090
00091
00092 StubBasicTaskQosket *btqi;
00093 quo::Contract_var contract;
00094 quo::ValueSC_var last_status;
00095
00096 btqi = new StubBasicTaskQosket();
00097 btqi->initSysconds(qk);
00098 btqi->initCallbacks(orb);
00099 contract = btqi->initContract(qk);
00100
00101 last_status = btqi->LastStatus();
00102
00103
00104 assert(contract_region(contract.in(), "OnTime"));
00105
00106 assert(btqi->btq_Callback->btc_Missed == 0);
00107 assert(btqi->btq_Callback->btc_Made == 1);
00108
00109
00110 last_status->longValue(11);
00111
00112 #if 0
00113
00114 assert(contract_region(contract.in(), "Late"));
00115 assert(btqi->btq_Callback->btc_Missed == 1);
00116 assert(btqi->btq_Callback->btc_Made == 1);
00117
00118
00119 last_status->longValue(10);
00120
00121
00122 assert(contract_region(contract.in(), "OnTime"));
00123 assert(btqi->btq_Callback->btc_Missed == 1);
00124 assert(btqi->btq_Callback->btc_Made == 2);
00125 #endif
00126
00127 return( retval );
00128 }