From: aguerre Date: Fri, 6 Sep 2013 16:15:42 +0000 (+0000) Subject: test port manager X-Git-Tag: begin_agr_portmanager_branch_131004~29 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ab421fb4ae3d4230a82f73e2120b6eaa7ae692b1;p=modules%2Fkernel.git test port manager --- diff --git a/bin/appliskel/tests/concurrentSession/CMakeLists.txt b/bin/appliskel/tests/concurrentSession/CMakeLists.txt index 9c865f91a..137ddfe53 100644 --- a/bin/appliskel/tests/concurrentSession/CMakeLists.txt +++ b/bin/appliskel/tests/concurrentSession/CMakeLists.txt @@ -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 index 190226363..000000000 --- a/bin/appliskel/tests/concurrentSession/TestConcurrentSession.py +++ /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 index 000000000..5b857cb98 --- /dev/null +++ b/bin/appliskel/tests/concurrentSession/testConcurrentSession.py @@ -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() +#