Salome HOME
Update copyrights
[modules/yacs.git] / src / yacsloader / Test / YacsLoaderTest.cxx
1 // Copyright (C) 2006-2019  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include "yacsconfig.h"
21 #include "RuntimeSALOME.hxx"
22 #include "PythonPorts.hxx"
23 #include "CORBAPorts.hxx"
24 #include "YacsLoaderTest.hxx"
25 #include "parsers.hxx"
26 #include "Proc.hxx"
27 #include "Exception.hxx"
28 #include "Executor.hxx"
29 #include "parsers.hxx"
30
31 #include <iostream>
32 #include <fstream>
33 #include <stdlib.h>
34 #ifdef WIN32
35 #include <io.h>
36 #define F_OK 0
37 #define access _access
38 #else
39 #include <unistd.h>
40 #endif
41
42 //#define _DEVDEBUG_
43 #include "YacsTrace.hxx"
44
45 using namespace YACS::ENGINE;
46 using namespace YACS;
47 using namespace std;
48
49 int driverTest(Proc* &p, const char* schema)
50 {
51   DEBTRACE("+++++++++++++++++++ BEGIN test " << schema);
52   RuntimeSALOME::setRuntime();
53
54   YACSLoader loader;
55   Executor executor;
56   try
57     {
58       p=loader.load(schema);
59         
60       std::cerr << __FILE__ << std::endl;
61       DEBTRACE("Proc *p = " << p);
62       std::ofstream f("toto");
63       p->writeDot(f);
64       f.close();
65       DEBTRACE("+++++++++++++++++++ BEGIN execution " << schema);
66       std::cerr << __FILE__ << std::endl;    
67       executor.RunW(p,0);
68       std::cerr << __FILE__ << std::endl;
69
70       DEBTRACE("+++++++++++++++++++   END execution " << schema);
71       std::ofstream g("titi");
72       p->writeDot(g);
73       g.close();
74       DEBTRACE("+++++++++++++++++++ END test " << schema);
75       return 0;
76     }
77   catch (YACS::Exception& e)
78     {
79       DEBTRACE("YACS exception caught: ");
80         std::cerr << __FILE__ << std::endl;
81       DEBTRACE(e.what());
82         std::cerr << __FILE__ << std::endl;
83
84       DEBTRACE("+++++++++++++++++++ END test in error " << schema);
85       return 1;
86     }
87   catch (const std::ios_base::failure&)
88     {
89         std::cerr << __FILE__ << std::endl;
90
91       DEBTRACE("io failure");
92   std::cerr << __FILE__ << std::endl;
93
94       DEBTRACE("+++++++++++++++++++ END test in error " << schema);
95       return 1;
96     }
97   catch(CORBA::SystemException& ex)
98     {
99       DEBTRACE("Caught a CORBA::SystemException.");
100       CORBA::Any tmp;
101       tmp <<= ex;
102       CORBA::TypeCode_var tc = tmp.type();
103       const char *p = tc->name();
104       if ( *p != '\0' )
105         {
106             std::cerr << __FILE__ << std::endl;
107
108           DEBTRACE(p);
109         }
110       else
111         {
112   std::cerr << __FILE__ << std::endl;
113           DEBTRACE(tc->id());
114         }
115       DEBTRACE("+++++++++++++++++++ END test in error " << schema);
116       return 1;
117     }
118   catch(omniORB::fatalException& fe)
119     {
120       DEBTRACE("Caught omniORB::fatalException:" );
121       DEBTRACE("  file: " << fe.file());
122       DEBTRACE("  line: " << fe.line());
123       DEBTRACE("  mesg: " << fe.errmsg());
124       DEBTRACE("+++++++++++++++++++ END test in error " << schema);
125       return 1;
126     }
127   catch(...)
128     {
129       DEBTRACE("Caught unknown exception.");
130       DEBTRACE("+++++++++++++++++++ END test in error " << schema);
131       return 1;
132     }
133 }
134
135 void YacsLoaderTest::setUp()
136 {
137 }
138
139 void YacsLoaderTest::tearDown()
140 {
141 }
142
143 void YacsLoaderTest::aschema()
144 {
145   Proc *p = 0;
146   int ret = driverTest(p, "samples/aschema.xml");
147   CPPUNIT_ASSERT(ret == 0);
148   CPPUNIT_ASSERT(p != 0);
149   if (p)
150     {
151       CORBA::Double dval = 0;
152       char *text = (char*)"";
153       CPPUNIT_ASSERT(p->nodeMap["c0.c1.n1"]);
154       *((OutputCorbaPort*)p->nodeMap["c0.c1.n1"]->getOutputPort("p1"))->getAny() >>= dval;
155       PyObject *data = ((OutputPyPort*)p->nodeMap["node32"]->getOutputPort("p1"))->get();
156       double val = PyFloat_AsDouble(data);
157       CPPUNIT_ASSERT_DOUBLES_EQUAL(22., dval, 1.E-12);
158       CPPUNIT_ASSERT_DOUBLES_EQUAL(20., val, 1.E-12);
159       delete p;
160     }
161 }
162
163 void YacsLoaderTest::bschema()
164 {
165   Proc *p = 0;
166   int ret = driverTest(p, "samples/bschema.xml");
167   CPPUNIT_ASSERT(ret == 0);
168   DEBTRACE("Proc *p = " << p);
169   CPPUNIT_ASSERT(p != 0);
170   if (p)
171     {
172       CORBA::Double dval = 0;
173       const char *text = "";
174       *((OutputCorbaPort*)p->nodeMap["node1"]->getOutputPort("p1"))->getAny() >>= dval;
175       *((OutputCorbaPort*)p->nodeMap["node2"]->getOutputPort("p1"))->getAny() >>= text;
176       CPPUNIT_ASSERT_DOUBLES_EQUAL(24., dval, 1.E-12);
177       CPPUNIT_ASSERT_EQUAL(string("coucou"), string(text));
178       delete p;
179     }
180 }
181
182 void YacsLoaderTest::cschema()
183 {
184   Proc *p = 0;
185   int ret = driverTest(p, "samples/cschema.xml");
186   CPPUNIT_ASSERT(ret == 0);
187   DEBTRACE("Proc *p = " << p);
188   CPPUNIT_ASSERT(p != 0);
189 #ifdef SALOME_KERNEL
190   if (p)
191     {
192       if(getenv("PYHELLO_ROOT_DIR"))
193         {
194           std::string hellodir(getenv("PYHELLO_ROOT_DIR"));
195           hellodir=hellodir+"/share/salome/resources/pyhello";
196           if(access(hellodir.c_str(),F_OK) == 0)
197             {
198               CORBA::Double dval = 0;
199               const char *text = "";
200               *((OutputCorbaPort*)p->nodeMap["node1"]->getOutputPort("p1"))->getAny() >>= text;
201               CPPUNIT_ASSERT_EQUAL(string("Hello coucou!"), string(text) );
202               text = "";
203               *((OutputCorbaPort*)p->nodeMap["node2"]->getOutputPort("p1"))->getAny() >>= text;
204               CPPUNIT_ASSERT_EQUAL(string("Hello Hello coucou!!"), string(text) );
205             }
206         }
207       delete p;
208     }
209 #endif
210 }
211
212 void YacsLoaderTest::dschema()
213 {
214   Proc *p = 0;
215   int ret = driverTest(p, "samples/dschema.xml");
216   CPPUNIT_ASSERT(ret == 0);
217   DEBTRACE("Proc *p = " << p);
218   CPPUNIT_ASSERT(p != 0);
219 #ifdef SALOME_KERNEL
220   if (p)
221     {
222       if(getenv("PYHELLO_ROOT_DIR"))
223         {
224           std::string hellodir(getenv("PYHELLO_ROOT_DIR"));
225           hellodir=hellodir+"/share/salome/resources/pyhello";
226           if(access(hellodir.c_str(),F_OK) == 0)
227             {
228               CORBA::Double dval = 0;
229               const char *text = "";
230               *((OutputCorbaPort*)p->nodeMap["node1"]->getOutputPort("p1"))->getAny() >>= text;
231               CPPUNIT_ASSERT_EQUAL(string("Hello coucou!"), string(text) );
232               text = "";
233               *((OutputCorbaPort*)p->nodeMap["node2"]->getOutputPort("p1"))->getAny() >>= text;
234               CPPUNIT_ASSERT_EQUAL(string("Hello Hello coucou!!"), string(text) );
235               text = "";
236               *((OutputCorbaPort*)p->nodeMap["node3"]->getOutputPort("p1"))->getAny() >>= text;
237               CPPUNIT_ASSERT_EQUAL( string("Hello Hello coucou!!"), string(text));
238             }
239         }
240       delete p;
241     }
242 #endif
243 }
244
245 void YacsLoaderTest::eschema()
246 {
247   Proc *p = 0;
248   int ret = driverTest(p, "samples/eschema.xml");
249   CPPUNIT_ASSERT(ret == 0);
250   DEBTRACE("Proc *p = " << p);
251   CPPUNIT_ASSERT(p != 0);
252   if (p)
253     {
254       PyObject *data = ((OutputPyPort*)p->nodeMap["node2"]->getOutputPort("p1"))->get();
255       char *text = PyUnicode_AsUTF8(data);
256       CPPUNIT_ASSERT_EQUAL(string("coucoucoucoucoucoucoucou"), string(text));
257       delete p;
258     }
259 }
260
261 void YacsLoaderTest::fschema()
262 {
263   Proc *p = 0;
264   int ret = driverTest(p, "samples/fschema.xml");
265   CPPUNIT_ASSERT(ret == 0);
266   DEBTRACE("Proc *p = " << p);
267   CPPUNIT_ASSERT(p != 0);
268   if (p)
269     {
270       PyObject *data = ((OutputPyPort*)p->nodeMap["node2"]->getOutputPort("p1"))->get();
271       char *text = PyUnicode_AsUTF8(data);
272       CPPUNIT_ASSERT_EQUAL(string("coucoucoucoucoucoucoucou"), string(text) );
273       delete p;
274     }
275 }
276
277 void YacsLoaderTest::oschema()
278 {
279   Proc *p = 0;
280   int ret = driverTest(p, "samples/oschema.xml");
281   CPPUNIT_ASSERT(ret == 1);
282 }
283
284 void YacsLoaderTest::pschema()
285 {
286   Proc *p = 0;
287   int ret = driverTest(p, "samples/pschema.xml");
288   CPPUNIT_ASSERT(ret == 0);
289   DEBTRACE("Proc *p = " << p);
290   CPPUNIT_ASSERT(p != 0);
291   if (p)
292     {
293       {
294         CORBA::Double dval = 0;
295         *((OutputCorbaPort*)p->nodeMap["node61"]->getOutputPort("p1"))->getAny() >>= dval;
296         CPPUNIT_ASSERT_DOUBLES_EQUAL(25., dval, 1.E-12);
297       }
298       {
299         CORBA::Double dval = 0;
300         *((OutputCorbaPort*)p->nodeMap["node62"]->getOutputPort("p1"))->getAny() >>= dval;
301         CPPUNIT_ASSERT_DOUBLES_EQUAL(25., dval, 1.E-12);
302       }
303       {
304         CORBA::Double dval = 0;
305         *((OutputCorbaPort*)p->nodeMap["node63"]->getOutputPort("p1"))->getAny() >>= dval;
306         CPPUNIT_ASSERT_DOUBLES_EQUAL(25., dval, 1.E-12);
307       }
308       delete p;
309     }
310 }
311
312 void YacsLoaderTest::schema()
313 {
314   Proc *p = 0;
315   int ret = driverTest(p, "samples/schema.xml");
316   CPPUNIT_ASSERT(ret == 1);
317 }
318
319 void YacsLoaderTest::schema2()
320 {
321   Proc *p = 0;
322   int ret = driverTest(p, "samples/schema2.xml");
323   CPPUNIT_ASSERT(ret == 0);
324   DEBTRACE("Proc *p = " << p);
325   CPPUNIT_ASSERT(p != 0);
326   if (p)
327     {
328       {
329         CORBA::Double dval = 0;
330         *((OutputCorbaPort*)p->nodeMap["node61"]->getOutputPort("p1"))->getAny() >>= dval;
331         CPPUNIT_ASSERT_DOUBLES_EQUAL(25., dval, 1.E-12);
332       }
333       {
334         CORBA::Double dval = 0;
335         *((OutputCorbaPort*)p->nodeMap["node62"]->getOutputPort("p1"))->getAny() >>= dval;
336         CPPUNIT_ASSERT_DOUBLES_EQUAL(25., dval, 1.E-12);
337       }
338       {
339         CORBA::Double dval = 0;
340         *((OutputCorbaPort*)p->nodeMap["node63"]->getOutputPort("p1"))->getAny() >>= dval;
341         CPPUNIT_ASSERT_DOUBLES_EQUAL(25., dval, 1.E-12);
342       }
343       try
344         {
345           delete p;
346         }
347       catch (YACS::Exception& e)
348         {
349           DEBTRACE("YACS exception caught: ");
350           DEBTRACE(e.what());
351         }
352       catch (const std::ios_base::failure&)
353         {
354           DEBTRACE("io failure");
355         }
356       catch(CORBA::SystemException& ex)
357         {
358           DEBTRACE("Caught a CORBA::SystemException.");
359           CORBA::Any tmp;
360           tmp <<= ex;
361           CORBA::TypeCode_var tc = tmp.type();
362           const char *p = tc->name();
363           if ( *p != '\0' )
364             {
365               DEBTRACE(p);
366             }
367           else
368             {
369               DEBTRACE(tc->id());
370             }
371         }
372       catch(omniORB::fatalException& fe)
373         {
374           DEBTRACE("Caught omniORB::fatalException:" );
375           DEBTRACE("  file: " << fe.file());
376           DEBTRACE("  line: " << fe.line());
377           DEBTRACE("  mesg: " << fe.errmsg());
378         }
379       catch(...)
380         {
381           DEBTRACE("unknown exception");
382         }
383     }
384 }
385
386 void YacsLoaderTest::forloop1()
387 {
388   Proc *p = 0;
389   int ret = driverTest(p, "samples/forloop1.xml");
390   CPPUNIT_ASSERT(ret == 0);
391   DEBTRACE("Proc *p = " << p);
392   CPPUNIT_ASSERT(p != 0);
393   if (p)
394     {
395       PyObject *data = ((OutputPyPort*)p->nodeMap["b1.node2"]->getOutputPort("p1"))->get();
396       double val = PyFloat_AsDouble(data);;
397       CPPUNIT_ASSERT_DOUBLES_EQUAL(33., val, 1.E-12);
398       delete p;
399     }
400 }
401
402 void YacsLoaderTest::forloop2()
403 {
404   Proc *p = 0;
405   int ret = driverTest(p, "samples/forloop2.xml");
406   CPPUNIT_ASSERT(ret == 0);
407 }
408
409 /////////////////////////////
410
411 void YacsLoaderTest::forloop3()
412 {
413   Proc *p = 0;
414   int ret = driverTest(p, "samples/forloop3.xml");
415   CPPUNIT_ASSERT(ret == 0);
416   DEBTRACE("Proc *p = " << p);
417   CPPUNIT_ASSERT(p != 0);
418   if (p)
419     {
420       delete p;
421     }
422 }
423
424 void YacsLoaderTest::forloop4()
425 {
426   Proc *p = 0;
427   int ret = driverTest(p, "samples/forloop4.xml");
428   CPPUNIT_ASSERT(ret == 0);
429   DEBTRACE("Proc *p = " << p);
430   CPPUNIT_ASSERT(p != 0);
431   if (p)
432     {
433       delete p;
434     }
435 }
436
437 void YacsLoaderTest::forloop5()
438 {
439   Proc *p = 0;
440   int ret = driverTest(p, "samples/forloop5.xml");
441   CPPUNIT_ASSERT(ret == 0);
442   DEBTRACE("Proc *p = " << p);
443   CPPUNIT_ASSERT(p != 0);
444   if (p)
445     {
446       delete p;
447     }
448 }
449
450 void YacsLoaderTest::forloop6()
451 {
452   Proc *p = 0;
453   int ret = driverTest(p, "samples/forloop6.xml");
454   CPPUNIT_ASSERT(ret == 0);
455   DEBTRACE("Proc *p = " << p);
456   CPPUNIT_ASSERT(p != 0);
457   if (p)
458     {
459       delete p;
460     }
461 }
462
463
464 void YacsLoaderTest::forloop7()
465 {
466   Proc *p = 0;
467   int ret = driverTest(p, "samples/forloop7.xml");
468   CPPUNIT_ASSERT(ret == 0);
469   DEBTRACE("Proc *p = " << p);
470   CPPUNIT_ASSERT(p != 0);
471   if (p)
472     {
473       delete p;
474     }
475 }
476
477 void YacsLoaderTest::switch1()
478 {
479   Proc *p = 0;
480   int ret = driverTest(p, "samples/switch1.xml");
481   CPPUNIT_ASSERT(ret == 0);
482   DEBTRACE("Proc *p = " << p);
483   CPPUNIT_ASSERT(p != 0);
484   if (p)
485     {
486       delete p;
487     }
488 }
489
490 void YacsLoaderTest::switch2()
491 {
492   Proc *p = 0;
493   int ret = driverTest(p, "samples/switch2.xml");
494   CPPUNIT_ASSERT(ret == 0);
495   DEBTRACE("Proc *p = " << p);
496   CPPUNIT_ASSERT(p != 0);
497   if (p)
498     {
499       delete p;
500     }
501 }
502
503 void YacsLoaderTest::switch3()
504 {
505   Proc *p = 0;
506   int ret = driverTest(p, "samples/switch3.xml");
507   CPPUNIT_ASSERT(ret == 0);
508   DEBTRACE("Proc *p = " << p);
509   CPPUNIT_ASSERT(p != 0);
510   if (p)
511     {
512       delete p;
513     }
514 }
515
516 void YacsLoaderTest::switch4()
517 {
518   Proc *p = 0;
519   int ret = driverTest(p, "samples/switch4.xml");
520   CPPUNIT_ASSERT(ret == 0);
521   DEBTRACE("Proc *p = " << p);
522   CPPUNIT_ASSERT(p != 0);
523   if (p)
524     {
525       delete p;
526     }
527 }
528
529 void YacsLoaderTest::switch5()
530 {
531   Proc *p = 0;
532   int ret = driverTest(p, "samples/switch5.xml");
533   CPPUNIT_ASSERT(ret == 0);
534   DEBTRACE("Proc *p = " << p);
535   CPPUNIT_ASSERT(p != 0);
536   if (p)
537     {
538       delete p;
539     }
540 }
541
542 void YacsLoaderTest::switch6()
543 {
544   Proc *p = 0;
545   int ret = driverTest(p, "samples/switch6.xml");
546   CPPUNIT_ASSERT(ret == 0);
547   DEBTRACE("Proc *p = " << p);
548   CPPUNIT_ASSERT(p != 0);
549   if (p)
550     {
551       delete p;
552     }
553 }
554
555 void YacsLoaderTest::switch7()
556 {
557   Proc *p = 0;
558   int ret = driverTest(p, "samples/switch7.xml");
559   CPPUNIT_ASSERT(ret == 0);
560   DEBTRACE("Proc *p = " << p);
561   CPPUNIT_ASSERT(p != 0);
562   if (p)
563     {
564       delete p;
565     }
566 }
567
568 void YacsLoaderTest::switch8()
569 {
570   Proc *p = 0;
571   int ret = driverTest(p, "samples/switch8.xml");
572   CPPUNIT_ASSERT(ret == 0);
573   DEBTRACE("Proc *p = " << p);
574   CPPUNIT_ASSERT(p != 0);
575   if (p)
576     {
577       delete p;
578     }
579 }
580
581 void YacsLoaderTest::switch9()
582 {
583   Proc *p = 0;
584   int ret = driverTest(p, "samples/switch9.xml");
585   CPPUNIT_ASSERT(ret == 0);
586   DEBTRACE("Proc *p = " << p);
587   CPPUNIT_ASSERT(p != 0);
588   if (p)
589     {
590       delete p;
591     }
592 }
593
594 void YacsLoaderTest::whiles()
595 {
596   Proc *p = 0;
597   int ret = driverTest(p, "samples/while1.xml");
598   CPPUNIT_ASSERT(ret == 0);
599   DEBTRACE("Proc *p = " << p);
600   CPPUNIT_ASSERT(p != 0);
601   if (p)
602     {
603       delete p;
604     }
605   ret = driverTest(p, "samples/while2.xml");
606   CPPUNIT_ASSERT(ret == 0);
607   ret = driverTest(p, "samples/while3.xml");
608   CPPUNIT_ASSERT(ret == 0);
609 }
610
611 void YacsLoaderTest::forwhile1()
612 {
613   Proc *p = 0;
614   int ret = driverTest(p, "samples/forwhile1.xml");
615   CPPUNIT_ASSERT(ret == 0);
616   DEBTRACE("Proc *p = " << p);
617   CPPUNIT_ASSERT(p != 0);
618   if (p)
619     {
620       delete p;
621     }
622 }
623
624 void YacsLoaderTest::blocs()
625 {
626   Proc *p = 0;
627   int ret;
628   ret = driverTest(p, "samples/bloc1.xml");
629   CPPUNIT_ASSERT(ret == 0);
630   CPPUNIT_ASSERT(p->getEffectiveState() == YACS::DONE );
631   ret = driverTest(p, "samples/bloc2.xml");
632   CPPUNIT_ASSERT(ret == 0);
633   CPPUNIT_ASSERT(p->getEffectiveState() == YACS::DONE );
634   ret = driverTest(p, "samples/bloc3.xml");
635   CPPUNIT_ASSERT(ret == 0);
636   CPPUNIT_ASSERT(p->getEffectiveState() != YACS::DONE );
637   ret = driverTest(p, "samples/bloc4.xml");
638   CPPUNIT_ASSERT(ret == 0);
639   CPPUNIT_ASSERT(p->getEffectiveState() == YACS::DONE );
640 }
641
642 void YacsLoaderTest::refcnt()
643 {
644   Proc *p = 0;
645   int ret;
646   PyObject *data;
647   ret = driverTest(p, "samples/refcnt1.xml");
648   CPPUNIT_ASSERT(ret == 0);
649   data = ((OutputPyPort*)p->nodeMap["b1.b.node1"]->getOutputPort("p1"))->get();
650   CPPUNIT_ASSERT(data->ob_refcnt==13);
651   ret = driverTest(p, "samples/refcnt2.xml");
652   CPPUNIT_ASSERT(ret == 0);
653   data = ((OutputPyPort*)p->nodeMap["b1.b.node1"]->getOutputPort("p1"))->get();
654   CPPUNIT_ASSERT(data->ob_refcnt==19);
655 }
656
657 void YacsLoaderTest::foreachs()
658 {
659   Proc *p = 0;
660   int ret;
661   ret = driverTest(p, "samples/foreach1.xml");
662   CPPUNIT_ASSERT_MESSAGE("Schema: foreach1.xml", ret == 0);
663   CPPUNIT_ASSERT_MESSAGE("Schema: foreach1.xml", p->getEffectiveState() == YACS::DONE);
664   delete p;
665   ret = driverTest(p, "samples/foreach2.xml");
666   CPPUNIT_ASSERT_MESSAGE("Schema: foreach2.xml", ret == 0);
667   CPPUNIT_ASSERT_MESSAGE("Schema: foreach2.xml", p->getEffectiveState() == YACS::DONE );
668   delete p;
669   ret = driverTest(p, "samples/foreach3.xml");
670   CPPUNIT_ASSERT_MESSAGE("Schema: foreach3.xml", ret == 1);
671   delete p;
672   ret = driverTest(p, "samples/foreach4.xml");
673   CPPUNIT_ASSERT_MESSAGE("Schema: foreach4.xml", ret == 0);
674   CPPUNIT_ASSERT_MESSAGE("Schema: foreach4.xml", p->getEffectiveState() == YACS::DONE );
675   delete p;
676   ret = driverTest(p, "samples/foreach5.xml");
677   CPPUNIT_ASSERT_MESSAGE("Schema: foreach5.xml", ret == 0);
678   CPPUNIT_ASSERT_MESSAGE("Schema: foreach5.xml", p->getEffectiveState() == YACS::DONE );
679   delete p;
680   ret = driverTest(p, "samples/foreach6.xml");
681   CPPUNIT_ASSERT_MESSAGE("Schema: foreach6.xml", ret == 0);
682   CPPUNIT_ASSERT_MESSAGE("Schema: foreach6.xml", p->getEffectiveState() == YACS::DONE );
683   delete p;
684   ret = driverTest(p, "samples/foreach8.xml");
685   CPPUNIT_ASSERT_MESSAGE("Schema: foreach8.xml", ret == 0);
686   CPPUNIT_ASSERT_MESSAGE("Schema: foreach8.xml", p->getEffectiveState() == YACS::DONE );
687   delete p;
688   ret = driverTest(p, "samples/foreach_init2fin.xml");
689   CPPUNIT_ASSERT_MESSAGE("Schema: foreach_init2fin.xml", ret == 0);
690   CPPUNIT_ASSERT_MESSAGE("Schema: foreach_init2fin.xml", p->getEffectiveState() == YACS::DONE );
691   delete p;
692   ret = driverTest(p, "samples/foreach_init2work.xml");
693   CPPUNIT_ASSERT_MESSAGE("Schema: foreach_init2work.xml", ret == 0);
694   CPPUNIT_ASSERT_MESSAGE("Schema: foreach_init2work.xml", p->getEffectiveState() == YACS::DONE );
695   CPPUNIT_ASSERT_EQUAL(p->getOutputPort("PostProc.r")->getAsString(), std::string("108"));
696   delete p;
697   if(getenv("GEOM_ROOT_DIR"))
698     {
699       std::string geomdir(getenv("GEOM_ROOT_DIR"));
700       geomdir=geomdir+"/share/salome/resources/geom";
701       if(access(geomdir.c_str(),F_OK) == 0)
702       {
703         ret = driverTest(p, "samples/foreach7.xml"); //needs GEOM_Superv component
704         CPPUNIT_ASSERT_MESSAGE("Schema: foreach7.xml", ret == 0);
705         CPPUNIT_ASSERT_MESSAGE("Schema: foreach7.xml", p->getEffectiveState() == YACS::DONE );
706         delete p;
707       }
708     }
709 }
710
711 void YacsLoaderTest::sinlines()
712 {
713   Proc *p = 0;
714   int ret;
715   ret = driverTest(p, "samples/sinline1.xml");
716   CPPUNIT_ASSERT(ret == 0);
717   CPPUNIT_ASSERT(p->getEffectiveState() == YACS::DONE );
718   ret = driverTest(p, "samples/sinline2.xml");
719   CPPUNIT_ASSERT(ret == 0);
720   CPPUNIT_ASSERT(p->getEffectiveState() == YACS::DONE );
721   ret = driverTest(p, "samples/sinline3.xml");
722   CPPUNIT_ASSERT(ret == 0);
723   CPPUNIT_ASSERT(p->getEffectiveState() == YACS::DONE );
724   ret = driverTest(p, "samples/sinline4.xml");
725   CPPUNIT_ASSERT(ret == 0);
726   CPPUNIT_ASSERT(p->getEffectiveState() == YACS::DONE );
727   ret = driverTest(p, "samples/sinline5.xml");
728   CPPUNIT_ASSERT(ret == 0);
729   CPPUNIT_ASSERT(p->getEffectiveState() == YACS::DONE );
730 }
731
732 void YacsLoaderTest::bools()
733 {
734   Proc *p = 0;
735   int ret;
736   ret = driverTest(p, "samples/bool1.xml");
737   CPPUNIT_ASSERT(ret == 0);
738   CPPUNIT_ASSERT(p->getEffectiveState() == YACS::DONE );
739 }
740 void YacsLoaderTest::integers()
741 {
742   Proc *p = 0;
743   int ret;
744   ret = driverTest(p, "samples/integer1.xml");
745   CPPUNIT_ASSERT(ret == 0);
746   CPPUNIT_ASSERT(p->getEffectiveState() == YACS::DONE );
747 }
748 void YacsLoaderTest::doubles()
749 {
750   Proc *p = 0;
751   int ret;
752   ret = driverTest(p, "samples/double1.xml");
753   CPPUNIT_ASSERT(ret == 0);
754   CPPUNIT_ASSERT(p->getEffectiveState() == YACS::DONE );
755 }
756 void YacsLoaderTest::strings()
757 {
758   Proc *p = 0;
759   int ret;
760   ret = driverTest(p, "samples/string1.xml");
761   CPPUNIT_ASSERT(ret == 0);
762   CPPUNIT_ASSERT(p->getEffectiveState() == YACS::DONE );
763 }
764 void YacsLoaderTest::objrefs()
765 {
766   Proc *p = 0;
767   int ret;
768   ret = driverTest(p, "samples/objref1.xml");
769   CPPUNIT_ASSERT(ret == 0);
770   CPPUNIT_ASSERT(p->getEffectiveState() == YACS::DONE );
771 }
772 void YacsLoaderTest::structs()
773 {
774   Proc *p = 0;
775   int ret;
776   ret = driverTest(p, "samples/struct1.xml");
777   CPPUNIT_ASSERT(ret == 0);
778   CPPUNIT_ASSERT(p->getEffectiveState() == YACS::DONE );
779   delete p;
780
781   ret = driverTest(p, "samples/struct2.xml");
782   CPPUNIT_ASSERT(ret == 0);
783   CPPUNIT_ASSERT(p->getEffectiveState() == YACS::DONE );
784   delete p;
785 }
786
787 void YacsLoaderTest::cpps()
788 {
789   Proc *p = 0;
790   int ret;
791   ret = driverTest(p, "samples/cpp1.xml");
792   CPPUNIT_ASSERT(ret == 0);
793   CPPUNIT_ASSERT(p->getEffectiveState() == YACS::DONE );
794   delete p;
795 }
796
797 void YacsLoaderTest::datanodes()
798 {
799   Proc *p = 0;
800   int ret;
801   ret = driverTest(p, "samples/datanode0.xml");
802   CPPUNIT_ASSERT(ret == 0);
803   CPPUNIT_ASSERT(p->getEffectiveState() == YACS::DONE );
804   delete p;
805 }
806
807 void YacsLoaderTest::optimizers()
808 {
809   Proc *p = 0;
810   int ret;
811   ret = driverTest(p, "samples/optimizer1.xml");
812   CPPUNIT_ASSERT(ret == 0);
813   CPPUNIT_ASSERT(p->getEffectiveState() == YACS::DONE );
814   delete p;
815
816   ret = driverTest(p, "samples/optimizer2.xml");
817   CPPUNIT_ASSERT(ret == 0);
818   CPPUNIT_ASSERT(p->getEffectiveState() == YACS::DONE );
819   delete p;
820
821   ret = driverTest(p, "samples/optimizer_sync_cpp.xml");
822   CPPUNIT_ASSERT(ret == 0);
823   CPPUNIT_ASSERT(p->getEffectiveState() == YACS::DONE );
824   delete p;
825
826   ret = driverTest(p, "samples/optimizer_async_cpp.xml");
827   CPPUNIT_ASSERT(ret == 0);
828   CPPUNIT_ASSERT(p->getEffectiveState() == YACS::DONE );
829   delete p;
830
831   ret = driverTest(p, "samples/optimizer_sync_py.xml");
832   CPPUNIT_ASSERT(ret == 0);
833   CPPUNIT_ASSERT(p->getEffectiveState() == YACS::DONE );
834   delete p;
835
836   ret = driverTest(p, "samples/optimizer_async_py.xml");
837   CPPUNIT_ASSERT(ret == 0);
838   CPPUNIT_ASSERT(p->getEffectiveState() == YACS::DONE );
839   delete p;
840
841   ret = driverTest(p, "samples/optimizer_retro.xml");
842   CPPUNIT_ASSERT(ret == 0);
843   CPPUNIT_ASSERT(p->getEffectiveState() == YACS::DONE );
844   delete p;
845 }
846
847 void YacsLoaderTest::pyremotes()
848 {
849   Proc *p = 0;
850   int ret;
851   ret = driverTest(p, "samples/pyremote1.xml");
852   CPPUNIT_ASSERT(ret == 0);
853   CPPUNIT_ASSERT(p->getEffectiveState() == YACS::DONE );
854   ret = driverTest(p, "samples/pyremote2.xml");
855   CPPUNIT_ASSERT(ret == 0);
856   CPPUNIT_ASSERT(p->getEffectiveState() == YACS::DONE );
857   ret = driverTest(p, "samples/pyremote3.xml");
858   CPPUNIT_ASSERT(ret == 0);
859   CPPUNIT_ASSERT(p->getEffectiveState() == YACS::DONE );
860   ret = driverTest(p, "samples/pyremote4.xml");
861   CPPUNIT_ASSERT(ret == 0);
862   CPPUNIT_ASSERT(p->getEffectiveState() == YACS::DONE );
863 }
864
865 void YacsLoaderTest::nonepyobj()
866 {
867   Proc *p = 0;
868   int ret;
869   ret = driverTest(p, "samples/nonepyobj.xml");
870   CPPUNIT_ASSERT(ret == 0);
871   CPPUNIT_ASSERT(p->getEffectiveState() == YACS::DONE );
872   CPPUNIT_ASSERT_EQUAL(p->getOutputPort("n2.r")->getAsString(), std::string("True"));
873   delete p;
874 }