Version: 9.16.0
testCppPluginInvokation.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2# Copyright (C) 2018-2026 CEA, EDF
3#
4# This library is free software; you can redistribute it and/or
5# modify it under the terms of the GNU Lesser General Public
6# License as published by the Free Software Foundation; either
7# version 2.1 of the License, or (at your option) any later version.
8#
9# This library is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12# Lesser General Public License for more details.
13#
14# You should have received a copy of the GNU Lesser General Public
15# License along with this library; if not, write to the Free Software
16# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17#
18# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19#
20
21import unittest
22import pilot
23import SALOMERuntime
24import loader
25
26
27SALOMERuntime.RuntimeSALOME.setRuntime()
28r=SALOMERuntime.getSALOMERuntime()
29
30p=r.createProc("prTest1")
31ti=p.createType("int","int")
32tdi=p.createSequenceTc("seqint","seqint",ti)
33
34node0=r.createScriptNode("Salome","Func0")
35node0.setScript("""o1=[1,4,3,2,0,6,7,8]""")
36out0=node0.edAddOutputPort("o1",tdi)
37p.edAddChild(node0)
38#
39node1=r.createForEachLoop("ForEachLoop_pyobj1",ti)
40p.edAddChild(node1)
41p.edAddCFLink(node0,node1)
42p.edAddLink(out0,node1.edGetSeqOfSamplesPort())
43node1.edGetNbOfBranchesPort().edInitInt(2)
44#
45node2=r.createScriptNode("Salome","Func1")
46node2.setScript("""o2=i1*i1""")
47i1=node2.edAddInputPort("i1",ti)
48o2=node2.edAddOutputPort("o2",ti)
49node1.edAddChild(node2)
50p.edAddLink(node1.edGetSamplePort(),i1)
51
52p.saveSchema("thomas.xml")
53
54ex=pilot.ExecutorSwig()
55assert(p.getState()==pilot.READY)
56pilot.LoadObserversPluginIfAny(p,ex)
57ex.RunW(p,0)
58assert(p.getState()==pilot.DONE)
59pilot.UnLoadObserversPluginIfAny()
60
61
62for i in range(100):
63 print(30*"*"+" %d"%i)
64 l=loader.YACSLoader()
65 p=l.load("thomas.xml")
66 ex=pilot.ExecutorSwig()
67 assert(p.getState()==pilot.READY)
68 pilot.LoadObserversPluginIfAny(p,ex)
69 ex.RunW(p,0)
70 assert(p.getState()==pilot.DONE)
71 pilot.UnLoadObserversPluginIfAny()
72