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