mirrored from https://chromium.googlesource.com/angle/angle
- Notifications
You must be signed in to change notification settings - Fork 644
/
Copy pathangle_trace_bundle.py
executable file
·112 lines (93 loc) · 3.99 KB
/
angle_trace_bundle.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/usr/bin/python3
#
# Copyright 2023 The ANGLE Project Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# angle_trace_bundle.py:
# Makes a zip bundle allowing to run angle traces, similarly to mb.py but
# - trims most of the dependencies
# - includes list_traces.sh and run_trace.sh (see --trace-name)
# - lib.unstripped only included if --include-unstripped-libs
# - does not depend on vpython
# - just adds files to the zip instead of "isolate remap" with a temp dir
#
# Example usage:
# % gn args out/Android # angle_restricted_traces=["among_us"]
# (note: explicit build isn't necessary as it is invoked by mb isolate this script runs)
# % scripts/angle_trace_bundle.py out/Android angle_trace.zip --trace-name=among_us
#
# (transfer the zip elsewhere)
# % unzip angle_trace.zip -d angle_trace
# % angle_trace/list_traces.sh
# % angle_trace/run_trace.sh # only included if --trace-name, runs that trace
importargparse
importjson
importos
importsubprocess
importsys
importzipfile
# {gn_dir}/angle_trace_tests has vpython in wrapper shebangs, call our runner directly
RUN_TESTS_TEMPLATE=r'''#!/bin/bash
cd "$(dirname "$0")"
python3 src/tests/angle_android_test_runner.py gtest --suite=angle_trace_tests --output-directory={gn_dir} "$@"
'''
LIST_TRACES_TEMPLATE=r'''#!/bin/bash
cd "$(dirname "$0")"
./_run_tests.sh --list-tests
'''
RUN_TRACE_TEMPLATE=r'''#!/bin/bash
cd "$(dirname "$0")"
./_run_tests.sh --filter='TraceTest.{trace_name}' --verbose --fixed-test-time-with-warmup 10
'''
defmain():
parser=argparse.ArgumentParser()
parser.add_argument('gn_dir', help='path to GN. (e.g. out/Android)')
parser.add_argument('output_zip_file', help='output zip file')
parser.add_argument(
'--include-unstripped-libs', action='store_true', help='include lib.unstripped')
parser.add_argument('--trace-name', help='trace to run from run_script.sh')
args, _=parser.parse_known_args()
gn_dir=os.path.join(os.path.normpath(args.gn_dir), '')
assertos.path.sep=='/'andgn_dir.endswith('/')
assertgn_dir[0] notin ('.', '/') # expecting relative to angle root
subprocess.check_call([
'python3', 'tools/mb/mb.py', 'isolate', gn_dir, 'angle_trace_perf_tests', '-i',
'infra/specs/gn_isolate_map.pyl'
])
withopen(os.path.join(args.gn_dir, 'angle_trace_perf_tests.isolate')) asf:
isolate_file_paths=json.load(f)['variables']['files']
skipped_prefixes= [
'build/',
'src/tests/run_perf_tests.py', # won't work as it depends on catapult
'third_party/catapult/',
'third_party/colorama/',
'third_party/jdk/',
'third_party/jinja2/',
'third_party/logdog/',
'third_party/r8/',
'third_party/requests/',
os.path.join(gn_dir, 'lib.java/'),
os.path.join(gn_dir, 'obj/'),
]
ifnotargs.include_unstripped_libs:
skipped_prefixes.append(os.path.join(gn_dir, 'lib.unstripped/'))
withzipfile.ZipFile(args.output_zip_file, 'w', zipfile.ZIP_DEFLATED, allowZip64=True) asfzip:
forfninisolate_file_paths:
path=os.path.normpath(os.path.join(gn_dir, fn))
ifany(path.startswith(p) forpinskipped_prefixes):
continue
fzip.write(path)
defaddScript(path_in_zip, contents):
# Creates a script directly inside the zip file
info=zipfile.ZipInfo(path_in_zip)
info.external_attr=0o755<<16# unnecessarily obscure way to chmod 755...
fzip.writestr(info, contents)
addScript('_run_tests.sh', RUN_TESTS_TEMPLATE.format(gn_dir=gn_dir))
addScript('list_traces.sh', LIST_TRACES_TEMPLATE.format(gn_dir=gn_dir))
ifargs.trace_name:
addScript('run_trace.sh',
RUN_TRACE_TEMPLATE.format(gn_dir=gn_dir, trace_name=args.trace_name))
return0
if__name__=='__main__':
sys.exit(main())