Commit 6336cceb authored by Alexandros Frantzis's avatar Alexandros Frantzis

scripts: Dump all selected traces even if some fail

Don't bail out when a trace dump operation fails, try to dump
all traces and log failures.
Signed-off-by: Alexandros Frantzis's avatarAlexandros Frantzis <alexandros.frantzis@collabora.com>
parent 5a16e17e
Pipeline #81909 passed with stages
in 13 minutes and 32 seconds
......@@ -31,22 +31,22 @@ from traceutil import iter_trace_paths, trace_has_images, all_trace_type_names
from traceutil import trace_type_from_name, trace_type_from_filename, TraceType
def log(severity, msg, end='\n'):
print("[dump_images] %s: %s" % (severity, msg), flush=True, end=end)
print("[dump_trace_images] %s: %s" % (severity, msg), flush=True, end=end)
def log_result(msg):
print(msg, flush=True)
def run_logged_command(cmd, log_path):
ret = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
logoutput = ("[dump_images] Running: %s\n" % " ".join(cmd)).encode() + \
logoutput = ("[dump_trace_images] Running: %s\n" % " ".join(cmd)).encode() + \
ret.stdout
log_path.parent.mkdir(parents=True, exist_ok=True)
with log_path.open(mode='wb') as log:
log.write(logoutput)
if ret.returncode:
sys.stdout.buffer.write(logoutput)
# Force an exception
ret.check_returncode()
raise RuntimeError(
logoutput.decode(errors='replace') +
"[dump_traces_images] Process failed with error code: %d" % ret.returncode)
def get_calls_num(trace, device_name):
tracename = str(Path(trace).name)
......@@ -80,13 +80,21 @@ def dump_from_trace(trace, device_name):
log("Info", "Dumping trace %s" % trace, end='... ')
calls = get_calls_num(trace, device_name)
trace_type = trace_type_from_filename(trace)
if trace_type == TraceType.APITRACE:
dump_with_apitrace(trace, calls, device_name)
elif trace_type == TraceType.RENDERDOC:
dump_with_renderdoc(trace, calls, device_name)
else:
raise RuntimeError("Unknown tracefile extension")
log_result("OK")
try:
if trace_type == TraceType.APITRACE:
dump_with_apitrace(trace, calls, device_name)
elif trace_type == TraceType.RENDERDOC:
dump_with_renderdoc(trace, calls, device_name)
else:
raise RuntimeError("Unknown tracefile extension")
log_result("OK")
return True
except Exception as e:
log_result("ERROR")
log("Debug", "=== Failure log start ===")
print(e)
log("Debug", "=== Failure log end ===")
return False
def find_traces_with_reference_images(directory, device_name, trace_types):
traces = []
......@@ -118,8 +126,13 @@ def main():
elif os.path.isfile(args.tracepath):
traces.append(args.tracepath)
failed_dump = False
for trace in traces:
dump_from_trace(trace, args.device_name)
if not dump_from_trace(trace, args.device_name):
failed_dump = True
sys.exit(1 if failed_dump else 0)
if __name__ == "__main__":
main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment