]> SALOME platform Git repositories - modules/kernel.git/blob - bin/appliskel/tests/concurrentSession/testConcurrentSession.py
Salome HOME
Merge branch V7_3_1_BR
[modules/kernel.git] / bin / appliskel / tests / concurrentSession / testConcurrentSession.py
1 #!/usr/bin/env python
2 # Copyright (C) 2013-2014  CEA/DEN, EDF R&D, OPEN CASCADE
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
21 import os
22 import sys
23 import unittest
24 import multiprocessing
25 import imp
26
27 def unwrap_self_session(arg, **kwarg):
28   return TestConcurrentLaunch.session(*arg, **kwarg)
29 #
30
31 class TestConcurrentLaunch(unittest.TestCase):
32   @classmethod
33   def setUpClass(cls):
34     # Initialize path to SALOME application
35     path_to_launcher = os.getenv("SALOME_LAUNCHER")
36     appli_dir = os.path.dirname(path_to_launcher)
37     cls.envd_dir = os.path.join(appli_dir, "env.d")
38
39     # Configure session startup
40     cls.SALOME = imp.load_source("SALOME", os.path.join(appli_dir,"salome"))
41     #cls.SALOME_args = ["shell", "--config="+cls.envd_dir]
42     cls.SALOME_args = ["--config="+cls.envd_dir]
43   #
44   @classmethod
45   def tearDownClass(cls):
46     args = ["killall", "--config="+cls.envd_dir]
47     cls.SALOME.main(args)
48     pass
49   #
50   def session(self, args=[]):
51     self.SALOME.main(self.SALOME_args + args)
52   #
53   def test01_SingleSession(self):
54     print "** Testing single session **"
55     self.session()
56   #
57   def test02_MultiSession(self):
58     print "** Testing multi sessions **"
59
60     jobs = []
61     for i in range(3):
62       p = multiprocessing.Process(target=unwrap_self_session, args=([self],))
63       jobs.append(p)
64       p.start()
65
66     for j in jobs:
67       j.join()
68   #
69 #
70
71
72 if __name__ == "__main__":
73   path_to_launcher = os.getenv("SALOME_LAUNCHER")
74   if not path_to_launcher:
75     msg = "Error: please set SALOME_LAUNCHER variable to the salome command of your application folder."
76     raise Exception(msg)
77
78   unittest.main()
79 #