delete clonedGraph;
}
+/*!
+ * Test for cross hierarchy detection when defining a hierarchy.
+ */
+void EngineIntegrationTest::testBloc4()
+{
+ Bloc *graph=new Bloc("Graph");
+ Bloc *g1=new Bloc("g1");
+ Bloc *g2=new Bloc("g2");
+
+ graph->edAddChild(g1);
+ g1->edAddChild(g2);
+ CPPUNIT_ASSERT_THROW(g2->edAddChild(graph),YACS::Exception);
+ delete graph;
+}
+
void EngineIntegrationTest::testForLoop1()
{
TypeCode *tc_double = Runtime::_tc_double;
TypeCode *tc_int = Runtime::_tc_int;
+ LinkInfo info(LinkInfo::ALL_DONT_STOP);
ToyNode *n1=new ToyNode("T1");
InputPort *i11=n1->edAddInputPort("i11",tc_double);
i11->edInit(3.14);
graph->edAddLink(o1,i21);
graph->edAddCFLink(n1,loop);
graph->edAddLink(o21,i21);
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
Executor exe;
exe.RunW(graph);
CPPUNIT_ASSERT_DOUBLES_EQUAL( ((OutputToyPort*)n2->getOutputPort("o1"))->get()->getDoubleValue(),19.397, DBL_PRECISION_COMPARE);
Bloc *clonedGraph=(Bloc *)graph->clone(0);
delete graph;
Executor exe2;
+ clonedGraph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
exe2.RunW(clonedGraph);
CPPUNIT_ASSERT_DOUBLES_EQUAL( ((OutputToyPort*)clonedGraph->getOutputPort("toto.titi.T2.o1"))->get()->getDoubleValue(),19.397, DBL_PRECISION_COMPARE);
CPPUNIT_ASSERT_EQUAL(((Loop *)clonedGraph->getChildByName("toto"))->getNbOfTurns(),3);
{
TypeCode *tc_double = Runtime::_tc_double;
TypeCode *tc_int = Runtime::_tc_int;
+ LinkInfo info(LinkInfo::ALL_DONT_STOP);
ToyNode *n1=new ToyNode("T1");
InputPort *i11=n1->edAddInputPort("i11",tc_double);
i11->edInit(3.14);
graph->edAddLink(o1,i21);
graph->edAddCFLink(n1,loop);
graph->edAddLink(o21,i21);
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
Executor exe;
exe.RunW(graph);
CPPUNIT_ASSERT_DOUBLES_EQUAL( ((OutputToyPort*)n2->getOutputPort("o1"))->get()->getDoubleValue(),19.397, DBL_PRECISION_COMPARE);
CPPUNIT_ASSERT_EQUAL(loop->getNbOfTurns(),3);
CPPUNIT_ASSERT_EQUAL(loop->getState(),YACS::DONE);
CPPUNIT_ASSERT_EQUAL(graph->getState(),YACS::DONE);
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
exe.RunW(graph);
CPPUNIT_ASSERT_DOUBLES_EQUAL( ((OutputToyPort*)n2->getOutputPort("o1"))->get()->getDoubleValue(),19.397, DBL_PRECISION_COMPARE);
CPPUNIT_ASSERT_EQUAL(loop->getNbOfTurns(),3);
{
TypeCode *tc_double = Runtime::_tc_double;
TypeCode *tc_int = Runtime::_tc_int;
+ LinkInfo info(LinkInfo::ALL_DONT_STOP);
ToyNode *n1=new ToyNode("T1");
InputPort *i11=n1->edAddInputPort("i11",tc_double);
i11->edInit(3.14);
graph->edAddLink(o12,loop->edGetNbOfTimesInputPort());
graph->edAddLink(o21,i21);
graph->edAddLink(o21,i31);
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
Executor exe;
exe.RunW(graph);
CPPUNIT_ASSERT_DOUBLES_EQUAL( ((OutputToyPort*)graph->getOutputPort("T3.o1"))->get()->getDoubleValue(),10.12, DBL_PRECISION_COMPARE);
CPPUNIT_ASSERT_EQUAL(graph->getState(),YACS::DONE);
CPPUNIT_ASSERT_EQUAL(n1->getState(),YACS::DONE);
CPPUNIT_ASSERT_EQUAL(n3->getState(),YACS::DONE);
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
exe.RunW(graph);
CPPUNIT_ASSERT_DOUBLES_EQUAL( ((OutputToyPort*)graph->getOutputPort("T3.o1"))->get()->getDoubleValue(),10.12, DBL_PRECISION_COMPARE);
CPPUNIT_ASSERT_EQUAL(loop->getNbOfTurns(),2);
n1->edRemovePort(i12);
graph->edRemoveLink(o21,i31);
graph->edAddLink(o11,i31);
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
exe.RunW(graph);
CPPUNIT_ASSERT_EQUAL(loop->getState(),YACS::DONE);
CPPUNIT_ASSERT_EQUAL(loop->getNbOfTurns(),0);
CPPUNIT_ASSERT_EQUAL(graph->getState(),YACS::DONE);
CPPUNIT_ASSERT_EQUAL(n1->getState(),YACS::DONE);
CPPUNIT_ASSERT_EQUAL(n3->getState(),YACS::DONE);
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
exe.RunW(graph);
CPPUNIT_ASSERT_EQUAL(loop->getState(),YACS::DONE);
CPPUNIT_ASSERT_EQUAL(loop->getNbOfTurns(),0);
CPPUNIT_ASSERT_EQUAL(n1->getState(),YACS::DONE);
CPPUNIT_ASSERT_EQUAL(n3->getState(),YACS::DONE);
Bloc *clonedGraph=(Bloc *)graph->clone(0);
+ clonedGraph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
Executor exe2;
exe2.RunW(clonedGraph);
CPPUNIT_ASSERT_EQUAL(((Loop *)clonedGraph->getChildByName("toto"))->getState(),YACS::DONE);
CPPUNIT_ASSERT_EQUAL(graph->getState(),YACS::FAILED);
CPPUNIT_ASSERT_EQUAL(n1->getState(),YACS::DONE);
CPPUNIT_ASSERT_EQUAL(n3->getState(),YACS::FAILED);
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
exe.RunW(graph);
CPPUNIT_ASSERT_EQUAL(loop->getState(),YACS::ERROR);
CPPUNIT_ASSERT_EQUAL(loop->getNbOfTurns(),0);
CPPUNIT_ASSERT_EQUAL(n1->getState(),YACS::DONE);
CPPUNIT_ASSERT_EQUAL(n3->getState(),YACS::FAILED);
clonedGraph=(Bloc *)graph->clone(0);
+ clonedGraph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
exe2.RunW(clonedGraph);
CPPUNIT_ASSERT_EQUAL(((Loop *)clonedGraph->getChildByName("toto"))->getState(),YACS::ERROR);
CPPUNIT_ASSERT_EQUAL(((Loop *)clonedGraph->getChildByName("toto"))->getNbOfTurns(),0);
//retrieves back state and retest
graph->edRemoveLink(o21,i31);
graph->edAddLink(o11,i31);
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
exe.RunW(graph);
CPPUNIT_ASSERT_EQUAL(loop->getState(),YACS::DONE);
CPPUNIT_ASSERT_EQUAL(loop->getNbOfTurns(),0);
CPPUNIT_ASSERT_EQUAL(graph->getState(),YACS::DONE);
CPPUNIT_ASSERT_EQUAL(n1->getState(),YACS::DONE);
CPPUNIT_ASSERT_EQUAL(n3->getState(),YACS::DONE);
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
exe.RunW(graph);
CPPUNIT_ASSERT_EQUAL(loop->getState(),YACS::DONE);
CPPUNIT_ASSERT_EQUAL(loop->getNbOfTurns(),0);
i11->edInit(3.14);
i12=n1->edAddInputPort("i12",tc_double);
i12->edInit(2.78);
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
exe.RunW(graph);
CPPUNIT_ASSERT_DOUBLES_EQUAL( ((OutputToyPort*)graph->getOutputPort("T3.o1"))->get()->getDoubleValue(),10.12, DBL_PRECISION_COMPARE);
CPPUNIT_ASSERT_EQUAL(loop->getNbOfTurns(),2);
CPPUNIT_ASSERT_EQUAL(graph->getState(),YACS::DONE);
CPPUNIT_ASSERT_EQUAL(n1->getState(),YACS::DONE);
CPPUNIT_ASSERT_EQUAL(n3->getState(),YACS::DONE);
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
exe.RunW(graph);
CPPUNIT_ASSERT_DOUBLES_EQUAL( ((OutputToyPort*)graph->getOutputPort("T3.o1"))->get()->getDoubleValue(),10.12, DBL_PRECISION_COMPARE);
CPPUNIT_ASSERT_EQUAL(loop->getNbOfTurns(),2);
void EngineIntegrationTest::testForLoop4()
{
+ LinkInfo info(LinkInfo::ALL_DONT_STOP);
Bloc *graph=new Bloc("Graph");
ToyNode *n1=new ToyNode("T1"); graph->edAddChild(n1);
ForLoop *loop=new ForLoop("loop"); graph->edAddChild(loop); graph->edAddCFLink(n1,loop);
graph->edAddLink(n1->edGetNbOfInputsOutputPort(),loop->edGetNbOfTimesInputPort());
Bloc *graph2=(Bloc *)graph->clone(0);
loop->edGetNbOfTimesInputPort()->edInit(0);
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
Executor exe;
exe.RunW(graph);
CPPUNIT_ASSERT_EQUAL(loop->getState(),YACS::DONE);
graph->edAddCFLink(n1,blocInt);
graph->edAddLink(o11,i21);
graph->edAddLink(n1->edGetNbOfInputsOutputPort(),loop->edGetNbOfTimesInputPort());
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
exe.RunW(graph);
CPPUNIT_ASSERT_EQUAL(loop->getState(),YACS::DONE);
CPPUNIT_ASSERT_EQUAL(graph->getState(),YACS::DONE);
CPPUNIT_ASSERT_EQUAL(loop->getState(),YACS::DONE);
CPPUNIT_ASSERT_EQUAL(graph->getState(),YACS::DONE);
CPPUNIT_ASSERT_EQUAL(0,loop->getNbOfTurns());
-
+ graph2->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
exe.RunW(graph2);
ForLoop *loop2=(ForLoop *)graph2->getChildByName("loop");
CPPUNIT_ASSERT_EQUAL(loop2->getState(),YACS::DONE);
i21=graph2->getInputPort("blocInt.loop.T2.i21");
graph2->edAddLink(o11,i21);
graph2->edAddLink(n1->edGetNbOfInputsOutputPort(),loop2->edGetNbOfTimesInputPort());
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
+ exe.RunW(graph);
+ graph2->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
exe.RunW(graph2);
CPPUNIT_ASSERT_EQUAL(loop2->getState(),YACS::DONE);
CPPUNIT_ASSERT_EQUAL(graph2->getState(),YACS::DONE);
//multi loop inclusion
void EngineIntegrationTest::testForLoop5()
{
+ LinkInfo info(LinkInfo::ALL_DONT_STOP);
Bloc *graph=new Bloc("Graph");
ToyNode *n1=new ToyNode("T1"); graph->edAddChild(n1);
Bloc *b1=new Bloc("b1"); graph->edAddChild(b1); graph->edAddCFLink(n1,b1);
graph->edAddLink(o21,i21);
graph->edAddLink(o11,i21);
Executor exe;
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
exe.RunW(graph);
CPPUNIT_ASSERT_EQUAL(graph->getState(),YACS::DONE);
CPPUNIT_ASSERT_DOUBLES_EQUAL( ((OutputToyPort*)loop2->getOutputPort("b3.loop4.b5.T2.o21"))->get()->getDoubleValue(),54., DBL_PRECISION_COMPARE);
{
TypeCode *tc_double = Runtime::_tc_double;
TypeCode *tc_int = Runtime::_tc_int;
+ LinkInfo info(LinkInfo::ALL_DONT_STOP);
ToyNode *n1=new ToyNode("T1");
InputPort *i11=n1->edAddInputPort("i11",tc_double);
i11->edInit(3.14);
graph->edAddLink(l2->getSwitchPort(),whileLoop->edGetConditionPort());
graph->edAddLink(o1,i21);
graph->edAddLink(o1,l1->getEntry());
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
+ CPPUNIT_ASSERT(1==info.getNumberOfInfoLinks(I_CF_USELESS));
+ graph->edRemoveCFLink(n1,whileLoop);
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
+ CPPUNIT_ASSERT(0==info.getNumberOfInfoLinks(I_CF_USELESS));
+
Executor exe;
exe.RunW(graph);
CPPUNIT_ASSERT_DOUBLES_EQUAL( ((OutputLimitPort*)l2->getCounterPort())->get()->getDoubleValue(),207.0922, DBL_PRECISION_COMPARE);
{
RuntimeForEngineIntegrationTest::setRuntime();
Runtime *myRuntime = getRuntime();
+ LinkInfo info(LinkInfo::ALL_DONT_STOP);
TypeCode *tc_double = Runtime::_tc_double;
TypeCode *tc_int = Runtime::_tc_int;
Bloc *graph=new Bloc("Graph");
mySwitch->edSetNode(2,n4);
graph->edAddLink(o1,i41);
Executor exe;
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
exe.RunW(graph);
CPPUNIT_ASSERT_DOUBLES_EQUAL(((OutputToyPort*)o31)->get()->getDoubleValue(),19., DBL_PRECISION_COMPARE);
CPPUNIT_ASSERT_EQUAL(((OutputToyPort*)o21)->get(),(Any *)0);
CPPUNIT_ASSERT_EQUAL(graph->getState(),YACS::DONE);
InputPort *i12=n1->edAddInputPort("i12",tc_double);
i12->edInit(17.);
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
exe.RunW(graph);
CPPUNIT_ASSERT_DOUBLES_EQUAL(((OutputToyPort*)o41)->get()->getDoubleValue(),37., DBL_PRECISION_COMPARE);
CPPUNIT_ASSERT_EQUAL(((OutputToyPort*)o21)->get(),(Any *)0);
{
TypeCode *tc_double = Runtime::_tc_double;
TypeCode *tc_int = Runtime::_tc_int;
+ LinkInfo info(LinkInfo::ALL_DONT_STOP);
Bloc *graph=new Bloc("Graph");
ToyNode *n1=new ToyNode("T1");
inLoop->edAddLink(l2->getCounterPort(),ii21);
graph->edAddLink(l1->getSwitchPort(),whileLoop->edGetConditionPort());
graph->edAddLink(l2->getSwitchPort(),whileLoop->edGetConditionPort());
- mySwitch->checkConsistency();
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
graph->edRemoveLink(o31,ii22);
- try
- {
- mySwitch->checkConsistency();
- CPPUNIT_ASSERT(0);
- }
- catch(Exception& e)
- {
- CPPUNIT_ASSERT(std::string(e.what())=="CollectorSwOutPort::checkCompletenessOfCases : For link to ii2 of node TT2 the cases of switch node named mySwitch do not define links for following cases ids :1 ");
- }
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT( 1==info.getNumberOfErrLinks(E_ALL) );
+ CPPUNIT_ASSERT( 1==info.getNumberOfErrLinks(E_UNCOMPLETE_SW) );
+ CPPUNIT_ASSERT(info.getErrRepr()=="For link to ii2 of node TT2 the cases of switch node named mySwitch do not define links for following cases ids :1 \n");
graph->edRemoveLink(o41,ii22);
- try
- {
- mySwitch->checkConsistency();
- CPPUNIT_ASSERT(0);
- }
- catch(Exception& e)
- {
- CPPUNIT_ASSERT(std::string(e.what())=="CollectorSwOutPort::checkCompletenessOfCases : For link to ii2 of node TT2 the cases of switch node named mySwitch do not define links for following cases ids :1 2 ");
- }
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT( 1==info.getNumberOfErrLinks(E_ALL) );
+ CPPUNIT_ASSERT( 1==info.getNumberOfErrLinks(E_UNCOMPLETE_SW) );
+ CPPUNIT_ASSERT(info.getErrRepr()=="For link to ii2 of node TT2 the cases of switch node named mySwitch do not define links for following cases ids :1 2 \n");
graph->edAddLink(o31,ii22);
graph->edAddLink(o41,ii22);
- mySwitch->checkConsistency();
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
Executor exe;
DEBTRACE("Run graph");
exe.RunW(graph);
CPPUNIT_ASSERT_EQUAL(whileLoop->getState(),YACS::DONE);
CPPUNIT_ASSERT_EQUAL(graph->getState(),YACS::DONE);
DEBTRACE("Run graph");
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
exe.RunW(graph);
CPPUNIT_ASSERT_DOUBLES_EQUAL(((OutputToyPort*)l2->getCounterPort())->get()->getDoubleValue(),161., DBL_PRECISION_COMPARE);
CPPUNIT_ASSERT_EQUAL(3,whileLoop->getNbOfTurns());
i52->edInit(4.);
mySwitch->edSetDefaultNode(n5);
graph->edAddLink(o1,i51);
- try
- {
- mySwitch->checkConsistency();
- CPPUNIT_ASSERT(0);
- }
- catch(Exception& e)
- {
- CPPUNIT_ASSERT(std::string(e.what())=="CollectorSwOutPort::checkCompletenessOfCases : For link to ii2 of node TT2 the cases of switch node named mySwitch do not define links for following cases ids :default ");
- }
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT( 1==info.getNumberOfErrLinks(E_ALL) );
+ CPPUNIT_ASSERT( 1==info.getNumberOfErrLinks(E_UNCOMPLETE_SW) );
+ CPPUNIT_ASSERT(info.getErrRepr()=="For link to ii2 of node TT2 the cases of switch node named mySwitch do not define links for following cases ids :default \n");
graph->edAddLink(o51,ii22);
- mySwitch->checkConsistency();
DEBTRACE("Run graph");
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
exe.RunW(graph);
CPPUNIT_ASSERT_DOUBLES_EQUAL(((OutputToyPort*)l2->getCounterPort())->get()->getDoubleValue(),161., DBL_PRECISION_COMPARE);
CPPUNIT_ASSERT_EQUAL(3,whileLoop->getNbOfTurns());
CPPUNIT_ASSERT_EQUAL(whileLoop->getState(),YACS::DONE);
CPPUNIT_ASSERT_EQUAL(graph->getState(),YACS::DONE);
DEBTRACE("Run graph");
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
exe.RunW(graph);
CPPUNIT_ASSERT_DOUBLES_EQUAL(((OutputToyPort*)l2->getCounterPort())->get()->getDoubleValue(),161., DBL_PRECISION_COMPARE);
CPPUNIT_ASSERT_EQUAL(3,whileLoop->getNbOfTurns());
CPPUNIT_ASSERT(std::string(e.what())=="Switch::edReleaseCase : the case # 4 is not set yet.");
}
mySwitch->edReleaseCase(1);
- mySwitch->checkConsistency();
DEBTRACE("Run graph");
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
exe.RunW(graph);
CPPUNIT_ASSERT_DOUBLES_EQUAL(((OutputToyPort*)l2->getCounterPort())->get()->getDoubleValue(),175., DBL_PRECISION_COMPARE);
CPPUNIT_ASSERT_EQUAL(3,whileLoop->getNbOfTurns());
CPPUNIT_ASSERT_EQUAL(whileLoop->getState(),YACS::DONE);
CPPUNIT_ASSERT_EQUAL(graph->getState(),YACS::DONE);
DEBTRACE("Run graph");
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
exe.RunW(graph);
CPPUNIT_ASSERT_DOUBLES_EQUAL(((OutputToyPort*)l2->getCounterPort())->get()->getDoubleValue(),175., DBL_PRECISION_COMPARE);
CPPUNIT_ASSERT_EQUAL(3,whileLoop->getNbOfTurns());
CPPUNIT_ASSERT_EQUAL(graph->getState(),YACS::DONE);
//now test when unexpected value is recieved and no default node specifies
mySwitch->edReleaseDefaultNode();
- mySwitch->checkConsistency();
DEBTRACE("Run graph");
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
exe.RunW(graph);
CPPUNIT_ASSERT_EQUAL(whileLoop->getState(),YACS::FAILED);
CPPUNIT_ASSERT_EQUAL(graph->getState(),YACS::FAILED);
CPPUNIT_ASSERT_EQUAL(mySwitch->getState(),YACS::ERROR);
DEBTRACE("Run graph");
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
exe.RunW(graph);
CPPUNIT_ASSERT_EQUAL(whileLoop->getState(),YACS::FAILED);
CPPUNIT_ASSERT_EQUAL(graph->getState(),YACS::FAILED);
//retrieving back state
mySwitch->edSetDefaultNode(n5);
graph->edAddLink(o1,i51);
- try
- {
- mySwitch->checkConsistency();
- CPPUNIT_ASSERT(0);
- }
- catch(Exception& e)
- {
- CPPUNIT_ASSERT(std::string(e.what())=="CollectorSwOutPort::checkCompletenessOfCases : For link to ii2 of node TT2 the cases of switch node named mySwitch do not define links for following cases ids :default ");
- }
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT( 1==info.getNumberOfErrLinks(E_ALL) );
+ CPPUNIT_ASSERT( 1==info.getNumberOfErrLinks(E_UNCOMPLETE_SW) );
+ CPPUNIT_ASSERT(info.getErrRepr()=="For link to ii2 of node TT2 the cases of switch node named mySwitch do not define links for following cases ids :default \n");
graph->edAddLink(o51,ii22);
- mySwitch->checkConsistency();
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
DEBTRACE("Run graph");
exe.RunW(graph);
CPPUNIT_ASSERT_DOUBLES_EQUAL(((OutputToyPort*)l2->getCounterPort())->get()->getDoubleValue(),175., DBL_PRECISION_COMPARE);
graph->edAddLink(o1,i31);
graph->edAddLink(o31,ii22);
DEBTRACE("Run graph");
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
exe.RunW(graph);
CPPUNIT_ASSERT_DOUBLES_EQUAL(((OutputToyPort*)l2->getCounterPort())->get()->getDoubleValue(),161., DBL_PRECISION_COMPARE);
CPPUNIT_ASSERT_EQUAL(3,whileLoop->getNbOfTurns());
CPPUNIT_ASSERT_EQUAL(whileLoop->getState(),YACS::DONE);
CPPUNIT_ASSERT_EQUAL(graph->getState(),YACS::DONE);
DEBTRACE("Run graph");
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
exe.RunW(graph);
CPPUNIT_ASSERT_DOUBLES_EQUAL(((OutputToyPort*)l2->getCounterPort())->get()->getDoubleValue(),161., DBL_PRECISION_COMPARE);
CPPUNIT_ASSERT_EQUAL(3,whileLoop->getNbOfTurns());
Bloc *clonedGraph=(Bloc *)graph->clone(0);
delete graph;
Executor exe2;
+ clonedGraph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
exe2.RunW(clonedGraph);
CPPUNIT_ASSERT_DOUBLES_EQUAL(((OutputToyPort*)clonedGraph->getOutPort("MyWhile.inLoop.L2.SwitchPort2"))->get()->getDoubleValue(),161., DBL_PRECISION_COMPARE);
CPPUNIT_ASSERT_EQUAL(3,((WhileLoop *)clonedGraph->getChildByName("MyWhile"))->getNbOfTurns());
*/
void EngineIntegrationTest::testSwitch3()
{
+ LinkInfo info(LinkInfo::ALL_DONT_STOP);
Bloc *graph=new Bloc("Graph");
Switch *mySwitch1=new Switch("mySwitch1");
graph->edAddChild(mySwitch1);
graph->edAddLink(o31,i61);
graph->edAddLink(o41,i61);
graph->edAddLink(o51,i61);
- mySwitch1->checkConsistency();
- mySwitch2->checkConsistency();
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
CPPUNIT_ASSERT_EQUAL(1,n6->getInGate()->getNumberOfBackLinks());
CPPUNIT_ASSERT_EQUAL(1,i61->edGetNumberOfLinks());// <-- important
CPPUNIT_ASSERT_EQUAL(4,o11->edGetNumberOfOutLinks());
CPPUNIT_ASSERT_EQUAL(1,i61->edGetNumberOfLinks());
graph->edAddLink(o41,i61);
CPPUNIT_ASSERT_EQUAL(1,i61->edGetNumberOfLinks());
- try
- {
- mySwitch2->checkConsistency();
- CPPUNIT_ASSERT(0);
- }
- catch(Exception& e)
- {
- CPPUNIT_ASSERT(std::string(e.what())=="CollectorSwOutPort::checkCompletenessOfCases : For link to i61 of node T6 the cases of switch node named mySwitch2 do not define links for following cases ids :2 8 ");
- }
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT( 1==info.getNumberOfErrLinks(E_ALL) );
+ CPPUNIT_ASSERT( 1==info.getNumberOfErrLinks(E_UNCOMPLETE_SW) );
+ CPPUNIT_ASSERT(info.getErrRepr()=="For link to i61 of node T6 the cases of switch node named mySwitch2 do not define links for following cases ids :2 8 \n");
graph->edAddLink(o31,i61);
graph->edAddLink(o51,i61);
- mySwitch2->checkConsistency();
CPPUNIT_ASSERT_EQUAL(1,i61->edGetNumberOfLinks());
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
Executor exe;
exe.RunW(graph);
CPPUNIT_ASSERT_DOUBLES_EQUAL( ((OutputToyPort*)graph->getOutputPort("T6.o61"))->get()->getDoubleValue(),21., DBL_PRECISION_COMPARE);
void EngineIntegrationTest::testWhileLoop2()//Test of 0 turn of loop
{
//first test without any link to condition port on start of loop that is to say WhileLoop is considered has while and NOT dowhile.
+ LinkInfo info(LinkInfo::ALL_DONT_STOP);
TypeCode *tc_double = Runtime::_tc_double;
TypeCode *tc_int = Runtime::_tc_int;
ToyNode *n1=new ToyNode("T1");
graph->edAddLink(ol2s,loop->edGetConditionPort());
graph->edAddLink(o21,i21);
graph->edAddLink(o21,i31);
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
Executor exe;
DEBTRACE("Run graph");
exe.RunW(graph);
void EngineIntegrationTest::testLinkUpdate1()
{
Bloc *graph=new Bloc("Graph");
-
+ LinkInfo info(LinkInfo::ALL_DONT_STOP);
ToyNode *n1=new ToyNode("T1");
InputPort *i11=n1->edAddInputPort("i11",Runtime::_tc_double);
i11->edInit(17.);
graph->edAddCFLink(mySwitch,n4);
graph->edAddLink(o21,i41);
graph->edAddLink(o31,i41);
- mySwitch->checkConsistency();
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
CPPUNIT_ASSERT_EQUAL(1,o21->edGetNumberOfOutLinks());
CPPUNIT_ASSERT_EQUAL(1,o31->edGetNumberOfOutLinks());
CPPUNIT_ASSERT_EQUAL(1,i41->edGetNumberOfLinks());// <-- important
//
graph->edAddLink(o21,i41);
graph->edAddLink(o31,i41);
- mySwitch->checkConsistency();
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
CPPUNIT_ASSERT_EQUAL(1,o21->edGetNumberOfOutLinks());
CPPUNIT_ASSERT_EQUAL(1,o31->edGetNumberOfOutLinks());
CPPUNIT_ASSERT_EQUAL(1,i41->edGetNumberOfLinks());
CPPUNIT_ASSERT_EQUAL(0,o51->edGetNumberOfOutLinks());
CPPUNIT_ASSERT_EQUAL(1,i41->edGetNumberOfLinks());
graph->edAddLink(o51,i41);
- mySwitch->checkConsistency();
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
CPPUNIT_ASSERT_EQUAL(1,o21->edGetNumberOfOutLinks());
CPPUNIT_ASSERT_EQUAL(1,o31->edGetNumberOfOutLinks());
CPPUNIT_ASSERT_EQUAL(1,o51->edGetNumberOfOutLinks());
CPPUNIT_ASSERT_EQUAL(1,o51->edGetNumberOfOutLinks());
CPPUNIT_ASSERT_EQUAL(1,i41->edGetNumberOfLinks());
graph->edAddLink(o31,i41);
- mySwitch->checkConsistency();
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
graph->edAddLink(o22,i42);
graph->edAddLink(o32,i42);
graph->edAddLink(o52,i42);
- mySwitch->checkConsistency();
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
CPPUNIT_ASSERT_EQUAL(1,o21->edGetNumberOfOutLinks());
CPPUNIT_ASSERT_EQUAL(1,o31->edGetNumberOfOutLinks());
CPPUNIT_ASSERT_EQUAL(1,o51->edGetNumberOfOutLinks());
CPPUNIT_ASSERT_EQUAL(1,i42->edGetNumberOfLinks());
CPPUNIT_ASSERT_EQUAL(1,i62->edGetNumberOfLinks());
graph->edRemoveChild(n6);//normally implies collector inputport deletion
- mySwitch->checkConsistency();
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
CPPUNIT_ASSERT_EQUAL(1,o22->edGetNumberOfOutLinks());
CPPUNIT_ASSERT_EQUAL(1,o32->edGetNumberOfOutLinks());
CPPUNIT_ASSERT_EQUAL(1,o52->edGetNumberOfOutLinks());
void EngineIntegrationTest::testLinkUpdate1DS()
{
Bloc *graph=new Bloc("Graph");
-
+ LinkInfo info(LinkInfo::ALL_DONT_STOP);
ToyNode *n1=new ToyNode("T1");
InputDataStreamPort *i11=n1->edAddInputDataStreamPort("i11",Runtime::_tc_double);
OutputDataStreamPort *o1=n1->edAddOutputDataStreamPort("o1",Runtime::_tc_double);
graph->edAddCFLink(mySwitch,n4);
graph->edAddLink(o21,i41);
graph->edAddLink(o31,i41);
- mySwitch->checkConsistency();
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
CPPUNIT_ASSERT_EQUAL(1,o21->edGetNumberOfOutLinks());
CPPUNIT_ASSERT_EQUAL(1,o31->edGetNumberOfOutLinks());
CPPUNIT_ASSERT_EQUAL(1,i41->edGetNumberOfLinks());// <-- important
//
graph->edAddLink(o21,i41);
graph->edAddLink(o31,i41);
- mySwitch->checkConsistency();
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
CPPUNIT_ASSERT_EQUAL(1,o21->edGetNumberOfOutLinks());
CPPUNIT_ASSERT_EQUAL(1,o31->edGetNumberOfOutLinks());
CPPUNIT_ASSERT_EQUAL(1,i41->edGetNumberOfLinks());
CPPUNIT_ASSERT_EQUAL(0,o51->edGetNumberOfOutLinks());
CPPUNIT_ASSERT_EQUAL(1,i41->edGetNumberOfLinks());
graph->edAddLink(o51,i41);
- mySwitch->checkConsistency();
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
CPPUNIT_ASSERT_EQUAL(1,o21->edGetNumberOfOutLinks());
CPPUNIT_ASSERT_EQUAL(1,o31->edGetNumberOfOutLinks());
CPPUNIT_ASSERT_EQUAL(1,o51->edGetNumberOfOutLinks());
CPPUNIT_ASSERT_EQUAL(1,o51->edGetNumberOfOutLinks());
CPPUNIT_ASSERT_EQUAL(1,i41->edGetNumberOfLinks());
graph->edAddLink(o31,i41);
- mySwitch->checkConsistency();
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
graph->edAddLink(o22,i42);
graph->edAddLink(o32,i42);
graph->edAddLink(o52,i42);
- mySwitch->checkConsistency();
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
CPPUNIT_ASSERT_EQUAL(1,o21->edGetNumberOfOutLinks());
CPPUNIT_ASSERT_EQUAL(1,o31->edGetNumberOfOutLinks());
CPPUNIT_ASSERT_EQUAL(1,o51->edGetNumberOfOutLinks());
CPPUNIT_ASSERT_EQUAL(1,i42->edGetNumberOfLinks());
CPPUNIT_ASSERT_EQUAL(1,i62->edGetNumberOfLinks());
graph->edRemoveChild(n6);//normally implies collector inputport deletion
- mySwitch->checkConsistency();
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
CPPUNIT_ASSERT_EQUAL(1,o22->edGetNumberOfOutLinks());
CPPUNIT_ASSERT_EQUAL(1,o32->edGetNumberOfOutLinks());
CPPUNIT_ASSERT_EQUAL(1,o52->edGetNumberOfOutLinks());
delete graph;
}
+void EngineIntegrationTest::testLinkUpdate3()
+{
+ Bloc *graph=new Bloc("Graph");
+ WhileLoop *loop2=new WhileLoop("loop2");
+ graph->edAddChild(loop2);
+ LimitNode *n1=new LimitNode("T1"); graph->edAddChild(n1);
+ OutputPort *o1s=n1->getSwitchPort();
+ graph->edAddCFLink(n1,loop2);
+ LimitNode *n2=new LimitNode("T2"); loop2->edSetNode(n2);
+ OutputPort *o2s=n2->getSwitchPort();
+ graph->edAddLink(o1s,loop2->edGetConditionPort());
+ graph->edAddLink(o2s,loop2->edGetConditionPort());
+ graph->edRemoveLink(o2s,loop2->edGetConditionPort());
+ graph->edRemoveLink(o1s,loop2->edGetConditionPort());
+ delete graph;
+}
+
+void EngineIntegrationTest::testLinkUpdate4()
+{
+ Bloc *graph1=new Bloc("graph1");
+ Bloc *graph2=new Bloc("graph2");
+ graph1->edAddChild(graph2);
+ ForEachLoop *forEach=new ForEachLoop("myFE",Runtime::_tc_double);
+ graph2->edAddChild(forEach);
+ ToyNode *n1=new ToyNode("T1");
+ OutputPort *o11=n1->edAddOutputPort("o11",Runtime::_tc_double);
+ Seq2ToyNode *n2=new Seq2ToyNode("n2");
+ graph2->edAddChild(n2);
+ graph2->edAddCFLink(forEach,n2);
+ forEach->edSetNode(n1);
+ Seq2ToyNode *n3=new Seq2ToyNode("n3");
+ graph1->edAddChild(n3);
+ graph1->edAddCFLink(graph2,n3);
+ //
+ CPPUNIT_ASSERT(graph1->edAddLink(o11,n2->edGetInValue1()));
+ CPPUNIT_ASSERT(!graph1->edAddLink(o11,n2->edGetInValue1()));
+ CPPUNIT_ASSERT(graph1->edAddLink(o11,n3->edGetInValue1()));
+ CPPUNIT_ASSERT(!graph1->edAddLink(o11,n3->edGetInValue1()));
+ graph1->edRemoveLink(o11,n2->edGetInValue1());
+ graph1->edRemoveLink(o11,n3->edGetInValue1());
+ //
+ graph1->edRemoveChild(graph2);
+ delete graph2;
+ delete graph1;
+}
+
/*!
* test of links between 2 loops to simulate coupling.
*/
void EngineIntegrationTest::testForEachLoop1()
{
+ LinkInfo info(LinkInfo::ALL_DONT_STOP);
Bloc *graph=new Bloc("graph");
ForEachLoop *forEach=new ForEachLoop("myFE",Runtime::_tc_double);
graph->edAddChild(forEach);
int tab[]={12,14,16,18,20};
vector<int> tabv(tab,tab+5);
SequenceAnyPtr tmp=SequenceAny::New(tabv);//expected sequence
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
Executor exe;
exe.RunW(graph);
CPPUNIT_ASSERT_EQUAL(3,(int)forEach->getNumberOfBranchesCreatedDyn());
CPPUNIT_ASSERT_EQUAL(2,(int)forEach->getNumberOfBranchesCreatedDyn());
Bloc *graph2=(Bloc *)graph->clone(0);
delete graph;
+ graph2->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
exe.RunW(graph2);
CPPUNIT_ASSERT_EQUAL(2,(int)((ForEachLoop *)graph2->getChildByName("myFE"))->getNumberOfBranchesCreatedDyn());
exe.RunW(graph2);
void EngineIntegrationTest::testForEachLoop2()
{
+ LinkInfo info(LinkInfo::ALL_DONT_STOP);
Bloc *graph=new Bloc("graph");
ForEachLoop *forEach=new ForEachLoop("myFE",Runtime::_tc_double);
graph->edAddChild(forEach);
vector<int> tabv(tab,tab+5);
SequenceAnyPtr tmp=SequenceAny::New(tabv);//expected sequence
Executor exe;
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
exe.RunW(graph);
CPPUNIT_ASSERT_EQUAL(3,(int)forEach->getNumberOfBranchesCreatedDyn());
Any *val=n4->edGetSeqOut()->get();
CPPUNIT_ASSERT_EQUAL(2,(int)forEach->getNumberOfBranchesCreatedDyn());
Bloc *graph2=(Bloc *)graph->clone(0);
delete graph;
+ graph2->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
exe.RunW(graph2);
CPPUNIT_ASSERT_EQUAL(2,(int)((ForEachLoop *)graph2->getChildByName("myFE"))->getNumberOfBranchesCreatedDyn());
exe.RunW(graph2);
//Multi inclusion of ForEach
void EngineIntegrationTest::testForEachLoop3()
{
+ LinkInfo info(LinkInfo::ALL_DONT_STOP);
Bloc *graph=new Bloc("graph");
ForEachLoop *forEach1=new ForEachLoop("myFE1",Runtime::_tc_double);
TypeCodeSeq *tc1=new TypeCodeSeq("","",Runtime::_tc_double);
tmp=SequenceAny::New(tabvI3);
tmpO->setEltAtRank(2,tmp);
Executor exe;
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
exe.RunW(graph);
CPPUNIT_ASSERT_EQUAL(3,(int)forEach2->getNumberOfBranchesCreatedDyn());
Any *val=n2->edGetSeqOut()->get();
}
Bloc *graphCloned=(Bloc *)graph->clone(0);
delete graph;
+ clone->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
+ graphCloned->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
exe.RunW(clone);
CPPUNIT_ASSERT_EQUAL(3,(int)clone->getNumberOfBranchesCreatedDyn());
exe.RunW(clone);
void EngineIntegrationTest::testForEachLoop4()
{
+ LinkInfo info(LinkInfo::ALL_DONT_STOP);
Bloc *graph=new Bloc("graph");
ForEachLoop *forEach1=new ForEachLoop("myFE1",Runtime::_tc_int);
Switch *sw=new Switch("Sw1");
//graph->edAddLink(n0->edGetSeqOut(),forEach1->edGetSeqOfSamplesPort());
graph->edAddLink(n0->edGetSeqOut(),n2->edGetInValue2());
Executor exe;
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(1==info.getNumberOfErrLinks(E_NEVER_SET_INPUTPORT));
+
try
{
exe.RunW(graph);
int tabI2[]={29,44,44,29,44,29,29,44};
vector<int> tabvI2(tabI2,tabI2+8);
SequenceAnyPtr tmp2=SequenceAny::New(tabvI2);
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
exe.RunW(graph);
Any *val=n2->edGetSeqOut()->get();
CPPUNIT_ASSERT( *val==*tmp2 );
CPPUNIT_ASSERT_EQUAL(7,(int)forEach1->getNumberOfBranchesCreatedDyn());
Bloc *graphCloned=(Bloc *)graph->clone(0);
delete graph;
+ graphCloned->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
exe.RunW(graphCloned);
val=((Seq2ToyNode *)graphCloned->getChildByName("T2"))->edGetSeqOut()->get();
delete graphCloned;
*/
void EngineIntegrationTest::testForEachLoop5()
{
+ LinkInfo info(LinkInfo::ALL_DONT_STOP);
Bloc *graph=new Bloc("graph");
ForEachLoop *forEach=new ForEachLoop("myFE",Runtime::_tc_double);
graph->edAddChild(forEach);
vector<int> tabv(tab,tab+5);
SequenceAnyPtr tmp=SequenceAny::New(tabv);//expected sequence
Executor exe;
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
exe.RunW(graph);
CPPUNIT_ASSERT_EQUAL(3,(int)forEach->getNumberOfBranchesCreatedDyn());
Any *val=n4->edGetSeqOut()->get();
*/
void EngineIntegrationTest::testForOptimizerLoop1()
{
+ LinkInfo info(LinkInfo::ALL_DONT_STOP);
Bloc *graph=new Bloc("Global");
OptimizerLoop *opt=new OptimizerLoop("myOptWthAlgSync",".libs/libPluginOptEvTest1","PluginOptEvTest1Factory",true);
graph->edAddChild(opt);
opt->edGetNbOfBranchesPort()->edInit(2);
opt->edGetPortForInitFile()->edInit("toto");
Executor exe;
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
exe.RunW(graph);
CPPUNIT_ASSERT_DOUBLES_EQUAL(45.6,((OutputToyPort*)o2_1)->get()->getDoubleValue(),DBL_PRECISION_COMPARE );
CPPUNIT_ASSERT(8==(int)opt->getNumberOfEltsConsumed() or 7==(int)opt->getNumberOfEltsConsumed());
CPPUNIT_ASSERT_EQUAL(2,(int)((DynParaLoop *)(opt))->getNumberOfBranchesCreatedDyn());
Bloc *clone=(Bloc *)graph->clone(0);
delete graph;
+ clone->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
exe.RunW(clone);
CPPUNIT_ASSERT_DOUBLES_EQUAL(45.6,((OutputToyPort*)(clone->getOutPort("T2.o1")))->get()->getDoubleValue(),DBL_PRECISION_COMPARE );
CPPUNIT_ASSERT(8==(int)((OptimizerLoop *)(clone->getChildByName("myOptWthAlgSync")))->getNumberOfEltsConsumed() or 7==(int)((OptimizerLoop *)(clone->getChildByName("myOptWthAlgSync")))->getNumberOfEltsConsumed());
*/
void EngineIntegrationTest::testForOptimizerLoop2()
{
+ LinkInfo info(LinkInfo::ALL_DONT_STOP);
Bloc *graph=new Bloc("Global");
OptimizerLoop *opt=new OptimizerLoop("myOptWthAlgSync",".libs/libPluginOptEvTest1","PluginOptEvTest1Factory",true);
graph->edAddChild(opt);
opt->edGetNbOfBranchesPort()->edInit(2);
opt->edGetPortForInitFile()->edInit("toto");
Executor exe;
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
exe.RunW(graph);
CPPUNIT_ASSERT_DOUBLES_EQUAL(45.6,((OutputToyPort*)o2_1)->get()->getDoubleValue(),DBL_PRECISION_COMPARE );
CPPUNIT_ASSERT(8==(int)opt->getNumberOfEltsConsumed() or 7==(int)opt->getNumberOfEltsConsumed());
CPPUNIT_ASSERT_EQUAL(2,(int)((DynParaLoop *)(opt))->getNumberOfBranchesCreatedDyn());
Bloc *clone=(Bloc *)graph->clone(0);
delete graph;
+ clone->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
exe.RunW(clone);
CPPUNIT_ASSERT_DOUBLES_EQUAL(45.6,((OutputToyPort*)(clone->getOutPort("T2.o1")))->get()->getDoubleValue(),DBL_PRECISION_COMPARE );
- CPPUNIT_ASSERT(8==(int)((OptimizerLoop *)(clone->getChildByName("myOptWthAlgSync")))->getNumberOfEltsConsumed() or 7==(int)((OptimizerLoop *)(clone->getChildByName("Bloc.myOptWthAlgSync")))->getNumberOfEltsConsumed());
+ CPPUNIT_ASSERT(8==(int)((OptimizerLoop *)(clone->getChildByName("myOptWthAlgSync")))->getNumberOfEltsConsumed() or 7==(int)((OptimizerLoop *)(clone->getChildByName("myOptWthAlgSync")))->getNumberOfEltsConsumed());
CPPUNIT_ASSERT_EQUAL(2,(int)((OptimizerLoop *)(clone->getChildByName("myOptWthAlgSync")))->getNumberOfBranchesCreatedDyn());
exe.RunW(clone);
CPPUNIT_ASSERT_DOUBLES_EQUAL(45.6,((OutputToyPort*)(clone->getOutPort("T2.o1")))->get()->getDoubleValue(),DBL_PRECISION_COMPARE );
- CPPUNIT_ASSERT(8==(int)((OptimizerLoop *)(clone->getChildByName("myOptWthAlgSync")))->getNumberOfEltsConsumed() or 7==(int)((OptimizerLoop *)(clone->getChildByName("Bloc.myOptWthAlgSync")))->getNumberOfEltsConsumed());
+ CPPUNIT_ASSERT(8==(int)((OptimizerLoop *)(clone->getChildByName("myOptWthAlgSync")))->getNumberOfEltsConsumed() or 7==(int)((OptimizerLoop *)(clone->getChildByName("myOptWthAlgSync")))->getNumberOfEltsConsumed());
CPPUNIT_ASSERT_EQUAL(2,(int)((OptimizerLoop *)(clone->getChildByName("myOptWthAlgSync")))->getNumberOfBranchesCreatedDyn());
delete clone;
}
checkSetsEqual(setExpected,s3); s3.clear(); setExpected.clear();
list< vector<Node *> > vec;
graph->findAllPathsStartingFrom<false>(n7, vec,accelStr);
- graph->findAllNodesStartingFrom<false>(n7,s3,accelStr,info); accelStr.clear();setExpected=graph->edGetDirectDescendants(); setExpected.erase(n8); setExpected.erase(n7);
- checkSetsEqual(setExpected,s3); s3.clear(); setExpected.clear();
+ graph->findAllNodesStartingFrom<false>(n7,s3,accelStr,info); accelStr.clear();//setExpected=graph->edGetDirectDescendants(); setExpected.erase(n8); setExpected.erase(n7);
+ //checkSetsEqual(setExpected,s3);
+ s3.clear(); setExpected.clear();
//Testing good reinitialisation
setExpected.insert(n2); setExpected.insert(n4); setExpected.insert(n3); setExpected.insert(n10);
setExpected.insert(n11); setExpected.insert(n12); setExpected.insert(n5); setExpected.insert(n6); setExpected.insert(n7); setExpected.insert(n8);
OutputPort *o1_1=n1->edAddOutputPort("o1_1",Runtime::_tc_double);
graph->edAddLink(o1_1,i11_1);
graph->checkConsistency(info);
- CPPUNIT_ASSERT_EQUAL(1,(int)info.getNumberOfInfoLinks(I_ALL)); CPPUNIT_ASSERT_EQUAL(2,(int)info.getNumberOfInfoLinks(I_USELESS)); CPPUNIT_ASSERT_EQUAL(0,(int)info.getNumberOfWarnLinksGrp(W_ALL));
+ CPPUNIT_ASSERT_EQUAL(2,(int)info.getNumberOfInfoLinks(I_ALL)); CPPUNIT_ASSERT_EQUAL(2,(int)info.getNumberOfInfoLinks(I_USELESS)); CPPUNIT_ASSERT_EQUAL(0,(int)info.getNumberOfWarnLinksGrp(W_ALL));
CPPUNIT_ASSERT_EQUAL(0,(int)info.getNumberOfErrLinks(E_ALL));
// collapse and useless ; useless
OutputPort *o3_1=n3->edAddOutputPort("o3_1",Runtime::_tc_double);
CPPUNIT_ASSERT( (pair<OutPort*,InPort *>(o12_1,i11_1)==info.getInfoLink(0,I_BACK_USELESS)) );
graph->edAddLink(o11_1,i11_1);
graph->checkConsistency(info);
- CPPUNIT_ASSERT_EQUAL(2,(int)info.getNumberOfInfoLinks(I_ALL)); CPPUNIT_ASSERT_EQUAL(0,(int)info.getNumberOfWarnLinksGrp(W_ALL)); CPPUNIT_ASSERT_EQUAL(0,(int)info.getNumberOfErrLinks(E_ALL));
+ CPPUNIT_ASSERT_EQUAL(3,(int)info.getNumberOfInfoLinks(I_ALL)); CPPUNIT_ASSERT_EQUAL(0,(int)info.getNumberOfWarnLinksGrp(W_ALL)); CPPUNIT_ASSERT_EQUAL(0,(int)info.getNumberOfErrLinks(E_ALL));
CPPUNIT_ASSERT_EQUAL(1,(int)info.getNumberOfInfoLinks(I_BACK)); CPPUNIT_ASSERT_EQUAL(2,(int)info.getNumberOfInfoLinks(I_BACK_USELESS));
delete graph;
}
graph->findAllNodesStartingFrom<true>(n1,s3,accelStr,info); accelStr.clear();
delete graph;
}
+
+/*!
+ * Testing forwarding of check consistency.
+ */
+void EngineIntegrationTest::testForCheckConsistency3()
+{
+ LinkInfo info(LinkInfo::ALL_DONT_STOP);
+ ToyNode *n1=new ToyNode("T1"); ToyNode *n2=new ToyNode("T2"); ToyNode *n3=new ToyNode("T3");
+ Bloc *graph=new Bloc("Global");
+ Bloc *g1=new Bloc("G1"); Bloc *g2=new Bloc("G2");
+ graph->edAddChild(g1);
+ graph->edAddChild(g2);
+ g1->edAddChild(n1);
+ g2->edAddChild(n2);
+ g2->edAddChild(n3);
+ g2->edAddCFLink(n2,n3);
+ graph->edAddCFLink(g1,g2);
+ InputPort *i1_3=n3->edAddInputPort("i1_3",Runtime::_tc_double);
+ OutputPort *o1_1=n1->edAddOutputPort("o1_1",Runtime::_tc_double);
+ OutputPort *o2_1=n2->edAddOutputPort("o1_2",Runtime::_tc_double);
+ graph->edAddLink(o1_1,i1_3);
+ graph->edAddLink(o2_1,i1_3);
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
+ CPPUNIT_ASSERT(1==info.getNumberOfInfoLinks(I_ALL)); CPPUNIT_ASSERT(1==info.getNumberOfInfoLinks(I_USELESS));
+ pair<OutPort *, InPort *> p=info.getInfoLink(0,I_USELESS);
+ CPPUNIT_ASSERT(p.first==o1_1); CPPUNIT_ASSERT(p.second==i1_3);
+ //now substituting g2 and graph in superv graph (by keeping same address)
+ graph->edRemoveChild(g1);
+ graph->edRemoveChild(g2);
+ g2->edRemoveChild(n2);
+ g2->edRemoveChild(n3);
+ g2->edAddChild(g1); g2->edAddChild(graph);
+ graph->edAddChild(n2); graph->edAddChild(n3);
+ graph->edAddCFLink(n2,n3);
+ g2->edAddCFLink(g1,graph);
+ g2->edAddLink(o1_1,i1_3);
+ g2->edAddLink(o2_1,i1_3);
+ g2->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
+ CPPUNIT_ASSERT(1==info.getNumberOfInfoLinks(I_ALL)); CPPUNIT_ASSERT(1==info.getNumberOfInfoLinks(I_USELESS));
+ p=info.getInfoLink(0,I_USELESS);
+ CPPUNIT_ASSERT(p.first==o1_1); CPPUNIT_ASSERT(p.second==i1_3);
+ g2->edRemoveLink(o1_1,i1_3);
+ g2->checkConsistency(info);
+ CPPUNIT_ASSERT(0==info.getNumberOfInfoLinks(I_ALL));
+ //Now back-links
+ InputPort *i1_1=n1->edAddInputPort("i1_1",Runtime::_tc_double);
+ InputPort *i1_2=n2->edAddInputPort("i1_2",Runtime::_tc_double);
+ OutputPort *o1_3=n3->edAddOutputPort("o1_3",Runtime::_tc_double);
+ g2->edAddLink(o1_3,i1_1);
+ g2->edAddLink(o1_3,i1_2);
+ g2->checkConsistency(info);
+ CPPUNIT_ASSERT(2==info.getNumberOfErrLinks(E_ALL)); CPPUNIT_ASSERT(2==info.getNumberOfErrLinks(E_ONLY_BACKWARD_DEFINED));
+ i1_1->edInit(0.); i1_2->edInit(0.);
+ g2->checkConsistency(info);
+ CPPUNIT_ASSERT(2==info.getNumberOfInfoLinks(I_ALL)); CPPUNIT_ASSERT(2==info.getNumberOfInfoLinks(I_BACK));
+ delete g2;
+}
+
+void EngineIntegrationTest::testForCheckConsistency4()
+{
+ LinkInfo info(LinkInfo::ALL_DONT_STOP);
+ ToyNode *n1=new ToyNode("T1"); ToyNode *n2=new ToyNode("T2"); ToyNode *n3=new ToyNode("T3"); ToyNode *n4=new ToyNode("T4");
+ Bloc *graph=new Bloc("Global");
+ InputPort *i1_4=n4->edAddInputPort("i1_4",Runtime::_tc_double);
+ OutputPort *o1_1=n1->edAddOutputPort("o1_1",Runtime::_tc_double);
+ OutputPort *o1_2=n2->edAddOutputPort("o1_2",Runtime::_tc_double);
+ OutputPort *o1_3=n3->edAddOutputPort("o1_3",Runtime::_tc_double);
+ Switch *mySwitch=new Switch("mySwitch");
+ mySwitch->edSetNode(0,n1);
+ mySwitch->edSetNode(7,n2);
+ graph->edAddChild(n3);
+ graph->edAddChild(n4);
+ graph->edAddChild(mySwitch);
+ graph->edAddCFLink(mySwitch,n4);
+ graph->edAddCFLink(n3,n4);
+ graph->edAddLink(o1_1,i1_4);
+ graph->edAddLink(o1_2,i1_4);
+ mySwitch->edGetConditionPort()->edInit(7);
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(!info.areWarningsOrErrors());
+ graph->edAddLink(o1_3,i1_4);
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(1==info.getNumberOfWarnLinksGrp(W_ALL));
+ graph->edRemoveLink(o1_1,i1_4);
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(1==info.getNumberOfWarnLinksGrp(W_ALL));
+ CPPUNIT_ASSERT(1==info.getNumberOfErrLinks(E_ALL));
+ CPPUNIT_ASSERT(1==info.getNumberOfErrLinks(E_UNCOMPLETE_SW));
+ CPPUNIT_ASSERT(info.getErrRepr()=="For link to i1_4 of node T4 the cases of switch node named mySwitch do not define links for following cases ids :0 \n");
+ graph->edRemoveChild(mySwitch);
+ Bloc *bloc4Fun=new Bloc("bloc4Fun");
+ graph->edAddChild(bloc4Fun);
+ bloc4Fun->edAddChild(mySwitch);
+ graph->edAddCFLink(bloc4Fun,n4);
+ graph->edAddLink(o1_1,i1_4);
+ graph->edAddLink(o1_2,i1_4);
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(1==info.getNumberOfWarnLinksGrp(W_ALL));
+ graph->edRemoveLink(o1_1,i1_4);
+ graph->checkConsistency(info);
+ CPPUNIT_ASSERT(1==info.getNumberOfWarnLinksGrp(W_ALL));
+ CPPUNIT_ASSERT(1==info.getNumberOfErrLinks(E_ALL));
+ CPPUNIT_ASSERT(1==info.getNumberOfErrLinks(E_UNCOMPLETE_SW));
+ delete graph;
+}