mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-06 01:50:38 +00:00
Add a configurable timeout when running demos program
This commit is contained in:
@@ -13,7 +13,7 @@ def run_until_capture(control):
|
||||
|
||||
|
||||
class TargetControl():
|
||||
def __init__(self, ident: int, host="localhost", username="testrunner", force=True, timeout=60, exit_kill=True):
|
||||
def __init__(self, ident: int, host="localhost", username="testrunner", force=True, timeout=None, exit_kill=True):
|
||||
"""
|
||||
Creates a target control manager for a given ident
|
||||
|
||||
@@ -29,6 +29,8 @@ class TargetControl():
|
||||
self._children = []
|
||||
self.control = rd.CreateTargetControl(host, ident, username, force)
|
||||
self._timeout = timeout
|
||||
if self._timeout is None:
|
||||
self._timeout = 60
|
||||
self._exit_kill = exit_kill
|
||||
|
||||
if self.control is None:
|
||||
@@ -148,7 +150,7 @@ def run_executable(exe: str, cmdline: str,
|
||||
return res.ident
|
||||
|
||||
|
||||
def run_and_capture(exe: str, cmdline: str, frame: int, capture_name=None, opts=rd.GetDefaultCaptureOptions()):
|
||||
def run_and_capture(exe: str, cmdline: str, frame: int, capture_name=None, opts=rd.GetDefaultCaptureOptions(), timeout=None):
|
||||
"""
|
||||
Helper function to run an executable with a command line, capture a particular frame, and exit.
|
||||
|
||||
@@ -166,7 +168,9 @@ def run_and_capture(exe: str, cmdline: str, frame: int, capture_name=None, opts=
|
||||
if capture_name is None:
|
||||
capture_name = 'capture'
|
||||
|
||||
control = TargetControl(run_executable(exe, cmdline, cappath=util.get_tmp_path(capture_name), opts=opts))
|
||||
control = TargetControl(run_executable(exe, cmdline, cappath=util.get_tmp_path(capture_name), opts=opts), timeout=timeout)
|
||||
|
||||
log.print("Queuing capture of frame {} without timeout of {}".format(frame, "default" if timeout is None else timeout))
|
||||
|
||||
# Capture frame
|
||||
control.queue_capture(frame)
|
||||
|
||||
@@ -198,7 +198,7 @@ class TestCase:
|
||||
"""
|
||||
|
||||
if self.demos_test_name != '':
|
||||
return capture.run_and_capture(util.get_demos_binary(), self.demos_test_name, self.demos_frame_cap, opts=self.get_capture_options())
|
||||
return capture.run_and_capture(util.get_demos_binary(), self.demos_test_name, self.demos_frame_cap, opts=self.get_capture_options(), timeout=util.get_demos_timeout())
|
||||
|
||||
raise NotImplementedError("If run() is not implemented in a test, then"
|
||||
"get_capture() and check_capture() must be.")
|
||||
|
||||
@@ -31,6 +31,7 @@ _data_extra_dir = os.path.realpath('data_extra')
|
||||
_temp_dir = os.path.realpath('tmp')
|
||||
_test_name = 'Unknown_Test'
|
||||
_demos_bin = os.path.realpath('demos_x64')
|
||||
_demos_timeout = None
|
||||
|
||||
|
||||
def set_root_dir(path: str):
|
||||
@@ -86,6 +87,11 @@ def set_demos_binary(path: str):
|
||||
_demos_bin = os.path.abspath(path)
|
||||
|
||||
|
||||
def set_demos_timeout(timeout: int):
|
||||
global _demos_timeout
|
||||
_demos_timeout = timeout
|
||||
|
||||
|
||||
def set_current_test(name: str):
|
||||
global _test_name
|
||||
_test_name = name
|
||||
@@ -127,6 +133,10 @@ def get_demos_binary():
|
||||
return _demos_bin
|
||||
|
||||
|
||||
def get_demos_timeout():
|
||||
return _demos_timeout
|
||||
|
||||
|
||||
def get_tmp_path(name: str):
|
||||
os.makedirs(os.path.join(_temp_dir, _test_name), exist_ok=True)
|
||||
return os.path.join(_temp_dir, _test_name, name)
|
||||
|
||||
@@ -23,6 +23,8 @@ parser.add_argument('--data', default=os.path.join(script_dir, "data"),
|
||||
help="The folder that reference data is in. Will not be modified.", type=str)
|
||||
parser.add_argument('--demos-binary', default="",
|
||||
help="The path to the built demos binary.", type=str)
|
||||
parser.add_argument('--demos-timeout', default=None,
|
||||
help="The timeout to use when expecting the demos to run.", type=int)
|
||||
parser.add_argument('--data-extra', default=os.path.join(script_dir, "data_extra"),
|
||||
help="The folder that extra reference data is in (typically very large captures that aren't part "
|
||||
"of the normal repo). Will not be modified.", type=str)
|
||||
@@ -68,6 +70,7 @@ temp_path = os.path.realpath(args.temp)
|
||||
demos_binary = args.demos_binary
|
||||
if demos_binary != "":
|
||||
demos_binary = os.path.realpath(demos_binary)
|
||||
demos_timeout = args.demos_timeout
|
||||
|
||||
os.chdir(sys.path[0])
|
||||
|
||||
@@ -105,6 +108,7 @@ rdtest.set_data_dir(data_path)
|
||||
rdtest.set_data_extra_dir(data_extra_path)
|
||||
rdtest.set_temp_dir(temp_path)
|
||||
rdtest.set_demos_binary(demos_binary)
|
||||
rdtest.set_demos_timeout(demos_timeout)
|
||||
|
||||
# debugger option implies in-process test running
|
||||
if args.debugger:
|
||||
|
||||
Reference in New Issue
Block a user