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