1 # Copyright (C) 2015-2016 CEA/DEN, EDF R&D, OPEN CASCADE
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
21 Usage: salome_test_driver.py <timeout_delay> <test command> [test command arguments]
31 print "Running:", " ".join(command)
32 p = subprocess.Popen(command)
36 # A negative value -N indicates that the child was terminated by signal N (Unix only).
37 # On Unix, the value 11 generally corresponds to a segmentation fault.
42 class TimeoutException(Exception):
43 """Exception raised when test timeout is reached."""
45 def timeoutHandler(signum, frame):
46 raise TimeoutException()
49 if __name__ == "__main__":
50 timeout_delay = sys.argv[1]
53 # Add explicit call to python executable if a Python script is passed as
56 print "Invalid arguments for salome_test_driver.py. No command defined."
58 _, ext = os.path.splitext(args[0])
60 test_and_args = [sys.executable] + args
64 # Ensure OMNIORB_USER_PATH is set
65 from salomeContextUtils import setOmniOrbUserPath
69 print "Test timeout explicitely set to: %s seconds"%timeout_delay
70 timeout_sec = abs(int(timeout_delay)-10)
71 if sys.platform == 'win32':
72 from threading import Timer
73 timer = Timer(timeout_sec, timeoutHandler)
76 signal.alarm(timeout_sec)
77 signal.signal(signal.SIGALRM, timeoutHandler)
79 # Run test in a new SALOME instance
80 from salome_instance import SalomeInstance
83 salome_instance = SalomeInstance.start(shutdown_servers=True)
84 port = salome_instance.get_port()
85 res = runTest(test_and_args)
86 except TimeoutException:
87 print "FAILED : timeout(%s) is reached"%timeout_delay
93 salome_instance.stop()
94 if sys.platform == 'win32':
96 print "Exit test with status code:", res