Capture/Replay: Support multi-digit context

The code is designed for single digit contexts, i.e 1-9.
We've hit our first app that uses context 10, so update the logic.

Bug: b/184105957
Bug: angleproject:5807
Change-Id: Ice5facad8a86f009c0a85d184db4a20e48eff248
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2796402
Commit-Queue: Cody Northrop <cnorthrop@google.com>
Reviewed-by: Tim Van Patten <timvp@google.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
This commit is contained in:
Cody Northrop 2021-03-29 23:01:01 -06:00 коммит произвёл Commit Bot
Родитель fe6b426997
Коммит 88b91df14b
2 изменённых файлов: 12 добавлений и 5 удалений

Просмотреть файл

@ -50,7 +50,7 @@
"src/tests/restricted_traces/free_fire.tar.gz.sha1":
"a4e7aba54fb48524bb4f3022623bc7cd",
"src/tests/restricted_traces/gen_restricted_traces.py":
"7df2fbfb890d54ea9932b443439ae97e",
"e16f270a02d11ad334cdd43bdff8b068",
"src/tests/restricted_traces/google_maps.tar.gz.sha1":
"5d7001969619570e80e5a39b1ab8b0c4",
"src/tests/restricted_traces/happy_color.tar.gz.sha1":

Просмотреть файл

@ -302,10 +302,17 @@ def get_context(trace):
for file in os.listdir(trace):
# Load up the only header present for each trace
if fnmatch.fnmatch(file, '*.h'):
# Strip the extension to isolate the context
context = file[len(file) - 3]
assert context.isdigit() == True, "Failed to find trace context number"
assert file[len(file) - 4].isdigit() == False, "Context number is higher than 9"
# Strip the extension to isolate the context by scanning
# for numbers leading up to the last one, i.e.:
# app_capture_context123.h
# ^^
# start---||---end
start = len(file) - 3
end = start + 1
while file[start - 1].isdigit():
start -= 1
context = file[start:end]
assert context.isnumeric(), "Failed to find trace context number"
return context