2 # Copyright (C) 2006-2019 CEA/DEN, EDF R&D
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.
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.
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
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
31 class TestResume(unittest.TestCase):
34 SALOMERuntime.RuntimeSALOME_setRuntime(1)
35 self.l = loader.YACSLoader()
36 self.e = pilot.ExecutorSwig()
37 self.p = self.l.load("samples/bloc2.xml")
38 workdir = tempfile.mkdtemp(suffix=".yacstest")
39 self.statefile = os.path.join(workdir, 'dumpPartialBloc2.xml')
42 def test1_PartialExec(self):
43 # --- stop execution after breakpoint
46 print("================= Start of PARTIALEXEC ===================")
48 self.e.setListOfBreakPoints(brp)
49 self.e.setExecMode(2) # YACS::STOPBEFORENODES
50 #self.e.displayDot(self.p)
51 run1 = threading.Thread(None, self.e.RunPy, "breakpoint", (self.p,0))
55 #self.e.displayDot(self.p)
56 self.e.saveState(self.statefile)
57 #self.e.displayDot(self.p)
58 self.e.stopExecution()
59 #self.e.displayDot(self.p)
60 self.assertEqual(101, self.p.getChildByName('b1.b2.node1').getEffectiveState())
61 self.assertEqual(106, self.p.getChildByName('b1.node1').getEffectiveState())
62 print("================= reach BREAKPOINT PARTIAL EXEC ==========")
64 # --- reload state from previous partial execution then exec
67 print("================= Start of EXECLOADEDSTATE ===============")
68 sp = loader.stateParser()
69 sl = loader.stateLoader(sp,self.p)
70 sl.parse(self.statefile)
71 #self.e.displayDot(self.p)
72 self.e.setExecMode(0) # YACS::CONTINUE
73 run2 = threading.Thread(None, self.e.RunPy, "loadState", (self.p,0,True,True))
77 #self.e.displayDot(self.p)
79 self.assertEqual(106, self.p.getChildByName('node1').getEffectiveState())
80 self.assertEqual(106, self.p.getChildByName('node2').getEffectiveState())
81 self.assertEqual(106, self.p.getChildByName('b1.node1').getEffectiveState())
82 self.assertEqual(106, self.p.getChildByName('b1.node2').getEffectiveState())
83 self.assertEqual(106, self.p.getChildByName('b1.b2.node1').getEffectiveState())
84 self.assertEqual(106, self.p.getChildByName('b1.b2.node2').getEffectiveState())
85 self.assertEqual(106, self.p.getChildByName('b1.b2.loop1.node1').getEffectiveState())
86 print("================= End of EXECLOADEDSTATE =================")
90 if __name__ == '__main__':
93 with open("/tmp/" + U + "/UnitTestsResult", 'a') as f:
94 f.write(" --- TEST src/yacsloader: testResume.py\n")
95 suite = unittest.makeSuite(TestResume)
96 result=unittest.TextTestRunner(f, descriptions=1, verbosity=1).run(suite)
97 sys.exit(not result.wasSuccessful())