2 # Copyright (C) 2015-2020 CEA/DEN, EDF R&D, OPEN CASCADE
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 Usage: salome_test_driver_gui.py <timeout_delay> <test command> [test command arguments]
31 class TimeoutException(Exception):
32 """Exception raised when test timeout is reached."""
34 def timeoutHandler(signum, frame):
35 raise TimeoutException()
38 if __name__ == "__main__":
39 timeout_delay = sys.argv[1]
42 # Add explicit call to python executable if a Python script is passed as
45 print("Invalid arguments for salome_test_driver_gui.py. No command defined.")
47 _, ext = os.path.splitext(args[0])
50 # Ensure OMNIORB_USER_PATH is set
51 from salomeContextUtils import setOmniOrbUserPath
55 print("Test timeout explicitly set to: %s seconds"%timeout_delay)
56 timeout_sec = abs(int(timeout_delay)-10)
57 if sys.platform == 'win32':
58 from threading import Timer
59 timer = Timer(timeout_sec, timeoutHandler)
62 signal.alarm(timeout_sec)
63 signal.signal(signal.SIGALRM, timeoutHandler)
65 # Run test in a new SALOME instance
66 from salome_instance import SalomeInstance
68 salome_instance = SalomeInstance.start(with_gui=True, args=test_and_args)
69 except TimeoutException:
70 print("FAILED : timeout(%s) is reached"%timeout_delay)
76 salome_instance.stop()
79 if sys.platform == 'win32':
81 # print("Exit test with status code:", res)