Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / native_client / buildbot / buildbot_selector.py
1 #!/usr/bin/python
2 # Copyright (c) 2012 The Native Client Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 import json
7 import os
8 import subprocess
9 import sys
10
11 python = sys.executable
12 bash = '/bin/bash'
13 echo = 'echo'
14
15
16 BOT_ASSIGNMENT = {
17     ######################################################################
18     # Buildbots.
19     ######################################################################
20     'xp-newlib-opt':
21         python + ' buildbot\\buildbot_standard.py opt 32 newlib --no-gyp',
22     'xp-glibc-opt':
23         python + ' buildbot\\buildbot_standard.py opt 32 glibc --no-gyp',
24
25     'xp-bare-newlib-opt':
26         python + ' buildbot\\buildbot_standard.py opt 32 newlib --no-gyp',
27     'xp-bare-glibc-opt':
28         python + ' buildbot\\buildbot_standard.py opt 32 glibc --no-gyp',
29
30     'precise-64-validator-opt':
31         python + ' buildbot/buildbot_standard.py opt 64 glibc --validator',
32
33     # Clang.
34     'precise_64-newlib-dbg-clang':
35         python + ' buildbot/buildbot_standard.py dbg 64 newlib --clang',
36     'mac10.7-newlib-dbg-clang':
37         python + ' buildbot/buildbot_standard.py dbg 32 newlib --clang',
38
39     # ASan.
40     'precise_64-newlib-dbg-asan':
41         python + ' buildbot/buildbot_standard.py opt 64 newlib --asan',
42     'mac10.7-newlib-dbg-asan':
43         python + ' buildbot/buildbot_standard.py opt 32 newlib --asan',
44
45     # PNaCl.
46     'oneiric_32-newlib-arm_hw-pnacl-panda-dbg':
47         bash + ' buildbot/buildbot_pnacl.sh mode-buildbot-arm-hw-dbg',
48     'oneiric_32-newlib-arm_hw-pnacl-panda-opt':
49         bash + ' buildbot/buildbot_pnacl.sh mode-buildbot-arm-hw-opt',
50     'precise_64-newlib-arm_qemu-pnacl-dbg':
51         bash + ' buildbot/buildbot_pnacl.sh mode-buildbot-arm-dbg',
52     'precise_64-newlib-arm_qemu-pnacl-opt':
53         bash + ' buildbot/buildbot_pnacl.sh mode-buildbot-arm-opt',
54     'precise_64-newlib-x86_32-pnacl':
55         python + ' buildbot/buildbot_pnacl.py opt 32 pnacl',
56     'precise_64-newlib-x86_64-pnacl':
57         python + ' buildbot/buildbot_pnacl.py opt 64 pnacl',
58     'precise_64-newlib-mips-pnacl':
59         echo + ' "TODO(mseaborn): add mips"',
60     # PNaCl Spec
61     'lucid_64-newlib-arm_qemu-pnacl-buildonly-spec':
62         bash + ' buildbot/buildbot_spec2k.sh pnacl-arm-buildonly',
63     'oneiric_32-newlib-arm_hw-pnacl-panda-spec':
64         bash + ' buildbot/buildbot_spec2k.sh pnacl-arm-hw',
65     'lucid_64-newlib-x86_32-pnacl-spec':
66         bash + ' buildbot/buildbot_spec2k.sh pnacl-x8632',
67     'lucid_64-newlib-x86_64-pnacl-spec':
68         bash + ' buildbot/buildbot_spec2k.sh pnacl-x8664',
69     'precise_64-newlib-arm_qemu-pnacl-buildonly-spec':
70         bash + ' buildbot/buildbot_spec2k.sh pnacl-arm-buildonly',
71     # NaCl Spec
72     'lucid_64-newlib-x86_32-spec':
73         bash + ' buildbot/buildbot_spec2k.sh nacl-x8632',
74     'lucid_64-newlib-x86_64-spec':
75         bash + ' buildbot/buildbot_spec2k.sh nacl-x8664',
76
77     # Valgrind bots.
78     'precise-64-newlib-dbg-valgrind':
79         echo + ' "Valgrind bots are disabled: see '
80             'https://code.google.com/p/nativeclient/issues/detail?id=3158"',
81     'precise-64-glibc-dbg-valgrind':
82         echo + ' "Valgrind bots are disabled: see '
83             'https://code.google.com/p/nativeclient/issues/detail?id=3158"',
84     # Coverage.
85     'mac10.6-newlib-coverage':
86          python + (' buildbot/buildbot_standard.py '
87                    'coverage 64 newlib --coverage --clang'),
88     'precise-64-32-newlib-coverage':
89          python + (' buildbot/buildbot_standard.py '
90                    'coverage 32 newlib --coverage'),
91     'precise-64-64-newlib-coverage':
92          python + (' buildbot/buildbot_standard.py '
93                    'coverage 64 newlib --coverage'),
94     'xp-newlib-coverage':
95          python + (' buildbot/buildbot_standard.py '
96                    'coverage 32 newlib --coverage'),
97
98     ######################################################################
99     # Trybots.
100     ######################################################################
101     'nacl-precise64_validator_opt':
102         python + ' buildbot/buildbot_standard.py opt 64 glibc --validator',
103     'nacl-precise64_newlib_dbg_valgrind':
104         bash + ' buildbot/buildbot_valgrind.sh newlib',
105     'nacl-precise64_glibc_dbg_valgrind':
106         bash + ' buildbot/buildbot_valgrind.sh glibc',
107     # Coverage trybots.
108     'nacl-mac10.6-newlib-coverage':
109          python + (' buildbot/buildbot_standard.py '
110                    'coverage 64 newlib --coverage --clang'),
111     'nacl-precise-64-32-newlib-coverage':
112          python + (' buildbot/buildbot_standard.py '
113                    'coverage 32 newlib --coverage'),
114     'nacl-precise-64-64-newlib-coverage':
115          python + (' buildbot/buildbot_standard.py '
116                    'coverage 64 newlib --coverage'),
117     'nacl-win32-newlib-coverage':
118          python + (' buildbot/buildbot_standard.py '
119                    'coverage 32 newlib --coverage'),
120     # Clang trybots.
121     'nacl-precise_64-newlib-dbg-clang':
122         python + ' buildbot/buildbot_standard.py dbg 64 newlib --clang',
123     'nacl-mac10.6-newlib-dbg-clang':
124         python + ' buildbot/buildbot_standard.py dbg 32 newlib --clang',
125     # Pnacl main trybots
126     'nacl-precise_64-newlib-arm_qemu-pnacl':
127         bash + ' buildbot/buildbot_pnacl.sh mode-trybot-qemu',
128     'nacl-precise_64-newlib-x86_32-pnacl':
129          python + ' buildbot/buildbot_pnacl.py opt 32 pnacl',
130     'nacl-precise_64-newlib-x86_64-pnacl':
131          python + ' buildbot/buildbot_pnacl.py opt 64 pnacl',
132     'nacl-precise_64-newlib-mips-pnacl':
133         echo + ' "TODO(mseaborn): add mips"',
134     'nacl-arm_opt_panda':
135         bash + ' buildbot/buildbot_pnacl.sh mode-buildbot-arm-try',
136     'nacl-arm_hw_opt_panda':
137         bash + ' buildbot/buildbot_pnacl.sh mode-buildbot-arm-hw-try',
138     # Pnacl spec2k trybots
139     'nacl-precise_64-newlib-x86_32-pnacl-spec':
140         bash + ' buildbot/buildbot_spec2k.sh pnacl-trybot-x8632',
141     'nacl-precise_64-newlib-x86_64-pnacl-spec':
142         bash + ' buildbot/buildbot_spec2k.sh pnacl-trybot-x8664',
143     'nacl-arm_perf_panda':
144         bash + ' buildbot/buildbot_spec2k.sh pnacl-trybot-arm-buildonly',
145     'nacl-arm_hw_perf_panda':
146         bash + ' buildbot/buildbot_spec2k.sh pnacl-trybot-arm-hw',
147     # Toolchain glibc.
148     'precise64-glibc': bash + ' buildbot/buildbot_linux-glibc-makefile.sh',
149     'mac-glibc': bash + ' buildbot/buildbot_mac-glibc-makefile.sh',
150     'win7-glibc': 'buildbot\\buildbot_windows-glibc-makefile.bat',
151     # Toolchain newlib x86.
152     'win7-toolchain_x86': 'buildbot\\buildbot_toolchain_win.bat',
153     'mac-toolchain_x86': bash + ' buildbot/buildbot_toolchain.sh mac',
154     'precise64-toolchain_x86': bash + ' buildbot/buildbot_toolchain.sh linux',
155     # Toolchain newlib arm.
156     'win7-toolchain_arm':
157         python + ' buildbot/buildbot_toolchain_build.py --buildbot',
158     'mac-toolchain_arm':
159         python + ' buildbot/buildbot_toolchain_build.py --buildbot',
160     'precise64-toolchain_arm':
161         python + ' buildbot/buildbot_toolchain_build.py --buildbot',
162
163     # BIONIC toolchain builders.
164     'precise64-toolchain_bionic':
165         python + ' buildbot/buildbot_toolchain_build_bionic.py --buildbot',
166
167     # Pnacl toolchain builders.
168     'linux-armtools-x86_32':
169         bash + ' buildbot/buildbot_toolchain_arm_trusted.sh',
170     'linux-pnacl-x86_32':
171         python + ' buildbot/buildbot_pnacl_toolchain.py --buildbot',
172     'linux-pnacl-x86_64':
173         python + ' buildbot/buildbot_pnacl_toolchain.py --buildbot',
174     'precise-pnacl-x86_32':
175         python + ' buildbot/buildbot_pnacl_toolchain.py --buildbot',
176     'precise-pnacl-x86_64':
177         python + ' buildbot/buildbot_pnacl_toolchain.py --buildbot',
178     'mac-pnacl-x86_32':
179         python + ' buildbot/buildbot_pnacl_toolchain.py --buildbot',
180     # TODO(robertm): Delete this once we are using win-pnacl-x86_64
181     'win-pnacl-x86_32':
182         python + ' buildbot/buildbot_pnacl_toolchain.py --buildbot',
183     # TODO(robertm): use this in favor or the misnamed win-pnacl-x86_32
184     'win-pnacl-x86_64':
185         python + ' buildbot/buildbot_pnacl_toolchain.py --buildbot',
186
187     # Pnacl toolchain testers
188     'linux-pnacl-x86_64-tests-x86_64':
189         bash + ' buildbot/buildbot_pnacl_toolchain_tests.sh tc-test-bot x86-64',
190     'linux-pnacl-x86_64-tests-x86_32':
191         bash + ' buildbot/buildbot_pnacl_toolchain_tests.sh tc-test-bot x86-32',
192     'linux-pnacl-x86_64-tests-arm':
193         bash + ' buildbot/buildbot_pnacl_toolchain_tests.sh tc-test-bot arm',
194
195     # MIPS toolchain buildbot.
196     'linux-pnacl-x86_32-tests-mips':
197         bash + ' buildbot/buildbot_toolchain_mips_trusted.sh',
198
199     # Toolchain trybots.
200     'nacl-toolchain-precise64-newlib':
201         bash + ' buildbot/buildbot_toolchain.sh linux',
202     'nacl-toolchain-mac-newlib': bash + ' buildbot/buildbot_toolchain.sh mac',
203     'nacl-toolchain-win7-newlib': 'buildbot\\buildbot_toolchain_win.bat',
204     'nacl-toolchain-precise64-newlib-arm':
205         python + ' buildbot/buildbot_toolchain_build.py --trybot',
206     'nacl-toolchain-mac-newlib-arm':
207         python + ' buildbot/buildbot_toolchain_build.py --trybot',
208     'nacl-toolchain-win7-newlib-arm':
209         python + ' buildbot/buildbot_toolchain_build.py --trybot',
210     'nacl-toolchain-precise64-glibc':
211         bash + ' buildbot/buildbot_linux-glibc-makefile.sh',
212     'nacl-toolchain-mac-glibc':
213         bash + ' buildbot/buildbot_mac-glibc-makefile.sh',
214     'nacl-toolchain-win7-glibc':
215         'buildbot\\buildbot_windows-glibc-makefile.bat',
216
217     # Pnacl toolchain trybots.
218     'nacl-toolchain-linux-pnacl-x86_32':
219         python + ' buildbot/buildbot_pnacl_toolchain.py --trybot',
220     'nacl-toolchain-linux-pnacl-x86_64':
221         python + ' buildbot/buildbot_pnacl_toolchain.py --trybot',
222     'nacl-toolchain-linux-pnacl-mips': echo + ' "TODO(mseaborn)"',
223     'nacl-toolchain-precise-pnacl-x86_32':
224         python + ' buildbot/buildbot_pnacl_toolchain.py --trybot',
225     'nacl-toolchain-precise-pnacl-x86_64':
226         python + ' buildbot/buildbot_pnacl_toolchain.py --trybot',
227     'nacl-toolchain-precise-pnacl-mips': echo + ' "TODO(mseaborn)"',
228     'nacl-toolchain-mac-pnacl-x86_32':
229         python + ' buildbot/buildbot_pnacl_toolchain.py --trybot',
230     'nacl-toolchain-win7-pnacl-x86_64':
231         python + ' buildbot/buildbot_pnacl_toolchain.py --trybot',
232
233 }
234
235 special_for_arm = [
236     'win7_64',
237     'win7-64',
238     'lucid-64',
239     'lucid64',
240     'precise-64',
241     'precise64'
242 ]
243 for platform in [
244     'vista', 'win7', 'win8', 'win',
245     'mac10.6', 'mac10.7', 'mac10.8',
246     'lucid', 'precise'] + special_for_arm:
247   if platform in special_for_arm:
248     arch_variants = ['arm']
249   else:
250     arch_variants = ['', '32', '64', 'arm']
251   for arch in arch_variants:
252     arch_flags = ''
253     real_arch = arch
254     arch_part = '-' + arch
255     # Disable GYP build for win32 bots and arm cross-builders. In this case
256     # "win" means Windows XP, not Vista, Windows 7, etc.
257     #
258     # Building via GYP always builds all toolchains by default, but the win32
259     # XP pnacl builds are pathologically slow (e.g. ~38 seconds per compile on
260     # the nacl-win32_glibc_opt trybot). There are other builders that test
261     # Windows builds via gyp, so the reduced test coverage should be slight.
262     if arch == 'arm' or (platform == 'win' and arch == '32'):
263       arch_flags += ' --no-gyp'
264     if arch == '':
265       arch_part = ''
266       real_arch = '32'
267     if platform.startswith('mac'):
268       arch_flags += ' --clang'
269     # Test with Breakpad tools only on basic Linux builds.
270     if sys.platform.startswith('linux'):
271       arch_flags += ' --use-breakpad-tools'
272     for mode in ['dbg', 'opt']:
273       for libc in ['newlib', 'glibc']:
274         # Buildbots.
275         for bare in ['', '-bare']:
276           name = platform + arch_part + bare + '-' + libc + '-' + mode
277           assert name not in BOT_ASSIGNMENT, name
278           BOT_ASSIGNMENT[name] = (
279               python + ' buildbot/buildbot_standard.py ' +
280               mode + ' ' + real_arch + ' ' + libc + arch_flags)
281         # Trybots
282         for arch_sep in ['', '-', '_']:
283           name = 'nacl-' + platform + arch_sep + arch + '_' + libc + '_' + mode
284           assert name not in BOT_ASSIGNMENT, name
285           BOT_ASSIGNMENT[name] = (
286               python + ' buildbot/buildbot_standard.py ' +
287               mode + ' ' + real_arch + ' ' + libc + arch_flags)
288
289
290 def EscapeJson(data):
291   return '"' + json.dumps(data).replace('"', r'\"') + '"'
292
293
294 def Main():
295   builder = os.environ.get('BUILDBOT_BUILDERNAME')
296   build_number = os.environ.get('BUILDBOT_BUILDNUMBER')
297   slave_type = os.environ.get('BUILDBOT_SLAVE_TYPE')
298   cmd = BOT_ASSIGNMENT.get(builder)
299   if not cmd:
300     sys.stderr.write('ERROR - unset/invalid builder name\n')
301     sys.exit(1)
302
303   env = os.environ.copy()
304
305   # Don't write out .pyc files because in cases in which files move around or
306   # the PYTHONPATH / sys.path change, old .pyc files can be mistakenly used.
307   # This avoids the need for admin changes on the bots in this case.
308   env['PYTHONDONTWRITEBYTECODE'] = '1'
309
310   # Use .boto file from home-dir instead of buildbot supplied one.
311   if 'AWS_CREDENTIAL_FILE' in env:
312     del env['AWS_CREDENTIAL_FILE']
313   if 'BOTO_CONFIG' in env:
314     del env['BOTO_CONFIG']
315
316   env['GSUTIL'] = '/b/build/third_party/gsutil/gsutil'
317
318   if sys.platform == 'win32':
319     # If the temp directory is not on the same drive as the working directory,
320     # there can be random failures when cleaning up temp directories, so use
321     # a directory on the current drive. Use __file__ here instead of os.getcwd()
322     # because toolchain_main picks its working directories relative to __file__
323     filedrive, _ = os.path.splitdrive(__file__)
324     tempdrive, _ = os.path.splitdrive(env['TEMP'])
325     if tempdrive != filedrive:
326       env['TEMP'] = filedrive + '\\temp'
327       env['TMP'] = env['TEMP']
328       if not os.path.exists(env['TEMP']):
329         os.mkdir(env['TEMP'])
330
331   # Run through runtest.py to get upload of perf data.
332   build_properties = {
333       'buildername': builder,
334       'mastername': 'client.nacl',
335       'buildnumber': str(build_number),
336   }
337   factory_properties = {
338       'perf_id': builder,
339       'show_perf_results': True,
340       'step_name': 'naclperf',  # Seems unused, but is required.
341       'test_name': 'naclperf',  # Really "Test Suite"
342       'expectations': True,
343       'perf_filename': ('native_client/tools/'
344                         'nacl_perf_expectations/nacl_perf_expectations.json'),
345   }
346   # Locate the buildbot build directory by relative path, as it's absolute
347   # location varies by platform and configuration.
348   buildbot_build_dir = os.path.join(* [os.pardir] * 4)
349   runtest = os.path.join(buildbot_build_dir, 'scripts', 'slave', 'runtest.py')
350   # For builds with an actual build number, require that the script is present
351   # (i.e. that we're run from an actual buildbot).
352   if build_number is not None and not os.path.exists(runtest):
353     raise Exception('runtest.py script not found at: %s\n' % runtest)
354   cmd_exe = cmd.split(' ')[0]
355   cmd_exe_ext = os.path.splitext(cmd_exe)[1]
356   # Do not wrap these types of builds with runtest.py:
357   # - tryjobs
358   # - commands beginning with 'echo '
359   # - batch files
360   if not (slave_type == 'Trybot' or
361           cmd_exe == echo or
362           cmd_exe_ext == '.bat'):
363     # Perf dashboards are now generated by output scraping that occurs in the
364     # script runtest.py, which lives in the buildbot repository.
365     # Non-trybot builds should be run through runtest, allowing it to upload
366     # perf data if relevant.
367     cmd = ' '.join([
368         python, runtest,
369         '--build-dir=src/out',
370         '--results-url=https://chromeperf.appspot.com',
371         '--annotate=graphing',
372         '--no-xvfb',  # We provide our own xvfb invocation.
373         '--factory-properties', EscapeJson(factory_properties),
374         '--build-properties', EscapeJson(build_properties),
375         cmd,
376     ])
377
378   print "%s runs: %s\n" % (builder, cmd)
379   retcode = subprocess.call(cmd, env=env, shell=True)
380   sys.exit(retcode)
381
382
383 if __name__ == '__main__':
384   Main()