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_gui.py <timeout_delay> <test command> [test command arguments]
30 class TimeoutException(Exception):
31 """Exception raised when test timeout is reached."""
33 def timeoutHandler(signum, frame):
34 raise TimeoutException()
37 if __name__ == "__main__":
38 timeout_delay = sys.argv[1]
41 # Add explicit call to python executable if a Python script is passed as
44 print("Invalid arguments for salome_test_driver_gui.py. No command defined.")
46 _, ext = os.path.splitext(args[0])
49 # Ensure OMNIORB_USER_PATH is set
50 from salomeContextUtils import setOmniOrbUserPath
54 print("Test timeout explicitely set to: %s seconds"%timeout_delay)
55 timeout_sec = abs(int(timeout_delay)-10)
56 if sys.platform == 'win32':
57 from threading import Timer
58 timer = Timer(timeout_sec, timeoutHandler)
61 signal.alarm(timeout_sec)
62 signal.signal(signal.SIGALRM, timeoutHandler)
64 # Run test in a new SALOME instance
65 from salome_instance import SalomeInstance
67 salome_instance = SalomeInstance.start(with_gui=True, args=test_and_args)
68 except TimeoutException:
69 print("FAILED : timeout(%s) is reached"%timeout_delay)
75 salome_instance.stop()
76 if sys.platform == 'win32':
78 # print("Exit test with status code:", res)