75 cout <<
"Asserted :" << b <<
" with :" << msg <<
endl;
87 addOperation(
"instantDoneDone", &
DispatchTest::true_gen,
this).doc(
"Returns true when instantDone is done.");
94 addOperation(
"instantFailDone", &
DispatchTest::true_gen,
this).doc(
"Returns true when instantFail is done.");
107 string prog = string(
"program x { do space.subspace.test.assertMsg(true,\"tpdtrue\") \n")
108 +
" if space.subspace.test.assert(true) then \n" 110 +
" do space.subspace.test.instantDone() \n" 117 BOOST_CHECK(
gtc.
engine()->programs()->getProgramStatus(
"x") != ProgramInterface::Status::error );
118 BOOST_CHECK(
gtc.
engine()->programs()->getProgramStatus(
"x") != ProgramInterface::Status::running );
119 BOOST_CHECK(
gtc.
engine()->programs()->getProgramStatus(
"x") == ProgramInterface::Status::stopped );
128 string prog = string(
"program x { do space.subspace.test.instantFail() \n")
133 BOOST_CHECK(
gtc.
engine()->programs()->getProgramStatus(
"x") == ProgramInterface::Status::error );
141 string prog = string(
"program x { if ( space.subspace.test.assert(true) ) then \n")
142 +
"do space.subspace.test.instantDone() \n" 144 +
"do space.subspace.test.instantFail() \n" 145 +
"if ( space.subspace.test.assert(false) ) then \n" 146 +
"do space.subspace.test.instantFail() \n" 148 +
"do space.subspace.test.instantDone() \n" 153 msg <<
"Status was not 'stopped', but "+
gtc.
engine()->programs()->getProgramStatusStr(
"x");
154 msg <<
" on line " <<
gtc.
engine()->programs()->getProgram(
"x")->getLineNumber();
155 BOOST_CHECK_MESSAGE(
gtc.
engine()->programs()->getProgramStatus(
"x") == ProgramInterface::Status::stopped,
164 string prog = string(
"program x { do space.subspace.test.assert(true)\n")
165 +
"and space.subspace.test.assert(true) \n" 166 +
"and space.subspace.test.assert(true) \n" 167 +
"do space.subspace.test.instantDone() \n" 168 +
"and space.subspace.test.instantDone() \n" 169 +
"and space.subspace.test.instantDone() \n" 174 msg <<
"Status was not 'stopped', but "+
gtc.
engine()->programs()->getProgramStatusStr(
"x");
175 msg <<
" on line " <<
gtc.
engine()->programs()->getProgram(
"x")->getLineNumber();
176 BOOST_CHECK_MESSAGE(
gtc.
engine()->programs()->getProgramStatus(
"x") == ProgramInterface::Status::stopped
185 string prog = string(
"program x { try space.subspace.test.assert(false)\n")
186 +
"try space.subspace.test.assert(true) \n" 187 +
"and space.subspace.test.assert(false) \n" 188 +
"and space.subspace.test.assert(true) \n" 189 +
"try space.subspace.test.instantFail()\n" 190 +
"try space.subspace.test.instantDone() \n" 191 +
"and space.subspace.test.instantFail() \n" 192 +
"and space.subspace.test.instantDone() \n" 196 BOOST_CHECK(
gtc.
engine()->programs()->getProgramStatus(
"x") != ProgramInterface::Status::error );
198 msg <<
"Status was not 'stopped', but "+
gtc.
engine()->programs()->getProgramStatusStr(
"x");
199 msg <<
" on line " <<
gtc.
engine()->programs()->getProgram(
"x")->getLineNumber();
200 BOOST_CHECK_MESSAGE(
gtc.
engine()->programs()->getProgramStatus(
"x") == ProgramInterface::Status::stopped
209 string prog = string(
"program x { do space.subspace.test.instantDone()\n")
211 +
" if time > 10 ms then continue \n" 213 +
"do space.subspace.test.instantDone()\n" 215 +
" if done then continue \n" 221 msg <<
"Status was not 'stopped', but "+
gtc.
engine()->programs()->getProgramStatusStr(
"x");
222 msg <<
" on line " <<
gtc.
engine()->programs()->getProgram(
"x")->getLineNumber();
223 BOOST_CHECK_MESSAGE(
gtc.
engine()->programs()->getProgramStatus(
"x") == ProgramInterface::Status::stopped,
232 string prog = string(
"program x { do space.subspace.test.instantFail()\n")
234 +
" if done then continue \n" 239 BOOST_CHECK(
gtc.
engine()->programs()->getProgramStatus(
"x") == ProgramInterface::Status::error );
248 string prog = string(
"program x { ")
249 +
" do space.subspace.test.instantDone()\n" 250 +
" do space.subspace.test.instantDone()\n" 251 +
" do space.subspace.test.instantDone()\n" 252 +
" do space.subspace.test.instantDone()\n" 256 BOOST_CHECK(
gtc.
engine()->programs()->getProgramStatus(
"x") != ProgramInterface::Status::error );
257 BOOST_CHECK(
gtc.
engine()->programs()->getProgramStatus(
"x") == ProgramInterface::Status::stopped );
272 BOOST_REQUIRE_MESSAGE(
false , exc.
what());
274 if ( pg_list.empty() )
276 BOOST_REQUIRE(
false );
278 BOOST_REQUIRE( tc->engine()->programs()->loadProgram( *pg_list.begin() ) );
282 BOOST_REQUIRE( tc->engine()->programs()->getProgram( (*pg_list.begin())->getName() )->start() );
284 SimulationThread::Instance()->stop();
285 SimulationThread::Instance()->run(1000);
293 tc->
engine()->programs()->getProgram( prog_name )->stop();
294 BOOST_CHECK( tc->
engine()->programs()->unloadProgram( prog_name ) );
void doDispatch(const std::string &prog, TaskContext *)
const std::string what() const
#define BOOST_FIXTURE_TEST_SUITE(suite_name, F)
bool assertMsg(bool, const std::string &msg)
#define BOOST_AUTO_TEST_SUITE_END()
Operation< Signature > & addOperation(Operation< Signature > &op)
virtual bool connectPeers(TaskContext *peer)
virtual void removePeer(const std::string &name)
Service * createObject(std::string a, CommandProcessor *cp)
bool setActivity(base::ActivityInterface *new_act)
std::vector< ProgramInterfacePtr > ParsedPrograms
virtual void disconnectPeers(const std::string &name)
basic_ostreams & endl(basic_ostreams &s)
void finishDispatch(TaskContext *, std::string)
BOOST_AUTO_TEST_CASE(testParseDispatch)
ParsedPrograms parseProgram(const std::string &s, TaskContext *, const std::string &filename="stream")
Reads out the string, parses it, and returns a new ProgramGraph.
void testDispatchFailure()
void testDispatchCondition()
const ExecutionEngine * engine() const
virtual bool addPeer(TaskContext *peer, std::string alias="")
void testDispatchUntilFail()