summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorAndres Gomez <agomez@igalia.com>2020-07-30 01:28:46 +0300
committerAndres Gomez <agomez@igalia.com>2020-11-02 22:15:29 +0200
commit476db8525bf845a85ede3bea0fe49c9e83d9dd2b (patch)
treee46deb2522fb529b29a9c366377358d078507655 /framework
parent04fa6e49496cf2e6cc697c67b2f76df4152fb600 (diff)
framework/replay: allow specifying where to dump the replay output
v2: - Remove handling the log file since we don't need to move it any more (Charlie). Signed-off-by: Andres Gomez <agomez@igalia.com> Reviewed-by: Dylan Baker <dylan@pnwbakers.com> Part-of: <https://gitlab.freedesktop.org/mesa/piglit/-/merge_requests/353>
Diffstat (limited to 'framework')
-rw-r--r--framework/replay/compare_replay.py26
-rw-r--r--framework/replay/dump_trace_images.py33
2 files changed, 24 insertions, 35 deletions
diff --git a/framework/replay/compare_replay.py b/framework/replay/compare_replay.py
index feac7cccb..f27d0ff54 100644
--- a/framework/replay/compare_replay.py
+++ b/framework/replay/compare_replay.py
@@ -24,7 +24,6 @@
# SPDX-License-Identifier: MIT
import os
-import shutil
import yaml
from glob import glob
@@ -43,23 +42,19 @@ __all__ = ['from_yaml',
TRACES_DB_PATH = './traces-db/'
RESULTS_PATH = './results/'
-def _replay(trace_path, device_name):
- success = dump_from_trace(trace_path, [], device_name)
+def _replay(trace_path, results_path, device_name):
+ success = dump_from_trace(trace_path, results_path, [], device_name)
if not success:
print("[check_image] Trace {} couldn't be replayed. "
"See above logs for more information.".format(trace_path))
- return None, None, None
+ return None, None
else:
- test_path = path.join(path.dirname(trace_path), 'test', device_name)
file_name = path.basename(trace_path)
- files = glob(path.join(test_path, file_name + '-*' + '.png'))
+ files = glob(path.join(results_path, file_name + '-*' + '.png'))
assert(files)
image_file = files[0]
- files = glob(path.join(test_path, file_name + '.log'))
- assert(files)
- log_file = files[0]
- return (hexdigest_from_image(image_file), image_file, log_file)
+ return hexdigest_from_image(image_file), image_file
def _check_trace(download_url, device_name, trace_path, expected_checksum):
@@ -74,18 +69,17 @@ def _check_trace(download_url, device_name, trace_path, expected_checksum):
results_path = path.join(RESULTS_PATH, dir_in_results)
os.makedirs(results_path, exist_ok=True)
- checksum, image_file, log_file = _replay(path.join(TRACES_DB_PATH,
- trace_path),
- device_name)
+ checksum, image_file = _replay(path.join(TRACES_DB_PATH, trace_path),
+ results_path,
+ device_name))
result[trace_path]['actual'] = checksum or 'error'
- shutil.move(log_file, path.join(results_path, path.basename(log_file)))
if checksum is None:
return False, result
if checksum == expected_checksum:
- if os.environ.get('TRACIE_STORE_IMAGES', '0') == '1':
- shutil.move(image_file, path.join(results_path, image_name))
+ if os.environ.get('TRACIE_STORE_IMAGES', '0') != '1':
+ os.remove(image_file)
print('[check_image] Images match for:\n {}\n'.format(trace_path))
ok = True
else:
diff --git a/framework/replay/dump_trace_images.py b/framework/replay/dump_trace_images.py
index 705279073..261aa05c2 100644
--- a/framework/replay/dump_trace_images.py
+++ b/framework/replay/dump_trace_images.py
@@ -73,9 +73,7 @@ def _get_last_gfxreconstruct_frame_call(trace_path):
return int(c[1])
return -1
-def _dump_with_apitrace(retrace_cmd, trace_path, calls, device_name):
- output_dir = path.join(path.dirname(trace_path), 'test', device_name)
- os.makedirs(output_dir, exist_ok=True)
+def _dump_with_apitrace(retrace_cmd, trace_path, output_dir, calls):
outputprefix = path.join(output_dir, path.basename(trace_path)) + '-'
if len(calls) == 0:
calls = [str(_get_last_apitrace_frame_call(retrace_cmd[:-1],
@@ -87,9 +85,7 @@ def _dump_with_apitrace(retrace_cmd, trace_path, calls, device_name):
log_path = path.join(output_dir, path.basename(trace_path)) + '.log'
_run_logged_command(cmd, None, log_path)
-def _dump_with_renderdoc(trace_path, calls, device_name):
- output_dir = path.join(path.dirname(trace_path), 'test', device_name)
- os.makedirs(output_dir, exist_ok=True)
+def _dump_with_renderdoc(trace_path, output_dir, calls):
script_path = path.dirname(path.abspath(__file__))
cmd = [path.join(script_path, 'renderdoc_dump_images.py'),
trace_path, output_dir]
@@ -97,10 +93,8 @@ def _dump_with_renderdoc(trace_path, calls, device_name):
log_path = path.join(output_dir, path.basename(trace_path)) + '.log'
_run_logged_command(cmd, None, log_path)
-def _dump_with_gfxreconstruct(trace_path, calls, device_name):
+def _dump_with_gfxreconstruct(trace_path, output_dir, calls):
from PIL import Image
- output_dir = path.join(path.dirname(trace_path), 'test', device_name)
- os.makedirs(output_dir, exist_ok=True)
outputprefix = path.join(output_dir, path.basename(trace_path))
if len(calls) == 0:
# FIXME: The VK_LAYER_LUNARG_screenshot numbers the calls from
@@ -123,10 +117,8 @@ def _dump_with_gfxreconstruct(trace_path, calls, device_name):
Image.open(ppm).save(outputfile)
os.remove(ppm)
-def _dump_with_testtrace(trace_path, calls, device_name):
+def _dump_with_testtrace(trace_path, output_dir, calls):
from PIL import Image
- output_dir = path.join(path.dirname(trace_path), 'test', device_name)
- os.makedirs(output_dir, exist_ok=True)
outputprefix = path.join(output_dir, path.basename(trace_path))
with open(trace_path) as f:
rgba = f.read()
@@ -141,21 +133,24 @@ def _dump_with_testtrace(trace_path, calls, device_name):
Image.frombytes('RGBA', (32, 32),
bytes(color * 32 * 32)).save(outputfile)
-def dump_from_trace(trace_path, calls, device_name):
+def dump_from_trace(trace_path, output_dir, calls, device_name):
_log('Info', 'Dumping trace {}'.format(trace_path), end='...\n')
+ if output_dir is None:
+ output_dir = path.join(path.dirname(trace_path), 'test', device_name)
+ os.makedirs(output_dir, exist_ok=True)
trace_type = trace_type_from_filename(path.basename(trace_path))
try:
if trace_type == TraceType.APITRACE:
- _dump_with_apitrace(['eglretrace'], trace_path, calls, device_name)
+ _dump_with_apitrace(['eglretrace'], trace_path, output_dir, calls)
elif trace_type == TraceType.APITRACE_DXGI:
- _dump_with_apitrace(['wine', 'd3dretrace'], trace_path, calls,
- device_name)
+ _dump_with_apitrace(['wine', 'd3dretrace'], trace_path, output_dir,
+ calls)
elif trace_type == TraceType.RENDERDOC:
- _dump_with_renderdoc(trace_path, calls, device_name)
+ _dump_with_renderdoc(trace_path, output_dir, calls)
elif trace_type == TraceType.GFXRECONSTRUCT:
- _dump_with_gfxreconstruct(trace_path, calls, device_name)
+ _dump_with_gfxreconstruct(trace_path, output_dir, calls)
elif trace_type == TraceType.TESTTRACE:
- _dump_with_testtrace(trace_path, calls, device_name)
+ _dump_with_testtrace(trace_path, output_dir, calls)
else:
raise RuntimeError('Unknown tracefile extension')
_log_result('OK')