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