1 # Copyright (C) 2013-2015 CEA/DEN, EDF R&D
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.
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.
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
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 import killSalomeWithPort
26 if not os.getenv("OMNIORB_USER_PATH"):
27 os.environ["OMNIORB_USER_PATH"] = os.path.realpath(os.path.expanduser('~'))
32 class SalomeSession(object):
33 def __init__(self, args=[]):
34 sys.argv = ['runSalome'] + args
38 sys.argv += ["--show-desktop=1"]
39 sys.argv += ["--splash=0"]
40 #sys.argv += ["--standalone=study"]
41 #sys.argv += ["--embedded=SalomeAppEngine,cppContainer,registry,moduleCatalog"]
43 sys.argv += ["--terminal"]
44 sys.argv += ["--modules=MED,PARAVIS,GUI"]
56 def run_test(command):
59 log = tempfile.NamedTemporaryFile(suffix='_nsport.log', delete=False)
62 salome_session = SalomeSession(args=["--ns-port-log=%s"%log.name])
64 session_server = salome.naming_service.Resolve('/Kernel/Session')
66 session_server.emitMessage("connect_to_study")
67 session_server.emitMessage("activate_viewer/ParaView")
71 with open(log.name) as f:
72 port = int(f.readline())
75 #res = subprocess.check_call(command)
76 p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
77 _out, _err = p.communicate()
81 killSalomeWithPort.killMyPort(port)
84 # :TRICKY: Special case of returncode=127
85 # When using paraview in SALOME environment, the following error
86 # systematically appears when exiting paraview (it's also true when using
87 # PARAVIS and exiting SALOME):
88 # Inconsistency detected by ld.so: dl-close.c: 738: _dl_close: Assertion `map->l_init_called' failed!
89 # For PARAVIS tests purpose, paraview functionalities are accessed in each
90 # test; these tests are run in the above subprocess call.
91 # The assertion error implies a subprocess return code of 127, and the test
92 # status is considered as "failed".
93 # The tricky part here is to discard such return codes, waiting for a fix
94 # maybe in paraview...
95 print "#############################"
98 print "#############################"
99 if res == 127 and _err.startswith("Inconsistency detected by ld.so: dl-close.c"):
100 print " ** THE FOLLOWING MESSAGE IS DISCARDED WHEN ANALYZING TEST SUCCESSFULNESS **"
102 print " ** end of message **"
105 print " ** Detected error **"
106 print "Error code: ", res
108 print " ** end of message **"
116 def timeout_handler(signum, frame):
117 print "FAILED : timeout(" + sys.argv[1] + ") is reached"
118 killSalomeWithPort.killMyPort(port)
121 signal.alarm(abs(int(sys.argv[1])-10))
122 signal.signal(signal.SIGALRM, timeout_handler)
126 res = run_test([sys.executable]+sys.argv[2:])
129 #traceback.print_exc()