X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fengine%2FTest%2FengineIntegrationTest.cxx;h=e2cac77a8d6197e295d141eed868b433e08b81ef;hb=651bb7e30a03a485c89c611a237484992b9c5eb1;hp=a2026e1d3c3aefb4435214b675428bfe083d0acb;hpb=802458daad8b198beabbb058dc87437bdc63b1a3;p=modules%2Fyacs.git diff --git a/src/engine/Test/engineIntegrationTest.cxx b/src/engine/Test/engineIntegrationTest.cxx index a2026e1d3..e2cac77a8 100644 --- a/src/engine/Test/engineIntegrationTest.cxx +++ b/src/engine/Test/engineIntegrationTest.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2006-2015 CEA/DEN, EDF R&D +// Copyright (C) 2006-2016 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -2274,7 +2274,7 @@ void EngineIntegrationTest::testForEachLoop2() graph->edAddLink(forEach->edGetSamplePort(),i32); graph->edAddLink(o31,n4->edGetInValue1()); graph->edAddLink(n2->edGetSeqOut(),n4->edGetInValue2()); - CPPUNIT_ASSERT(dynamic_cast(graph->getOutputPort("myFE.blocToShakeBaby.T3.o31"))); + CPPUNIT_ASSERT(graph->getOutputPort("myFE.blocToShakeBaby.T3.o31")); int tab[]={12,14,16,18,20}; vector tabv(tab,tab+5); SequenceAnyPtr tmp=SequenceAny::New(tabv);//expected sequence @@ -2565,6 +2565,7 @@ void EngineIntegrationTest::testForEachLoop5() delete graph2; } + /*! * Here a test for OptimizerLoop with an evenemential (or synchronous) algorithm */ @@ -2582,9 +2583,9 @@ void EngineIntegrationTest::testForOptimizerLoop1() InputPort *i1=n1->edAddInputPort("i1",Runtime::_tc_double); OutputPort *o1=n1->edAddOutputPort("o1",Runtime::_tc_double); graph->edAddLink(opt->edGetSamplePort(),i1); - InputPort *i2=n2->edAddInputPort("i2",Runtime::_tc_double); + InputPort *i2=n2->edAddInputPort("i2",opt->edGetAlgoResultPort()->edGetType()); OutputPort *o2_1=n2->edAddOutputPort("o1",Runtime::_tc_double); - graph->edAddLink(o1,i2); + graph->edAddLink(opt->edGetAlgoResultPort(),i2); graph->edAddLink(n1->edGetNbOfInputsOutputPort(),opt->edGetPortForOutPool()); opt->edGetNbOfBranchesPort()->edInit(2); opt->edGetAlgoInitPort()->edInit("toto"); @@ -2634,9 +2635,9 @@ void EngineIntegrationTest::testForOptimizerLoop2() InputPort *i1=n1->edAddInputPort("i1",Runtime::_tc_double); OutputPort *o1=n1->edAddOutputPort("o1",Runtime::_tc_double); graph->edAddLink(opt->edGetSamplePort(),i1); - InputPort *i2=n2->edAddInputPort("i2",Runtime::_tc_double); + InputPort *i2=n2->edAddInputPort("i2",opt->edGetAlgoResultPort()->edGetType()); OutputPort *o2_1=n2->edAddOutputPort("o1",Runtime::_tc_double); - graph->edAddLink(o1,i2); + graph->edAddLink(opt->edGetAlgoResultPort(),i2); graph->edAddLink(n1->edGetNbOfInputsOutputPort(),opt->edGetPortForOutPool()); opt->edGetNbOfBranchesPort()->edInit(2); opt->edGetAlgoInitPort()->edInit("toto"); @@ -2666,6 +2667,46 @@ void EngineIntegrationTest::testForOptimizerLoop2() delete clone; } +/*! + * Test of illegal links within an OptimizerLoop. + */ +void EngineIntegrationTest::testForOptimizerLoop3() +{ + LinkInfo info(LinkInfo::ALL_DONT_STOP); + Bloc *graph=new Bloc("Global"); + OptimizerLoop *opt=new OptimizerLoop("myOptWthAlgSync","libPluginOptEvTest1","PluginOptEvTest1Factory",true); + graph->edAddChild(opt); + ToyNode *n1=new ToyNode("T1"); + ToyNode *n2=new ToyNode("T2"); + Bloc *bloc=new Bloc("Bloc"); + graph->edAddChild(n2); + graph->edAddCFLink(opt,n2); + opt->edSetNode(bloc); + bloc->edAddChild(n1); + InputPort *i1=n1->edAddInputPort("i1",Runtime::_tc_double); + OutputPort *o1=n1->edAddOutputPort("o1",Runtime::_tc_double); + InputPort *i2=n2->edAddInputPort("i2",opt->edGetAlgoResultPort()->edGetType()); + try + { + graph->edAddLink(opt->edGetAlgoResultPort(),i1); + CPPUNIT_FAIL("Construction of an illegal link: the result port linked to a node inside the OptimizerLoop."); + } + catch(Exception& e) + { + } + + try + { + graph->edAddLink(o1,i2); + CPPUNIT_FAIL("Construction of an illegal link: a node inside the loop linked to a node outside the OptimizerLoop."); + } + catch(Exception& e) + { + } + + delete graph; +} + /*! * Test to check that in for compil-time known connectivity of a graph, deployment calculation is OK. */ @@ -2873,9 +2914,10 @@ void EngineIntegrationTest::testForDeployment2() CPPUNIT_ASSERT(!tree.presenceOfDefaultContainer()); //Check that compatibility is checked... ComponentInstanceTest1 *comp1=new ComponentInstanceTest1("FLICA"); - n1S->setComponent(comp1); + /*n1S->setComponent(comp1); CPPUNIT_ASSERT_THROW(n4S->setComponent(comp1),YACS::Exception);//Impossible not compatible between ToyNode1S and ToyNode2S - CPPUNIT_ASSERT_THROW(n2S->setComponent(comp1),YACS::Exception);//Failure here to but due to incompatibility of scopes n2S is in a ForEachLoop and not n1S and comp1 is NOT attached here. + CPPUNIT_ASSERT_THROW(n2S->setComponent(comp1),YACS::Exception);//Failure here to but due to incompatibility of scopes n2S is in a ForEachLoop and not n1S and comp1 is NOT attached here.*/ + n1S->setComponent(comp1); comp1->attachOnCloning(); n2S->setComponent(comp1);//here it's ok because comp1 is attached... tree=graph->getDeploymentTree(); @@ -2894,7 +2936,7 @@ void EngineIntegrationTest::testForDeployment2() CPPUNIT_ASSERT_EQUAL(1, (int) tree.getNumberOfCTDefComponentInstances()); CPPUNIT_ASSERT_EQUAL(1, (int) tree.getNumberOfRTODefComponentInstances()); ComponentInstanceTest2 *comp3=new ComponentInstanceTest2("DKCORE"); n4S->setComponent(comp3); - CPPUNIT_ASSERT_THROW(n5S->setComponent(comp3),YACS::Exception);//For fun just like 19 lines before. + //CPPUNIT_ASSERT_THROW(n5S->setComponent(comp3),YACS::Exception);//For fun just like 19 lines before. comp3->attachOnCloning(); n5S->setComponent(comp3);//ok tree=graph->getDeploymentTree();