mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-05 09:30:44 +00:00
Include test process output into test log
This commit is contained in:
@@ -152,6 +152,7 @@ std::string trim(const std::string &str)
|
||||
}
|
||||
|
||||
static char printBuf[4096] = {};
|
||||
static FILE *logFile = NULL;
|
||||
|
||||
void DebugPrint(const char *fmt, ...)
|
||||
{
|
||||
@@ -165,6 +166,12 @@ void DebugPrint(const char *fmt, ...)
|
||||
fputs(printBuf, stdout);
|
||||
fflush(stdout);
|
||||
|
||||
if(logFile)
|
||||
{
|
||||
fputs(printBuf, logFile);
|
||||
fflush(logFile);
|
||||
}
|
||||
|
||||
#if defined(WIN32)
|
||||
OutputDebugStringA(printBuf);
|
||||
#endif
|
||||
@@ -510,6 +517,11 @@ void GraphicsTest::Prepare(int argc, char **argv)
|
||||
maxFrameCount = atoi(argv[i + 1]);
|
||||
}
|
||||
|
||||
if(i + 1 < argc && !strcmp(argv[i], "--log"))
|
||||
{
|
||||
logFile = fopen(argv[i + 1], "w");
|
||||
}
|
||||
|
||||
if(i + 1 < argc && (!strcmp(argv[i], "--width") || !strcmp(argv[i], "-w")))
|
||||
{
|
||||
screenWidth = atoi(argv[i + 1]);
|
||||
|
||||
@@ -150,7 +150,8 @@ 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(), timeout=None):
|
||||
def run_and_capture(exe: str, cmdline: str, frame: int, *, capture_name=None, opts=rd.GetDefaultCaptureOptions(),
|
||||
timeout=None, logfile=None):
|
||||
"""
|
||||
Helper function to run an executable with a command line, capture a particular frame, and exit.
|
||||
|
||||
@@ -161,6 +162,9 @@ def run_and_capture(exe: str, cmdline: str, frame: int, capture_name=None, opts=
|
||||
:param cmdline: The command line to pass.
|
||||
:param frame: The frame to capture.
|
||||
:param capture_name: The name to use creating the captures
|
||||
:param opts: The capture options to use
|
||||
:param timeout: The timeout to wait before killing the process if no capture has happened.
|
||||
:param logfile: The log file output to include in the test log.
|
||||
:return: The path of the generated capture.
|
||||
:rtype: str
|
||||
"""
|
||||
@@ -170,7 +174,7 @@ def run_and_capture(exe: str, cmdline: str, frame: int, capture_name=None, 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))
|
||||
log.print("Queuing capture of frame {} with timeout of {}".format(frame, "default" if timeout is None else timeout))
|
||||
|
||||
# Capture frame
|
||||
control.queue_capture(frame)
|
||||
@@ -180,6 +184,9 @@ def run_and_capture(exe: str, cmdline: str, frame: int, capture_name=None, opts=
|
||||
|
||||
captures = control.captures()
|
||||
|
||||
if logfile is not None and os.path.exists(logfile):
|
||||
log.inline_file('Process output', logfile)
|
||||
|
||||
if len(captures) == 0:
|
||||
raise RuntimeError("No capture made")
|
||||
|
||||
|
||||
@@ -90,6 +90,16 @@ class TestLogger:
|
||||
self.dedent()
|
||||
self.rawprint("<< Section {}".format(name))
|
||||
|
||||
def inline_file(self, name: str, path: str):
|
||||
self.rawprint(">> Raw {}".format(name))
|
||||
self.indent()
|
||||
with open(path) as f:
|
||||
lines = f.readlines()
|
||||
for l in lines:
|
||||
self.rawprint(l.strip())
|
||||
self.dedent()
|
||||
self.rawprint("<< Raw {}".format(name))
|
||||
|
||||
def success(self, message):
|
||||
self.rawprint("** " + message)
|
||||
|
||||
|
||||
@@ -201,7 +201,10 @@ 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(), timeout=util.get_demos_timeout())
|
||||
logfile = os.path.join(util.get_tmp_dir(), 'demos.log')
|
||||
return capture.run_and_capture(util.get_demos_binary(), self.demos_test_name + " --log " + logfile,
|
||||
self.demos_frame_cap, logfile=logfile, 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.")
|
||||
|
||||
@@ -166,6 +166,9 @@ document.body.onload = function() {
|
||||
if(words[0] == 'Callstack') {
|
||||
html += start ? '<div class="expandable callstack"><span class="expandtoggle"></span><div class="title">Callstack</div><div class="contents"><pre>' : '</pre></div></div>';
|
||||
instack = start;
|
||||
} else if(words[0] == 'Raw') {
|
||||
html += start ? '<div class="expandable"><span class="expandtoggle"></span><div class="title">' + words.slice(1).join(' ') + '</div><div class="contents"><pre>' : '</pre></div></div>';
|
||||
instack = start;
|
||||
} else if(words[0] == 'Test') {
|
||||
test_name = words[1];
|
||||
html += start ? '<div class="expandable test" id="' + test_name + '"><span class="expandtoggle"></span><div class="title">Test: ' + test_name + '</div><div class="contents">' : '</div></div>';
|
||||
|
||||
Reference in New Issue
Block a user