summaryrefslogtreecommitdiff
path: root/build/scripts/slave/recipes/v8.py
blob: fbe3a408ea71dd20137098298f59d6bad947d828 (plain)
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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
# Copyright 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import re

DEPS = [
  'archive',
  'chromium',
  'gclient',
  'json',
  'path',
  'platform',
  'properties',
  'raw_io',
  'step',
  'time',
  'tryserver',
  'v8',
]


def RunSteps(api):
  v8 = api.v8
  v8.apply_bot_config(v8.BUILDERS)

  if api.platform.is_win:
    api.chromium.taskkill()

  update_step = v8.checkout()
  v8.set_up_swarming()

  if v8.c.mips_cross_compile:
    v8.setup_mips_toolchain()
  v8.runhooks()
  api.chromium.cleanup_temp()

  if v8.should_build:
    v8.compile()

  if v8.run_dynamorio:
    v8.dr_compile()

  if v8.should_upload_build:
    v8.upload_build()

  v8.maybe_create_clusterfuzz_archive(update_step)

  if v8.should_download_build:
    v8.download_build()

  if v8.should_test:
    test_results = v8.runtests()
    v8.maybe_bisect(test_results)

    if test_results.is_negative:
      # Let the overall build fail for failures and flakes.
      raise api.step.StepFailure('Failures or flakes in build.')

  v8.maybe_trigger()
  v8.verify_cq_integrity()


def _sanitize_nonalpha(text):
  return ''.join(c if c.isalnum() else '_' for c in text)


