]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
test port manager
authoraguerre <aguerre>
Fri, 6 Sep 2013 16:15:42 +0000 (16:15 +0000)
committeraguerre <aguerre>
Fri, 6 Sep 2013 16:15:42 +0000 (16:15 +0000)
bin/appliskel/tests/concurrentSession/CMakeLists.txt
bin/appliskel/tests/concurrentSession/TestConcurrentSession.py [deleted file]
bin/appliskel/tests/concurrentSession/testConcurrentSession.py [new file with mode: 0644]

index 9c865f91af9f807f18772cea7501367c60da7c87..137ddfe53700841c11d467cbd3b8e417cabd519d 100644 (file)
@@ -23,8 +23,8 @@ ENABLE_TESTING()
 # define environment for running tests
 SET(PYTHON_VERSION ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR})
 
-SET(THIS_PYTHONPATH ${CMAKE_SOURCE_DIR}/bin/salome:$ENV{PYTHONPATH})
-#SET(THIS_LD_LIBRARY_PATH $ENV{CMAKE_SOURCE_DIR}/lib/salome:$ENV{LD_LIBRARY_PATH})
+SET(THIS_PYTHONPATH ${CMAKE_SOURCE_DIR}/bin:$ENV{PYTHONPATH})
+#SET(THIS_LD_LIBRARY_PATH $ENV{LD_LIBRARY_PATH})
 
 # add tests (use make test to run)
 FILE(GLOB tests "${CMAKE_CURRENT_SOURCE_DIR}/Test*.py")
diff --git a/bin/appliskel/tests/concurrentSession/TestConcurrentSession.py b/bin/appliskel/tests/concurrentSession/TestConcurrentSession.py
deleted file mode 100644 (file)
index 1902263..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-#!/usr/bin/env python
-# Copyright (C) 2013  CEA/DEN, EDF R&D, OPEN CASCADE
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-#
-# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-#
-
-import os
-import sys
-import unittest
-import multiprocessing
-
-class SalomeSession(object):
-  def __init__(self, script, killAtEnd=True):
-    self.__killAtEnd = killAtEnd
-    import runSalome
-    sys.argv  = ["runSalome.py"]
-    sys.argv += ["--terminal"]
-    sys.argv += ["%s" % script]
-    clt, d = runSalome.main()
-  #
-  def __del__(self):
-    if self.__killAtEnd:
-      port = os.getenv('NSPORT')
-      import killSalomeWithPort
-      killSalomeWithPort.killMyPort(port)
-    return
-  #
-#
-
-def run_session():
-  SalomeSession("")
-#
-class TestConcurrentLaunch(unittest.TestCase):
-  def testSingleSession(self):
-    print "** Testing single session **"
-    SalomeSession("")
-  #
-  def testMultiSession(self):
-    print "** Testing multi sessions **"
-
-    jobs = []
-    for i in range(3):
-      p = multiprocessing.Process(target=run_session)
-      jobs.append(p)
-      p.start()
-
-    for j in jobs:
-      j.join()
-  #
-  @classmethod
-  def tearDownClass(cls):
-    import killSalome
-    killSalome.killAllPorts()
-  #
-#
-
-unittest.main()
diff --git a/bin/appliskel/tests/concurrentSession/testConcurrentSession.py b/bin/appliskel/tests/concurrentSession/testConcurrentSession.py
new file mode 100644 (file)
index 0000000..5b857cb
--- /dev/null
@@ -0,0 +1,67 @@
+#!/usr/bin/env python
+# Copyright (C) 2013  CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+import os
+import sys
+import unittest
+import multiprocessing
+
+class TestConcurrentLaunch(unittest.TestCase):
+  @classmethod
+  def setUpClass(cls):
+    # Initialize path to SALOME application
+    path_to_launcher = os.getenv("SALOME_LAUNCHER")
+    appli_dir = os.path.dirname(path_to_launcher)
+    envd_dir = os.path.join(appli_dir, "env.d")
+
+    # Configure session startup
+    cls.SALOME = imp.load_source("SALOME", os.path.join(appli_dir,"salome"))
+    cls.SALOME_args = ["shell", "--config="+envd_dir]
+  #
+  def session(self, args=[]):
+    self.SALOME.main(self.SALOME_args + args)
+  #
+  def testSingleSession(self):
+    print "** Testing single session **"
+    self.session()
+  #
+  def testMultiSession(self):
+    print "** Testing multi sessions **"
+
+    jobs = []
+    for i in range(3):
+      p = multiprocessing.Process(target=session, args=(self,))
+      jobs.append(p)
+      p.start()
+
+    for j in jobs:
+      j.join()
+  #
+#
+
+
+if __name__ == "__main__":
+  path_to_launcher = os.getenv("SALOME_LAUNCHER")
+  if not path_to_launcher:
+    msg = "Error: please set SALOME_LAUNCHER variable to the salome command of your application folder."
+    raise Exception(msg)
+
+  unittest.main()
+#