Salome HOME
c309d91606a0c2e1561161e1a530eaa74337a9fa
[modules/shaper.git] / src / ExchangePlugin / Test / testme.py
1 # Copyright (C) 2007-2022  CEA/DEN, EDF R&D
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19
20 #!/usr/bin/env python3
21
22 import unittest, sys, os
23 import subprocess
24
25 testTimeout = 600
26
27 class SalomeSession(object):
28     def __init__(self, script):
29         isOk = True
30         proc = subprocess.Popen(["runSalome.py", "--modules", "SHAPER,GEOM,SHAPERSTUDY", "--gui", "--splash", "0", script], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
31         try:
32             out, err = proc.communicate(timeout = testTimeout)
33         except TimeoutExpired:
34             isOk = False
35             proc.kill()
36             out, err = proc.communicate()
37             error = "Killed by CPU limit."
38             pass
39         print(err)
40
41         assert isOk, "Test failed. {}".format(error)
42
43         # # import runSalome
44         # # run_script = "runSalome.py"
45         # # if sys.platform == 'win32':
46             # # module_dir = os.getenv("KERNEL_ROOT_DIR")
47             # # if module_dir: run_script = os.path.join(module_dir, "bin", "salome", run_script)
48             # # pass
49         # # sys.argv  = [run_script]
50         # # sys.argv += ["--gui"]
51         # # sys.argv += ["--splash=0"]
52         # # sys.argv += ["--modules=SHAPER,GEOM,SHAPERSTUDY,SMESH"]
53         # # sys.argv += ["%s" % script]
54         # # if sys.platform == 'win32':
55             # # main_module_path = sys.modules['__main__'].__file__
56             # # sys.modules['__main__'].__file__ = ''
57         # # clt, d = runSalome.main()
58         # # if sys.platform == 'win32':
59             # # sys.modules['__main__'].__file__ = main_module_path
60         return
61
62     def __del__(self):
63         port = os.getenv('NSPORT')
64         import killSalomeWithPort
65         if port:
66              killSalomeWithPort.killMyPort(port)
67         return
68     pass
69
70 class MyTest(unittest.TestCase):
71     def testFunction(self):
72         SalomeSession(sys.argv[1])
73     pass
74
75 unittest.main(argv=sys.argv[:1])