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.h>
00025 #include <assert_pp.h>
00026
00027 #include <BrokerC.h>
00028 #include <ManagerImpl.hh>
00029
00030 #include <StubTask.hh>
00031
00032 struct {
00033 int verbose;
00034 } args = {
00035 1,
00036 };
00037
00038
00039
00040
00041
00042
00043
00044 #define expect_catch(BLOCK, EXCEPTION) \
00045 { \
00046 try \
00047 { \
00048 BLOCK; \
00049 ensure(0); \
00050 } \
00051 catch(const EXCEPTION &_e) \
00052 { \
00053 if( args.verbose ) \
00054 { \
00055 cerr << "Tried \"" \
00056 << __STRING(BLOCK) \
00057 << "\" at line " \
00058 << __LINE__ \
00059 << " and got expected exception \"" \
00060 << _e \
00061 << "\"" \
00062 << endl; \
00063 } \
00064 } \
00065 }
00066
00067 #if defined(BLOCK_ON_SEGV)
00068 static void sigloop(int sig)
00069 {
00070 for( ;; )
00071 {
00072 sleep(5);
00073 }
00074 }
00075 #endif
00076
00077 int main(int argc, char *argv[])
00078 {
00079 int retval = EXIT_SUCCESS;
00080
00081 #if defined(BLOCK_ON_SEGV)
00082 signal(SIGSEGV, sigloop);
00083 #endif
00084
00085
00086 CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
00087
00088 CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
00089
00090 PortableServer::POA_var root_poa =
00091 PortableServer::POA::_narrow(obj.in());
00092 PortableServer::POAManager_var mgr = root_poa->the_POAManager();
00093 mgr->activate();
00094
00095
00096 ManagerImpl *mi = new ManagerImpl("dummy");
00097 Broker::Manager_var manager;
00098
00099 manager = mi->_this();
00100
00101 StubTask *st = new StubTask();
00102 Broker::Task_var task;
00103
00104 task = st->_this();
00105
00106 assert(CORBA::is_nil(manager->CurrentPolicy()));
00107
00108 manager->CurrentPolicy(Broker::Policy::_nil());
00109
00110 Broker::ScheduleParameters sparam;
00111 sparam.length(0);
00112
00113
00114 expect_catch(manager->AddTask(Broker::Task::_nil(), sparam),
00115 CORBA::BAD_PARAM);
00116
00117 manager->AddTask(task.in(), sparam);
00118
00119 expect_catch(manager->AddTask(task.in(), sparam), CORBA::BAD_PARAM);
00120
00121
00122 expect_catch(manager->RemoveTask(Broker::Task::_nil()), CORBA::BAD_PARAM);
00123
00124 manager->RemoveTask(task.in());
00125
00126 expect_catch(manager->RemoveTask(task.in()), CORBA::BAD_PARAM);
00127
00128
00129 expect_catch(manager->ChangeTaskCPU(Broker::RealTimeTask::_nil(),
00130 0,
00131 0,
00132 0),
00133 CORBA::BAD_PARAM);
00134
00135 task = Broker::Task::_nil();
00136 delete st;
00137
00138 manager = Broker::Manager::_nil();
00139 delete mi;
00140
00141 return( retval );
00142 }