def GenTests(api):
  # Simulated branch names for testing. Optionally upgrade these in branch
  # period to reflect the real branches used by the gitiles poller.
  STABLE_BRANCH = '4.2'
  BETA_BRANCH = '4.3'

  def get_test_branch_name(mastername, buildername):
    if mastername == 'client.dart.fyi':
      return STABLE_BRANCH
    if re.search(r'stable branch', buildername):
      return STABLE_BRANCH
    if re.search(r'beta branch', buildername):
      return BETA_BRANCH
    return 'master'

  for mastername, builders, buildername, bot_config in api.v8.iter_builders():
    bot_type = bot_config.get('bot_type', 'builder_tester')

    if bot_type in ['builder', 'builder_tester']:
      assert bot_config['testing'].get('parent_buildername') is None

    branch = get_test_branch_name(mastername, buildername)
    v8_config_kwargs = bot_config.get('v8_config_kwargs', {})
    test = (
      api.test('full_%s_%s' % (_sanitize_nonalpha(mastername),
                               _sanitize_nonalpha(buildername))) +
      api.properties.generic(mastername=mastername,
                             buildername=buildername,
                             branch=branch,
                             parent_buildername=bot_config.get(
                                 'parent_buildername'),
                             revision='20123') +
      api.platform(bot_config['testing']['platform'],
                   v8_config_kwargs.get('TARGET_BITS', 64))
    )

    if bot_config.get('parent_buildername'):
      test += api.properties(parent_got_revision='54321')
      # Add isolated-tests property from parent builder.
      parent = builders[bot_config['parent_buildername']]
      isolated_tests = parent['testing'].get('isolated_tests')
      if isolated_tests:
        test += api.properties(isolated_tests=isolated_tests)

    if mastername.startswith('tryserver'):
      test += (api.properties(
          revision='12345',
          patch_url='svn://svn-mirror.golo.chromium.org/patch'))

    yield test

  yield (
    api.test('branch_sync_failure') +
    api.properties.tryserver(mastername='client.v8.branches',
                             buildername='V8 Linux - beta branch',
                             branch=BETA_BRANCH,
                             revision='20123') +
    api.platform('linux', 32) +
    api.step_data('bot_update', retcode=1)
  )

  # Test usage of test filters. They're used when the buildbucket
  # job gets a property 'testfilter', which is expected to be a json list of
  # test-filter strings.
  mastername = 'tryserver.v8'
  buildername = 'v8_linux_rel'
  bot_config = api.v8.BUILDERS[mastername]['builders'][buildername]
  yield (
    api.test('full_%s_%s_test_filter' % (
        _sanitize_nonalpha(mastername), _sanitize_nonalpha(buildername))) +
    api.properties.generic(
        mastername=mastername,
        buildername=buildername,
        branch='master',
        revision='12345',
        patch_url='svn://svn-mirror.golo.chromium.org/patch',
        testfilter=['mjsunit/regression/*', 'test262/foo', 'test262/bar'],
        extra_flags='--trace_gc --turbo_stats',
    ) +
    api.platform(bot_config['testing']['platform'],
                 v8_config_kwargs.get('TARGET_BITS', 64))
  )

  # Test using extra flags with a bot that already uses some extra flags as
  # positional argument.
  buildername = 'v8_linux_greedy_allocator_dbg'
  bot_config = api.v8.BUILDERS[mastername]['builders'][buildername]
  yield (
    api.test('full_%s_%s_positional_extra_flags' % (
        _sanitize_nonalpha(mastername), _sanitize_nonalpha(buildername))) +
    api.properties.generic(
        mastername=mastername,
        buildername=buildername,
        branch='master',
        revision='12345',
        patch_url='svn://svn-mirror.golo.chromium.org/patch',
        extra_flags=['--trace_gc', '--turbo_stats'],
    ) +
    api.platform(bot_config['testing']['platform'],
                 v8_config_kwargs.get('TARGET_BITS', 64))
  )

  mastername = 'client.v8'
  buildername = 'V8 Linux - isolates'
  bot_config = api.v8.BUILDERS[mastername]['builders'][buildername]
  def TestFailures(wrong_results, flakes):
    results_suffix = "_wrong_results" if wrong_results else ""
    flakes_suffix = "_flakes" if flakes else ""
    return (
      api.test('full_%s_%s_test_failures%s%s' %
          (_sanitize_nonalpha(mastername),
          _sanitize_nonalpha(buildername),
          results_suffix,
          flakes_suffix)) +
      api.properties.generic(mastername=mastername,
                             buildername=buildername,
                             branch='master',
                             parent_buildername=bot_config.get(
                                 'parent_buildername')) +
      api.platform(bot_config['testing']['platform'],
                   v8_config_kwargs.get('TARGET_BITS', 64)) +
      api.v8(test_failures=True, wrong_results=wrong_results, flakes=flakes)
    )

  yield TestFailures(wrong_results=False, flakes=False)
  yield TestFailures(wrong_results=False, flakes=True)
  yield (
      TestFailures(wrong_results=True, flakes=False) +
      api.expect_exception('AssertionError')
  )

  yield (
    api.test('full_%s_%s_empty_json' % (
        _sanitize_nonalpha(mastername), _sanitize_nonalpha(buildername))) +
    api.properties.generic(mastername=mastername,
                           buildername=buildername,
                           branch='master',
                           parent_buildername=bot_config.get(
                               'parent_buildername')) +
    api.platform(bot_config['testing']['platform'],
                 v8_config_kwargs.get('TARGET_BITS', 64)) +
    api.override_step_data('Check', api.json.output([])) +
    api.expect_exception('AssertionError')
  )

  yield (
    api.test('full_%s_%s_one_failure' %
        (_sanitize_nonalpha(mastername),
        _sanitize_nonalpha(buildername))) +
    api.properties.generic(mastername=mastername,
                           buildername=buildername,
                           branch='master',
                           parent_buildername=bot_config.get(
                               'parent_buildername')) +
    api.platform(bot_config['testing']['platform'],
                 v8_config_kwargs.get('TARGET_BITS', 64)) +
    api.override_step_data('Check', api.v8.one_failure())
  )

  buildername = 'V8 Linux - memcheck'
  yield (
    api.test('full_%s_%s_no_errors' % (
        _sanitize_nonalpha(mastername), _sanitize_nonalpha(buildername))) +
    api.properties.generic(mastername=mastername,
                           buildername=buildername,
                           branch='master',
                           parent_buildername=bot_config.get(
                               'parent_buildername')) +
    api.platform(bot_config['testing']['platform'],
                 v8_config_kwargs.get('TARGET_BITS', 64)) +
    api.override_step_data(
        'Simple Leak Check',
        api.raw_io.stream_output('no leaks are possible', stream='stderr'),
    )
  )

  buildername = 'V8 Fuzzer'
  yield (
    api.test('full_%s_%s_fuzz_archive' % (
        _sanitize_nonalpha(mastername), _sanitize_nonalpha(buildername))) +
    api.properties.generic(mastername=mastername,
                           buildername=buildername,
                           branch='master',
                           parent_buildername=bot_config.get(
                               'parent_buildername')) +
    api.platform(bot_config['testing']['platform'],
                 v8_config_kwargs.get('TARGET_BITS', 64)) +
    api.override_step_data(
        'Fuzz',
        api.raw_io.stream_output(
          'foo\nCreating archive bar\nbaz', stream='stdout'),
        retcode=1,
    )
  )

  # Bisect over range a1, a2, a3. Assume a2 is the culprit. Steps:
  # Bisect a0 -> no failures.
  # Bisect a2 -> failures.
  # Bisect a1 -> no failures.
  # Report culprit a2.
  buildername = 'V8 Linux - predictable'
  yield (
    api.test('full_%s_%s_bisect' % (
        _sanitize_nonalpha(mastername), _sanitize_nonalpha(buildername))) +
    api.properties.generic(mastername=mastername,
                           buildername=buildername,
                           branch='master') +
    api.platform(bot_config['testing']['platform'],
                 v8_config_kwargs.get('TARGET_BITS', 64)) +
    api.override_step_data('Mjsunit', api.v8.bisect_failures_example()) +
    api.override_step_data(
        'Bisect a2.Retry', api.v8.bisect_failures_example()) +
    api.time.step(120)
  )

  # Disable bisection, because the failing test is too long compared to the
  # overall test time.
  yield (
    api.test('full_%s_%s_bisect_tests_too_long' % (
        _sanitize_nonalpha(mastername), _sanitize_nonalpha(buildername))) +
    api.properties.generic(mastername=mastername,
                           buildername=buildername,
                           branch='master') +
    api.platform(bot_config['testing']['platform'],
                 v8_config_kwargs.get('TARGET_BITS', 64)) +
    api.override_step_data('Mjsunit', api.v8.bisect_failures_example()) +
    api.time.step(7)
  )

  # Bisect over range a1, a2, a3. Assume a3 is the culprit. This is a tester
  # and the build for a2 is not available. Steps:
  # Bisect a0 -> no failures.
  # Bisect a1 -> no failures.
  # Report a2 and a3 as possible culprits.
  buildername = 'V8 Linux64 - debug - greedy allocator'
  bot_config = api.v8.BUILDERS[mastername]['builders'][buildername]
  yield (
    api.test('full_%s_%s_bisect_tester' % (
        _sanitize_nonalpha(mastername), _sanitize_nonalpha(buildername))) +
    api.properties.generic(mastername=mastername,
                           buildername=buildername,
                           branch='master',
                           parent_buildername=bot_config.get(
                               'parent_buildername')) +
    api.platform(bot_config['testing']['platform'],
                 v8_config_kwargs.get('TARGET_BITS', 64)) +
    api.override_step_data('Check', api.v8.bisect_failures_example()) +
    api.time.step(120)
  )

  # Disable bisection due to a recurring failure. Steps:
  # Bisect a0 -> failures.
  buildername = 'V8 Linux - predictable'
  yield (
    api.test('full_%s_%s_bisect_recurring_failure' % (
        _sanitize_nonalpha(mastername), _sanitize_nonalpha(buildername))) +
    api.properties.generic(mastername=mastername,
                           buildername=buildername,
                           branch='master') +
    api.platform(bot_config['testing']['platform'],
                 v8_config_kwargs.get('TARGET_BITS', 64)) +
    api.override_step_data('Mjsunit', api.v8.bisect_failures_example()) +
    api.override_step_data(
        'Bisect a0.Retry', api.v8.bisect_failures_example()) +
    api.time.step(120)
  )

  # Disable bisection due to less than two changes.
  yield (
    api.test('full_%s_%s_bisect_one_change' % (
        _sanitize_nonalpha(mastername), _sanitize_nonalpha(buildername))) +
    api.properties.generic(mastername=mastername,
                           buildername=buildername,
                           branch='master') +
    api.platform(bot_config['testing']['platform'],
                 v8_config_kwargs.get('TARGET_BITS', 64)) +
    api.override_step_data('Mjsunit', api.v8.bisect_failures_example()) +
    api.override_step_data(
        'Bisect.Fetch changes', api.v8.example_one_buildbot_change()) +
    api.time.step(120)
  )

  buildername = 'V8 GC Stress - 3'
  bot_config = api.v8.BUILDERS[mastername]['builders'][buildername]
  yield (
    api.test('full_%s_%s_bisect_no_shards' % (
        _sanitize_nonalpha(mastername), _sanitize_nonalpha(buildername))) +
    api.properties.generic(mastername=mastername,
                           buildername=buildername,
                           branch='master',
                           parent_buildername=bot_config.get(
                               'parent_buildername')) +
    api.platform(bot_config['testing']['platform'],
                 v8_config_kwargs.get('TARGET_BITS', 64)) +
    api.override_step_data('Mjsunit', api.v8.bisect_failures_example()) +
    api.time.step(120)
  )