Commit 41c66442 by Gert Wollny Committed by Commit Bot

Capture/Replay: Print context diff on failure when verbose

When run with the --verbose flag, and a test fails because the context comparison fails, then print the unified diff between the JSON serialization of context that was captured and the context when it was replayed. Bug: angleproject:5715 Change-Id: I86210d96e5bbdf63f1ed663ddf8dfcb33764cbea Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2821535 Commit-Queue: Gert Wollny <gert.wollny@collabora.com> Reviewed-by: 's avatarCody Northrop <cnorthrop@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 5faed621
...@@ -22,6 +22,7 @@ Script testing capture_replay with angle_end2end_tests ...@@ -22,6 +22,7 @@ Script testing capture_replay with angle_end2end_tests
# Command line arguments: run with --help for a full list. # Command line arguments: run with --help for a full list.
import argparse import argparse
import difflib
import distutils.util import distutils.util
import fnmatch import fnmatch
import logging import logging
...@@ -566,7 +567,7 @@ class TestBatch(): ...@@ -566,7 +567,7 @@ class TestBatch():
return False return False
return True return True
def RunReplay(self, replay_exe_path, child_processes_manager, tests): def RunReplay(self, replay_build_dir, replay_exe_path, child_processes_manager, tests):
env = os.environ.copy() env = os.environ.copy()
env['ANGLE_CAPTURE_ENABLED'] = '0' env['ANGLE_CAPTURE_ENABLED'] = '0'
env['ANGLE_FEATURE_OVERRIDES_ENABLED'] = 'enable_capture_limits' env['ANGLE_FEATURE_OVERRIDES_ENABLED'] = 'enable_capture_limits'
...@@ -595,12 +596,34 @@ class TestBatch(): ...@@ -595,12 +596,34 @@ class TestBatch():
passes.append(self.FindTestByLabel(words[1])) passes.append(self.FindTestByLabel(words[1]))
else: else:
fails.append(self.FindTestByLabel(words[1])) fails.append(self.FindTestByLabel(words[1]))
if self.verbose:
print("Context comparison failed: {}".format(
self.FindTestByLabel(words[1])))
self.PrintContextDiff(replay_build_dir, words[1])
count += 1 count += 1
if len(passes) > 0: if len(passes) > 0:
self.results.append(GroupedResult(GroupedResult.Passed, "", "", passes)) self.results.append(GroupedResult(GroupedResult.Passed, "", "", passes))
if len(fails) > 0: if len(fails) > 0:
self.results.append(GroupedResult(GroupedResult.Failed, "", "", fails)) self.results.append(GroupedResult(GroupedResult.Failed, "", "", fails))
def PrintContextDiff(self, replay_build_dir, test_name):
frame = 1
while True:
capture_file = "{}/{}_ContextCaptured{}.json".format(replay_build_dir, test_name,
frame)
replay_file = "{}/{}_ContextReplayed{}.json".format(replay_build_dir, test_name, frame)
if os.path.exists(capture_file) and os.path.exists(replay_file):
captured_context = open(capture_file, "r").readlines()
replayed_context = open(replay_file, "r").readlines()
for line in difflib.unified_diff(
captured_context, replayed_context, fromfile=capture_file,
tofile=replay_file):
print(line, end="")
frame = frame + 1
else:
break
def FindTestByLabel(self, label): def FindTestByLabel(self, label):
for test in self.tests: for test in self.tests:
if test.GetLabel() == label: if test.GetLabel() == label:
...@@ -722,7 +745,8 @@ def RunTests(args, worker_id, job_queue, result_list, message_queue): ...@@ -722,7 +745,8 @@ def RunTests(args, worker_id, job_queue, result_list, message_queue):
result_list.append(test_batch.GetResults()) result_list.append(test_batch.GetResults())
message_queue.put(str(test_batch.GetResults())) message_queue.put(str(test_batch.GetResults()))
continue continue
test_batch.RunReplay(replay_exec_path, child_processes_manager, continued_tests) test_batch.RunReplay(replay_build_dir, replay_exec_path, child_processes_manager,
continued_tests)
result_list.append(test_batch.GetResults()) result_list.append(test_batch.GetResults())
message_queue.put(str(test_batch.GetResults())) message_queue.put(str(test_batch.GetResults()))
except KeyboardInterrupt: except KeyboardInterrupt:
......
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