mirrored from https://chromium.googlesource.com/angle/angle
- Notifications
You must be signed in to change notification settings - Fork 645
/
Copy pathupdate_extension_data.py
executable file
·219 lines (172 loc) · 6.93 KB
/
update_extension_data.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
#!/usr/bin/python3
#
# Copyright 2021 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.
#
# update_extension_data.py:
# Downloads and updates auto-generated extension data.
importargparse
importlogging
importjson
importos
importre
importshutil
importsubprocess
importsys
importtempfile
EXIT_SUCCESS=0
EXIT_FAILURE=1
TEST_SUITE='angle_end2end_tests'
BUILDERS= [
'angle/ci/android-arm64-test', 'angle/ci/linux-test', 'angle/ci/win-test',
'angle/ci/win-x86-test'
]
SWARMING_SERVER='chromium-swarm.appspot.com'
d=os.path.dirname
THIS_DIR=d(os.path.abspath(__file__))
ANGLE_ROOT_DIR=d(THIS_DIR)
# Host GPUs
INTEL_UHD630='8086:9bc5'
NVIDIA_GTX1660='10de:2184'
SWIFTSHADER='none'
GPUS= [INTEL_UHD630, NVIDIA_GTX1660, SWIFTSHADER]
GPU_NAME_MAP= {
INTEL_UHD630: 'intel_630',
NVIDIA_GTX1660: 'nvidia_1660',
SWIFTSHADER: 'swiftshader'
}
# OSes
LINUX='Linux'
WINDOWS_10='Windows-10'
BOT_OSES= [LINUX, WINDOWS_10]
BOT_OS_NAME_MAP= {LINUX: 'linux', WINDOWS_10: 'win10'}
# Devices
PIXEL_4='flame'
PIXEL_6='oriole'
DEVICES_TYPES= [PIXEL_4, PIXEL_6]
DEVICE_NAME_MAP= {PIXEL_4: 'pixel_4', PIXEL_6: 'pixel_6'}
# Device OSes
ANDROID_11='R'
ANDROID_13='T'
DEVICE_OSES= [ANDROID_11, ANDROID_13]
DEVICE_OS_NAME_MAP= {ANDROID_11: 'android_11', ANDROID_13: 'android_13'}
# Result names
INFO_FILES= [
'GLinfo_ES3_2_Vulkan.json',
'GLinfo_ES3_1_Vulkan_SwiftShader.json',
]
LOG_LEVELS= ['WARNING', 'INFO', 'DEBUG']
defrun_and_get_json(args):
logging.debug(' '.join(args))
output=subprocess.check_output(args)
returnjson.loads(output)
defget_bb():
return'bb.bat'ifos.name=='nt'else'bb'
defrun_bb_and_get_output(*args):
bb_args= [get_bb()] +list(args)
returnsubprocess.check_output(bb_args, encoding='utf-8')
defrun_bb_and_get_json(*args):
bb_args= [get_bb()] +list(args) + ['-json']
returnrun_and_get_json(bb_args)
defget_swarming():
swarming_bin='swarming.exe'ifos.name=='nt'else'swarming'
returnos.path.join(ANGLE_ROOT_DIR, 'tools', 'luci-go', swarming_bin)
defrun_swarming(*args):
swarming_args= [get_swarming()] +list(args)
logging.debug(' '.join(swarming_args))
subprocess.check_call(swarming_args)
defrun_swarming_and_get_json(*args):
swarming_args= [get_swarming()] +list(args)
returnrun_and_get_json(swarming_args)
defname_device(gpu, device_type):
ifgpu:
returnGPU_NAME_MAP[gpu]
else:
assertdevice_type
returnDEVICE_NAME_MAP[device_type]
defname_os(bot_os, device_os):
ifbot_os:
returnBOT_OS_NAME_MAP[bot_os]
else:
assertdevice_os
returnDEVICE_OS_NAME_MAP[device_os]
defget_props_string(gpu, bot_os, device_os, device_type):
d= {'gpu': gpu, 'os': bot_os, 'device os': device_os, 'device': device_type}
return', '.join('%s %s'% (k, v) for (k, v) ind.items() ifv)
defcollect_task_and_update_json(task_id, found_dims):
gpu=found_dims.get('gpu', None)
bot_os=found_dims.get('os', None)
device_os=found_dims.get('device_os', None)
device_type=found_dims.get('device_type', None)
logging.info('Found task with ID: %s, %s'%
(task_id, get_props_string(gpu, bot_os, device_os, device_type)))
target_file_name='%s_%s.json'% (name_device(gpu, device_type), name_os(bot_os, device_os))
target_file=os.path.join(THIS_DIR, 'extension_data', target_file_name)
withtempfile.TemporaryDirectory() astempdirname:
run_swarming('collect', '-S', SWARMING_SERVER, '-output-dir=%s'%tempdirname, task_id)
task_dir=os.path.join(tempdirname, task_id)
found=False
forfnameinos.listdir(task_dir):
iffnameinINFO_FILES:
iffound:
logging.warning('Multiple candidates found for %s'%target_file_name)
return
else:
logging.info('%s -> %s'% (fname, target_file))
found=True
source_file=os.path.join(task_dir, fname)
shutil.copy(source_file, target_file)
defget_intersect_or_none(list_a, list_b):
i= [vforvinlist_aifvinlist_b]
assertnotiorlen(i) ==1
returni[0] ifielseNone
defmain():
parser=argparse.ArgumentParser(description='Pulls extension support data from ANGLE CI.')
parser.add_argument(
'-v', '--verbose', help='Print additional debugging into.', action='count', default=0)
args=parser.parse_args()
ifargs.verbose>=len(LOG_LEVELS):
args.verbose=len(LOG_LEVELS) -1
logging.basicConfig(level=LOG_LEVELS[args.verbose])
name_expr=re.compile(r'^'+TEST_SUITE+r' on (.*) on (.*)$')
forbuilderinBUILDERS:
# Step 1: Find the build ID.
# We list two builds using 'bb ls' and take the second, to ensure the build is finished.
ls_output=run_bb_and_get_output('ls', builder, '-n', '2', '-id')
build_id=ls_output.splitlines()[1]
logging.info('%s: build id %s'% (builder, build_id))
# Step 2: Get the test suite swarm hashes.
# 'bb get' returns build properties, including cloud storage identifiers for this test suite.
get_json=run_bb_and_get_json('get', build_id, '-p')
test_suite_hash=get_json['output']['properties']['swarm_hashes'][TEST_SUITE]
logging.info('Found swarm hash: %s'%test_suite_hash)
# Step 3: Find all tasks using the swarm hashes.
# 'swarming tasks' can find instances of the test suite that ran on specific systems.
task_json=run_swarming_and_get_json('tasks', '-tag', 'data:%s'%test_suite_hash, '-S',
SWARMING_SERVER)
# Step 4: Download the extension data for each configuration we're monitoring.
# 'swarming collect' downloads test artifacts to a temporary directory.
dim_map= {
'gpu': GPUS,
'os': BOT_OSES,
'device_os': DEVICE_OSES,
'device_type': DEVICES_TYPES,
}
fortaskintask_json:
found_dims= {}
forbot_dimintask['bot_dimensions']:
key, value=bot_dim['key'], bot_dim['value']
ifkeyindim_map:
logging.debug('%s=%s'% (key, value))
mapped_values=dim_map[key]
found_dim=get_intersect_or_none(mapped_values, value)
iffound_dim:
found_dims[key] =found_dim
found_gpu_or_device= ('gpu'infound_dimsor'device_type'infound_dims)
found_os= ('os'infound_dimsor'device_os'infound_dims)
iffound_gpu_or_deviceandfound_os:
collect_task_and_update_json(task['task_id'], found_dims)
returnEXIT_SUCCESS
if__name__=='__main__':
sys.exit(main())