<commit_before># vim: ft=python:
# Copyright (c) 2012 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.

from buildbot.changes import svnpoller
from buildbot.scheduler import Dependent
from buildbot.scheduler import Nightly
from buildbot.scheduler import Periodic
from buildbot.scheduler import Scheduler
from buildbot.scheduler import Triggerable
from buildbot.status.mail import MailNotifier

# These modules come from scripts/master, which must be in the PYTHONPATH.
from master import build_utils
from master import chromium_notifier
from master import failures_notifier
from master import master_config
from master import master_utils
from master import slaves_list

from master.factory import annotator_factory
from master.factory import chromeos_factory
from master.factory import chromium_factory

# These modules come from scripts/common, which must be in the PYTHONPATH.
import config
import master_site_config

import master_win_asan_cfg

ActiveMaster = master_site_config.ChromiumFYI

CODESEARCH_NOTIFIER = True
DRMEMORY_NOTIFIER = True
STATUS_PUSH = False

# This is the dictionary that the buildmaster pays attention to. We also use
# a shorter alias to save typing.
c = BuildmasterConfig = {}
c['status'] = []

config.DatabaseSetup(c, require_dbconfig=ActiveMaster.is_production_host)

####### CHANGESOURCES

# the 'change_source' list tells the buildmaster how it should find out about
# source code changes. Any class which implements IChangeSource can be added
# to this list: there are several in buildbot/changes/*.py to choose from.
def ChromeTreeFileSplitter(path):
  """split_file for the 'src' project in the trunk."""

  # Exclude .DEPS.git from triggering builds on chrome.
  if path == 'src/.DEPS.git':
    return None

  # List of projects we are interested in. The project names must exactly
  # match paths in the Subversion repository, relative to the 'path' URL
  # argument. build_utils.SplitPath() will use them as branch names to
  # kick off the Schedulers for different projects.
  projects = ['src']
  return build_utils.SplitPath(projects, path)

# Rev link urls.
chromium_rev = 'http://src.chromium.org/viewvc/chrome?view=rev&revision=%s'

# Polls config.Master.trunk_url for changes
trunk_poller = svnpoller.SVNPoller(svnurl=config.Master.trunk_url,
                                   split_file=ChromeTreeFileSplitter,
                                   pollinterval=10,
                                   revlinktmpl=chromium_rev)

c['change_source'] = [trunk_poller]

# Number of machines to shard ash browser_tests over.
ASH_SHARDS = 2

####### SCHEDULERS

## configure the Schedulers

# Main scheduler for all changes in trunk.
s_chromium = Scheduler(
    name='chromium',
    branch='src',
    treeStableTimer=60,
    builderNames=['Chromium Linux Reliability (valgrind)',
                  'Chromium Linux Browser Builder (valgrind)',
                  'Chromium Linux Browser (valgrind) (1)',
                  'Chromium Linux Browser (valgrind) (2)',
                  'Chromium Linux Browser (valgrind) (3)',
                  'Chromium Linux Browser (valgrind) (4)',
                  'Chromium Builder',
                  'Chromium Linux Perf',
                  'Chromium Windows Perf',
                  'Chromium Mac Perf',
                  'Chromium Cros32 Perf',
                  'Chromium Cros64 Perf',
                  'Chromium Windows Instant Extended',
                  'Chromium Linux Buildrunner',
                  'Chromium Windows Buildrunner',
                  'Chromium Mac Buildrunner',
                  'Chromium Mac 10.8 Buildrunner',
                  'Chromium Builder (dbg)',
                  'Chromium Win Multiple',
                  'Chromium Win VS2012 (dbg)',
                  'Chromium Win VS2012',
                  'Chromium Win VS2012 Goma (dbg)',
                  'Chromium Win VS2012 Goma',
                  'Chromium Win Ninja Goma',
                  'Chromium Win Ninja Goma (shared)',
                  'Chromium Win x64 Clobber',
                  'Chromium Win7 Ninja Goma',
                  'Chromium Win7 Ninja Goma (shared)',
                  'Linux Tests (tsan RV)',
                  'Chromium Linux TSan v2',
                  'Chromium Linux LSan (and ASan)',
                  'Chromium Mac 10.6 (tsan)',
                  'Windows Tests (DrMemory XP)',
                  'Windows Unit (DrMemory full) (1)',
                  'Windows Unit (DrMemory full) (2)',
                  'Windows Browser (DrMemory full) (1)',
                  'Windows Browser (DrMemory full) (2)',
                  'Windows Browser (DrMemory full) (3)',
                  'Windows Browser (DrMemory full) (4)',
                  'Windows Builder (DrMemory)',
                  'Windows Tests (TSan Win 7)',
                  'Chromium Vista Memory',
                  'Chromium Linux Memory',
                  'Chromium Mac Memory',
                  'Chromium Linux Redux',
                  'Linux ARM Cross-Compile',
                  'Android Builder (dbg)',
                  'Android x86 Builder (dbg)',
                  'Android User Builder Tests',
                  'Android Asan Builder Tests (dbg)',
                  'Android Builder Tests (JB Nexus7)(shared)',
                  'Android AOSP Builder (dbg)',
                  'Chromium iOS Simulator (dbg)',
                  'Chromium iOS Device',
                  'More NaCl Tests (mac)',
                  'More NaCl Tests (linux)',
                  'Chromium Linux Goma Canary',
                  'Chromium Linux Precise Goma LinkTest',
                  'Chromium Linux32 Goma Canary',
                  'Chromium Mac 10.6 Goma Canary',
                  'Chromium Mac 10.7 Goma Canary',
                  'Chromium Mac 10.6 Ninja Goma Canary',
                  'Chromium Mac 10.7 Ninja Goma Canary',
                  'Chromium Mac 10.8 x64 (experimental)',
                  'Windows 8 App Certification',
                  'ChromiumOS Linux Tests',
                  ] + [
                      'Chromium Win Aura Ash (%d)' % shard
                       for shard in range(1, ASH_SHARDS+1)
                  ])

# Triggerable scheduler for Windows Release.
s_chromium_win_rel = Triggerable(
    name='win_rel',
    builderNames=['Chrome Frame Perf',
                  'Chrome Frame Tests (ie6)(peruser)',
                  'Chrome Frame Tests (ie7)(peruser)',
                  'Chrome Frame Tests (ie8)(peruser)',
                  'Chromium Win MiniInstaller Tests',
                  'More NaCl Tests (win32)',
                  'More NaCl Tests (win64)',
                  'Win8 Tests (1)',
                  'Win8 Tests (2)',
                  'Windows Tests (Memory benchmark)'])

# Triggerable scheduler for Windows Debug.
s_chromium_win_dbg = Triggerable(
    name='win_dbg',
    builderNames=['Vista Tests (dbg)(1)',
                  'Vista Tests (dbg)(2)',
                  'Chrome Frame Tests (ie8)(dbg)'])

# Triggerable scheduler for Android Builder
s_chromium_android_dbg = Triggerable(
    name='android_dbg',
    builderNames=['Android Tests (JB GalaxyNexus)(dbg)',
                  'Android Tests (ICS GalaxyNexus)(dbg)',
                  'Android Tests (JB Nexus7)(dbg)',
                  'Android Tests (JB Manta)(dbg)',
                  'Android ChromeDriver Tests (dbg)'])

s_chromium_linux_browser_valgrind_trigger = Triggerable(
    'chromium_linux_browser_valgrind',
    ['Chromium Linux Browser (valgrind) (1)',
     'Chromium Linux Browser (valgrind) (2)',
     'Chromium Linux Browser (valgrind) (3)',
     'Chromium Linux Browser (valgrind) (4)',
    ])

s_chromium_windows_drmemory_trigger = Triggerable(
    name='chromium_windows_drmemory',
    builderNames=[
     'Windows Unit (DrMemory full) (1)',
     'Windows Unit (DrMemory full) (2)',
     'Windows Browser (DrMemory full) (1)',
     'Windows Browser (DrMemory full) (2)',
     'Windows Browser (DrMemory full) (3)',
     'Windows Browser (DrMemory full) (4)',
    ])

# Triggerable scheduler for Codesearch.
s_chromium_codesearch = Triggerable(
    name='chromium_codesearch',
    builderNames=[
      'Chromium Linux Codesearch',
      'ChromiumOS Codesearch',
    ])


# Triggerable scheduler for Linux ARM
s_chromium_linux_arm = Triggerable(
    name='chromium_linux_arm',
    builderNames=[
        'Linux ARM Tests (Panda)'
    ])

# Triggerable scheduler for 10.8 x64 tests
s_chromium_mac_108_x64_experimental = Triggerable(
    name='chromium_mac_108_x64_experimental',
    builderNames=[
        'Chromium Mac 10.8 x64 tester (experimental)'
    ])

# Triggerable scheduler for Windows Coverage
s_chromium_win_coverage = Triggerable(
    name='chromium_win_coverage',
    builderNames=[
        'Win Coverage Tests (1)',
        'Win Coverage Tests (2)',
        'Win Coverage Tests (3)',
        'Win Coverage Tests (4)',
        'Win Coverage Tests (5)',
    ])

# 4-hourly scheduler.
#
# The Codesearch Scheduler bot will trigger the s_chromium_codesearch scheduler,
# so all codesearch bots will start on the same revision.
s_chromium_4hourly = Nightly(name='chromium_4hourly',
                             builderNames=[
                               'Chromium Codesearch Scheduler',
                             ],
                             branch='src',
                             hour=range(0, 24, 4),
                             minute=0)

# 4 times daily build of metro_driver and delegate_execute for Win8.
s_chromium_6hourly = Nightly(name='chromium_6hourly',
                             builderNames=['Win8 (delegate_execute)',
                                           'Win8 (metro_driver)'],
                             branch='src',
                             hour=range(0, 24, 6),
                             minute=0)

# Once an hour scheduler to provide a periodic poll of lkgr.  The
# coverage builds "run" once an hour but nop themselves if lkgr hasn't
# changed.
s_chromium_hourly = Periodic(name="hourly",
                             builderNames=['Linux Coverage (dbg)',
                                           'Win Coverage Processor'],
                             periodicBuildTimer=60*60)  # in seconds


c['schedulers'] = [s_chromium,
                   s_chromium_hourly,
                   s_chromium_4hourly,
                   s_chromium_6hourly,
                   s_chromium_android_dbg,
                   s_chromium_codesearch,
                   s_chromium_win_rel,
                   s_chromium_win_dbg,
                   s_chromium_linux_browser_valgrind_trigger,
                   s_chromium_windows_drmemory_trigger,
                   s_chromium_linux_arm,
                   s_chromium_mac_108_x64_experimental,
                   s_chromium_win_coverage,
                  ]

# Tests that are single-machine shard-safe.
sharded_tests = [
  'aura_unittests',
  'base_unittests',
  'browser_tests',
  'cacheinvalidation_unittests',
  'cc_unittests',
  'chromedriver2_tests',
  'chromedriver2_unittests',
  'components_unittests',
  'content_browsertests',
  'content_unittests',
  'crypto_unittests',
  'device_unittests',
  'gpu_unittests',
  'jingle_unittests',
  'media_unittests',
  'net_unittests',
  'ppapi_unittests',
  'printing_unittests',
  'remoting_unittests',
  'sync_integration_tests',
  'sync_unit_tests',
  'ui_unittests',
  'unit_tests',
  'views_unittests',
  'webkit_compositor_bindings_unittests',
]

####### BUILDERS

# buildbot/process/factory.py provides several BuildFactory classes you can
# start with, which implement build processes for common targets (GNU
# autoconf projects, CPAN perl modules, etc). The factory.BuildFactory is the
# base class, and is configured with a series of BuildSteps. When the build
# is run, the appropriate buildslave is told to execute each Step in turn.

# the first BuildStep is typically responsible for obtaining a copy of the
# sources. There are source-obtaining Steps in buildbot/process/step.py for
# CVS, SVN, and others.

builders = []

# ----------------------------------------------------------------------------
# FACTORIES

F = chromium_factory.ChromiumFactory
def win(): return F('src/chrome', 'win32')
def win_build(): return F('src/build', 'win32')
def win_out(): return F('src/out', 'win32')
def win_metro(): return F('src/metro_driver', 'win32')
def win_delegate(): return F('src/delegate_execute', 'win32')
def mac(): return F('src/xcodebuild', 'darwin')
def linux(**kwargs): return F('src/out', 'linux2', **kwargs)
def ios(): return F('src/xcodebuild', 'darwin')

def codesearch():
  return F('src/build', 'linux2', pull_internal=False, full_checkout=True,
           additional_svn_urls=[config.Master.trunk_url_tools])

def codesearch_scheduler():
  return F('src/build', 'linux2', pull_internal=False)

def chromeos():
  return F('src/build', 'linux2')

def linux_android(custom_deps_list=None):
  return F('src/build', 'linux2', nohooks_on_update=True, target_os='android',
           custom_deps_list=custom_deps_list)

chromium_rel_archive = master_config.GetArchiveUrl(
    'ChromiumFYI',
    'Chromium Builder',
    'chromium-rel-builder',
    'win32')

chromium_dbg_archive = master_config.GetArchiveUrl(
    'ChromiumFYI',
    'Chromium Builder (dbg)',
    'chromium-dbg-builder',
    'win32')

chromium_linux_browser_valgrind_archive = master_config.GetArchiveUrl(
    'ChromiumFYI',
    'Chromium Linux Browser Builder (valgrind)',
    'chromium-rel-linux-browser-valgrind-builder',
    'linux')

chromium_windows_drmemory_archive = master_config.GetArchiveUrl(
    'ChromiumFYI',
    'Windows Builder (DrMemory)',
    'drm-cr',
    'win32')

chromium_linux_arm_archive = master_config.GetGSBuildCacheUrl(
    ActiveMaster.project_name, 'Linux ARM Cross-Compile')

chromium_dbg_win_drmemory_archive_ext = ('http://vm832-m1/b/build/slave/'
                                         'chromium-dbg-win-drmemory-builder/'
                                         'chrome_staging/full-build-win32.zip')

chromium_rel_archive_ext = ('http://master.chromium.org:8802/b/build/slave'
                            '/chromium-rel-builder/chrome_staging/'
                            'full-build-win32.zip')

chromium_android_fyi_dbg_archive = master_config.GetGSUtilUrl(
    'chromium-android', 'android_fyi_dbg')

chromium_mac_108_x64_experimental_archive = master_config.GetGSUtilUrl(
    'chromium-qa', 'Chromium Mac 10.8 x64 (experimental)')

# The identifier of the factory is the build configuration. If two factories
# are using the same build configuration, they should have the same identifier.
f_chromium_rel_builder = win_build().ChromiumFactory(
    slave_type='Builder',
    project='all.sln;chromium_builder_tests',
    factory_properties={'trigger': 'win_rel',
                        'gclient_env': {'GYP_DEFINES': 'fastbuild=1'}})

f_chromium_dbg_builder = win_build().ChromiumFactory(
    slave_type='Builder',
    target='Debug',
    project='all.sln;chromium_builder_tests',
    factory_properties={'trigger': 'win_dbg',
                        'gclient_env': {'GYP_DEFINES': 'fastbuild=1'}})

f_linux_perf = linux().ChromiumFactory(target='Release',
    slave_type='Builder',
    options=['--compiler=goma', '--', 'chromium_builder_perf'],
    factory_properties={
      'show_perf_results': True,
      'expectations': True,
      'halt_on_missing_build': True,
      'perf_id': 'linux-release-fyi'},
    tests=['page_cycler_moz',
      'page_cycler_morejs',
      'page_cycler_intl_ar_fa_he',
      'page_cycler_intl_es_fr_pt-BR',
      'page_cycler_intl_hi_ru',
      'page_cycler_intl_ja_zh',
      'page_cycler_intl_ko_th_vi',
      'page_cycler_typical_25',
      'page_cycler_bloat',
      'page_cycler_dhtml',
      'page_cycler_indexeddb',
      'smoothness_top_25',
      'jsgamebench',
      'kraken',
      'robohornet_pro',
      'memory_top_25',
      'telemetry_perf_unittests',
      'telemetry_unittests'])

f_win_perf = win_build().ChromiumFactory(slave_type='Builder',
    project='all.sln;chromium_builder_perf',
    factory_properties={
      'show_perf_results': True,
      'expectations': True,
      'halt_on_missing_build': True,
      'perf_id': 'chromium-rel-win7-dual-fyi',
      'process_dumps': True,
      'start_crash_handler': True,},
    tests=['page_cycler_moz',
      'page_cycler_morejs',
      'page_cycler_intl_ar_fa_he',
      'page_cycler_intl_es_fr_pt-BR',
      'page_cycler_intl_hi_ru',
      'page_cycler_intl_ja_zh',
      'page_cycler_intl_ko_th_vi',
      'page_cycler_typical_25',
      'page_cycler_bloat',
      'page_cycler_dhtml',
      'page_cycler_indexeddb',
      'smoothness_top_25',
      'jsgamebench',
      'kraken',
      'robohornet_pro',
      'memory_top_25',
      'telemetry_perf_unittests',
      'telemetry_unittests'])

f_mac_perf = mac().ChromiumFactory(slave_type='Builder',
    options=['--compiler=goma-clang', '--', '-target', 'chromium_builder_perf'],
    factory_properties={
      'archive_build': False,
      'show_perf_results': True,
      'expectations': True,
      'halt_on_missing_build': True,
      'perf_id': 'chromium-rel-mac7-fyi', },
    tests=['page_cycler_moz',
      'page_cycler_morejs',
      'page_cycler_intl_ar_fa_he',
      'page_cycler_intl_es_fr_pt-BR',
      'page_cycler_intl_hi_ru',
      'page_cycler_intl_ja_zh',
      'page_cycler_intl_ko_th_vi',
      'page_cycler_typical_25',
      'page_cycler_bloat',
      'page_cycler_dhtml',
      'page_cycler_indexeddb',
      'smoothness_top_25',
      'jsgamebench',
      'kraken',
      'robohornet_pro',
      'memory_top_25',
      'telemetry_perf_unittests',
      'telemetry_unittests'])

f_cros32_perf = chromeos_factory.CbuildbotFactory(
  buildroot='/b/cbuild.cros32_perf',
  pass_revision=True,
  params='x86-generic-telemetry').get_factory()

f_cros64_perf = chromeos_factory.CbuildbotFactory(
  buildroot='/b/cbuild.cros64_perf',
  pass_revision=True,
  params='amd64-generic-telemetry').get_factory()

f_win_instantextended = win_build().ChromiumFactory(
           project='all.sln;chromium_builder_tests',
           tests=[
               'instant_extended_manual_tests',
               'buildrunner_tests',
           ],
           slave_type='BuilderTester',
           factory_properties={
               'gclient_env': {
                   'GYP_DEFINES': 'fastbuild=1',
               },
               'process_dumps': True,
               'start_crash_handler': True,
               'generate_gtest_json': True,
           })

f_linux_buildrunner = linux().ChromiumFactory(
           tests=['base_unittests_br',
                  'browser_tests_br',
                  'cacheinvalidation_br',
                  'content_browsertests_br',
                  'crypto_br',
                  'dbus_br',
                  'googleurl_br',
                  'gpu_br',
                  'jingle_br',
                  'media_br',
                  'net_br',
                  'ppapi_unittests_br',
                  'printing_br',
                  'remoting_br',
                  'unit_br',
                  'buildrunner_tests',
           ],
           options=['--compiler=goma'],
           slave_type='Builder',
           factory_properties={
               'archive_build': False,
               'generate_gtest_json': True,
               'gclient_env': {
                   'GYP_DEFINES': 'target_arch=x64 '
                   'tests_run=noop,component=shared_library'}
           })

f_win_buildrunner = win_build().ChromiumFactory(
           project='all.sln;chromium_builder_tests',
           tests=['base_unittests_br',
                  'browser_tests_br',
                  'cacheinvalidation_br',
                  'content_browsertests_br',
                  'courgette_br',
                  'crypto_br',
                  'googleurl_br',
                  'gpu_br',
                  'installer_br',
                  'jingle_br',
                  'media_br',
                  'ppapi_unittests_br',
                  'printing_br',
                  'remoting_br',
                  'sandbox_br',
                  'buildrunner_tests',
           ],
           slave_type='Builder',
           factory_properties={'gclient_env': {'GYP_DEFINES': 'fastbuild=1',
                                               'GYP_MSVS_VERSION': '2008'},
                               'process_dumps': True,
                               'start_crash_handler': True,
                               'generate_gtest_json': True,
                               'archive_build': False,
           })

f_mac_buildrunner = mac().ChromiumFactory(
           tests=['base_unittests_br',
                  'browser_tests_br',
                  'cacheinvalidation_br',
                  'content_browsertests_br',
                  'crypto_br',
                  'googleurl_br',
                  'gpu_br',
                  'jingle_br',
                  'media_br',
                  'message_center_unittests_br',
                  'ppapi_unittests_br',
                  'printing_br',
                  'remoting_br',
                  'buildrunner_tests',
           ],
           options=['--compiler=goma-clang', '--', '-target',
                    'chromium_builder_tests'],
           factory_properties={
               'archive_build': False,
               'generate_gtest_json': True
           })


def without(these, notthese):
  return [x for x in these if x not in notthese]

tests_win_1 = ['base_unittests',
               'cacheinvalidation_unittests',
               'components_unittests',
               'courgette_unittests',
               'crypto_unittests',
               'device_unittests',
               'google_apis_unittests',
               'googleurl',
               'gpu',
               'installer',
               'jingle',
               'media',
               'net',
               'ppapi_unittests',
               'printing',
               'remoting',
               'sandbox',
               'unit',]
tests_win_2 = ['browser_tests',
               'content_browsertests']

f_chromium_rel_multiple_builder_tests = win_build().ChromiumFactory(
    slave_type='BuilderTester',
    options=['--build-tool=ninja', '--', 'chromium_builder_tests'],
    factory_properties={
        'gclient_env': {
            'GYP_DEFINES': ('component=static_library '
                            'fastbuild=1 '
                            'chrome_multiple_dll=1'),
            'GYP_GENERATORS': 'ninja',
        }})

f_chromium_rel_delegate = win_delegate().ChromiumFactory(slave_type='Builder')
f_chromium_rel_metro = win_metro().ChromiumFactory(slave_type='Builder')

f_chromium_dbg_tests_1 = win_build().ChromiumFactory(
    slave_type='Tester',
    target='Debug',
    build_url=chromium_dbg_archive,
    tests=tests_win_1,
    factory_properties={'process_dumps': True,
                        'start_crash_handler': True})

f_chromium_dbg_tests_2 = win_build().ChromiumFactory(
    slave_type='Tester',
    target='Debug',
    build_url=chromium_dbg_archive,
    tests=tests_win_2,
    factory_properties={'process_dumps': True,
                        'start_crash_handler': True})

f_chromium_rel_tests_1 = win_build().ChromiumFactory(
    slave_type='Tester',
    build_url=chromium_rel_archive,
    tests=tests_win_1,
    factory_properties={'process_dumps': True,
                        'start_crash_handler': True})

f_chromium_rel_tests_2 = win_build().ChromiumFactory(
    slave_type='Tester',
    build_url=chromium_rel_archive,
    tests=tests_win_2,
    factory_properties={'process_dumps': True,
                        'start_crash_handler': True})

f_cr_win_rel_mini_installer = win_build().ChromiumFactory(
    slave_type='Tester',
    build_url=chromium_rel_archive,
    tests=['mini_installer'],
    factory_properties={'process_dumps': True,
                        'start_crash_handler': True,})

f_cr_rel_perf_frame = win_build().ChromiumFactory(
    slave_type='Tester',
    build_url=chromium_rel_archive_ext,
    tests=['chrome_frame_perftests'],
    factory_properties={'show_perf_results': True,
                        'expectations': True,
                        'perf_id': 'chromium-rel-frame',
                        'process_dumps': True,
                        'start_crash_handler': True,})

f_cr_rel_frame = win_build().ChromiumFactory(
    slave_type='Tester',
    build_url=chromium_rel_archive,
    tests=['chrome_frame'],
    factory_properties={'process_dumps': True,
                        'start_crash_handler': True,})

f_cr_dbg_frame = win_build().ChromiumFactory(
    target='Debug',
    slave_type='Tester',
    build_url=chromium_dbg_archive,
    tests=['chrome_frame'],
    factory_properties={'process_dumps': True,
                        'start_crash_handler': True,})

f_chromium_linux_redux = linux().ChromiumFactory(
    tests=[
      'base_unittests',
      'cacheinvalidation_unittests',
      'crypto_unittests',
      'device_unittests',
      'jingle',
      'net',
      'unit',
      'check_deps2git',
    ],
    options=['base_unittests',
             'cacheinvalidation_unittests',
             'content_unittests',
             'crypto_unittests',
             'device_unittests',
             'ipc_tests',
             'jingle_unittests',
             'media_unittests',
             'net_unittests',
             'ppapi_unittests',
             'printing_unittests',
             'remoting_unittests',
             'sql_unittests',
             'sync_unit_tests',
             'ui_unittests',
             'unit_tests',
             'url_unittests',
             ],
    factory_properties={
        'gclient_env': {
            'GYP_DEFINES': ('linux_fpic=1 '
                            'enable_touch_events=1 '
                            'disable_nacl=1 '
                            'linux_use_tcmalloc=0 '
                            'linux_breakpad=0 '
                            'remoting=0 '
                            'configuration_policy=0 '
                            'safe_browsing=0 '
                            'use_openssl=1')}})

# Windows Tests (DrMemory XP)
f_chromium_dbg_win_drmemory = win_out().ChromiumFactory(
    slave_type='Tester',
    target='Debug',
    build_url=chromium_dbg_win_drmemory_archive_ext,
    tests=[
      'drmemory_light_url',
      'drmemory_light_printing',
      'drmemory_light_media',
      'drmemory_light_sql',
      'drmemory_light_crypto',
      'drmemory_light_remoting',
      'drmemory_light_ipc_tests',
      'drmemory_light_base_unittests',
      'drmemory_light_net',
      # run tests in shards to decrease the number of reports per shard.
      'drmemory_light_unit_1_of_3',
      'drmemory_light_unit_2_of_3',
      'drmemory_light_unit_3_of_3',
    ],
    factory_properties={'needs_drmemory': True}
)

# Windows Unit (DrMemory full) (1)
f_chromium_dbg_win_drmemory_full_1 = win_out().ChromiumFactory(
    slave_type='Tester',
    target='Debug',
    build_url=chromium_windows_drmemory_archive,
    tests=[
      'drmemory_full_url',
      'drmemory_full_printing',
      'drmemory_full_media',
      'drmemory_full_sql',
      'drmemory_full_crypto',
      'drmemory_full_remoting',
      'drmemory_full_ipc_tests',
      'drmemory_full_base_unittests',
      'drmemory_full_net',
    ],
    factory_properties={'needs_drmemory': True},
)

# Windows Unit (DrMemory full) (2)
f_chromium_dbg_win_drmemory_full_2 = win_out().ChromiumFactory(
    slave_type='Tester',
    target='Debug',
    build_url=chromium_windows_drmemory_archive,
    tests=[
      # Full mode has a high memory overhead currently, so shard the tests
      # more.
      'drmemory_full_unit_1_of_6',
      'drmemory_full_unit_2_of_6',
      'drmemory_full_unit_3_of_6',
      'drmemory_full_unit_4_of_6',
      'drmemory_full_unit_5_of_6',
      'drmemory_full_unit_6_of_6',
    ],
    factory_properties={'needs_drmemory': True},
)


f_chromium_rel_win_morenacl = win().ChromiumFactory(
    target='Release',
    slave_type='Tester',
    build_url=chromium_rel_archive,
    tests=['nacl_integration'],
    factory_properties={'process_dumps': True,
                        'start_crash_handler': True})

f_chromium_rel_mac_morenacl = mac().ChromiumFactory(
    target='Release',
    tests=['nacl_integration'],
    options=['--compiler=goma-clang'])

f_chromium_rel_linux_morenacl = linux().ChromiumFactory(
    target='Release',
    tests=['nacl_integration'])


f_cr_dbg_mac_106_tsan = mac().ChromiumFactory(
    target='Debug',
    tests=['tsan_base_unittests',
           'tsan_content',
           'tsan_crypto',
           'tsan_googleurl',
           'tsan_net',
           'tsan_ipc_tests',
           'tsan_media',
           'tsan_printing',
           'tsan_remoting',
           'tsan_sql',
           'tsan_sync',
           'tsan_ui_unittests',
           ],
    options=['--', '-project', '../build/all.xcodeproj',
             '-target', 'chromium_builder_dbg_tsan_mac'],
    factory_properties={
        'needs_valgrind': True,
        # Running out of address space on 10.5... try to buy some time.
        'gclient_env': {
            'GYP_DEFINES': 'build_for_tool=memcheck target_arch=ia32'}})

f_chromium_rel_linux_tsan_v2 = linux().ChromiumFactory(
    target='Release',
    slave_type='BuilderTester',
    options=[
      '--compiler=goma-clang',
      '--build-tool=ninja',
      '--llvm-tsan',
      'base_unittests',
      'browser_tests',
      'cacheinvalidation_unittests',
      'content_browsertests',
      'content_unittests',
      'crypto_unittests',
      'device_unittests',
      'gpu_unittests',
      'ipc_tests',
      'jingle_unittests',
      'media_unittests',
      'net_unittests',
      'ppapi_unittests',
      'printing_unittests',
      'remoting_unittests',
      'sandbox_linux_unittests',
      'sql_unittests',
      'sync_unit_tests',
      'ui_unittests',
      'unit_tests',
      'url_unittests',
    ],
    factory_properties={
        'tsan': True,
        'sharded_tests': sharded_tests,
        'gclient_env': {
            'GYP_DEFINES': ('tsan=1 '
                            'linux_use_tcmalloc=0 '
                            'release_extra_cflags="-gline-tables-only" '
                            'disable_nacl=1 '),
            'GYP_GENERATORS': 'ninja', }},
    tests=[
      'base_unittests',
      'browser_tests',
      'cacheinvalidation_unittests',
      'content_browsertests',
      'content_unittests',
      'crypto_unittests',
      'device_unittests',
      'googleurl',
      'gpu',
      'jingle',
      'net',
      'media',
      'ppapi_unittests',
      'printing',
      'remoting',
      'sandbox_linux_unittests',
      'unit_tests',
    ],
)

f_chromium_rel_linux_lsan_asan = linux().ChromiumFactory(
    target='Release',
    slave_type='BuilderTester',
    options=[
      '--compiler=goma-clang',
      '--build-tool=ninja',
      'base_unittests',
      'cacheinvalidation_unittests',
      'cc_unittests',
      'content_unittests',
      'crypto_unittests',
      'device_unittests',
      'gpu_unittests',
      'ipc_tests',
      'jingle_unittests',
      'media_unittests',
      'net_unittests',
      'ppapi_unittests',
      'printing_unittests',
      'remoting_unittests',
      'sandbox_linux_unittests',
      'sql_unittests',
      'sync_unit_tests',
      'ui_unittests',
      'unit_tests',
      'url_unittests',
    ],
    factory_properties={
        'asan': True,
        'cluster_size': 1,
        'gclient_env': {
            'GYP_DEFINES': ('asan=1 '
                            'lsan=1 '
                            'linux_use_tcmalloc=0 '
                            'release_extra_cflags="-gline-tables-only" '),
            'GYP_GENERATORS': 'ninja', },
        'lsan': True,
        'lsan_run_all_tests': True,
        'sharded_tests': sharded_tests,
    },
    tests=[
      'base_unittests',
      'cacheinvalidation_unittests',
      'crypto_unittests',
      'device_unittests',
      'gpu',
      'jingle',
      'net',
      'sandbox_linux_unittests',
      'googleurl',
      'media',
      'ppapi_unittests',
      'printing',
      'remoting',
      'unit',
      'cc_unittests',
    ],
)

# GYP_DEFINES for running coverage.  Why we do each:
# coverage=1: turn it on!  (e.g. add -ftest-coverage on Linux, enable
#   the 'coverage' target, etc)
# fastbuild=1, enable_svg=0: try and make it smaller so we don't choke on link.
# (Sadly those two don't make us small enough to link with the 10.5 SDK.)
GYP_DEFINES_FOR_COVERAGE_WIN = ('coverage=1 '
                                'enable_svg=0')
# fastbuild=1 prevents PDB generation on Windows and it's necessary for
# code coverage, so we only add it for the other plaforms.
GYP_DEFINES_FOR_COVERAGE_POSIX = '%s fastbuild=1' % GYP_DEFINES_FOR_COVERAGE_WIN

f_coverage_dbg_linux = linux().ChromiumFactory(
    target='Debug',<commit_msg>Change the FYI LSan bot to run browser tests.<commit_after># vim: ft=python:
# Copyright (c) 2012 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.

from buildbot.changes import svnpoller
from buildbot.scheduler import Dependent
from buildbot.scheduler import Nightly
from buildbot.scheduler import Periodic
from buildbot.scheduler import Scheduler
from buildbot.scheduler import Triggerable
from buildbot.status.mail import MailNotifier

# These modules come from scripts/master, which must be in the PYTHONPATH.
from master import build_utils
from master import chromium_notifier
from master import failures_notifier
from master import master_config
from master import master_utils
from master import slaves_list

from master.factory import annotator_factory
from master.factory import chromeos_factory
from master.factory import chromium_factory

# These modules come from scripts/common, which must be in the PYTHONPATH.
import config
import master_site_config

import master_win_asan_cfg

ActiveMaster = master_site_config.ChromiumFYI

CODESEARCH_NOTIFIER = True
DRMEMORY_NOTIFIER = True
STATUS_PUSH = False

# This is the dictionary that the buildmaster pays attention to. We also use
# a shorter alias to save typing.
c = BuildmasterConfig = {}
c['status'] = []

config.DatabaseSetup(c, require_dbconfig=ActiveMaster.is_production_host)

####### CHANGESOURCES

# the 'change_source' list tells the buildmaster how it should find out about
# source code changes. Any class which implements IChangeSource can be added
# to this list: there are several in buildbot/changes/*.py to choose from.
def ChromeTreeFileSplitter(path):
  """split_file for the 'src' project in the trunk."""

  # Exclude .DEPS.git from triggering builds on chrome.
  if path == 'src/.DEPS.git':
    return None

  # List of projects we are interested in. The project names must exactly
  # match paths in the Subversion repository, relative to the 'path' URL
  # argument. build_utils.SplitPath() will use them as branch names to
  # kick off the Schedulers for different projects.
  projects = ['src']
  return build_utils.SplitPath(projects, path)

# Rev link urls.
chromium_rev = 'http://src.chromium.org/viewvc/chrome?view=rev&revision=%s'

# Polls config.Master.trunk_url for changes
trunk_poller = svnpoller.SVNPoller(svnurl=config.Master.trunk_url,
                                   split_file=ChromeTreeFileSplitter,
                                   pollinterval=10,
                                   revlinktmpl=chromium_rev)

c['change_source'] = [trunk_poller]

# Number of machines to shard ash browser_tests over.
ASH_SHARDS = 2

####### SCHEDULERS

## configure the Schedulers

# Main scheduler for all changes in trunk.
s_chromium = Scheduler(
    name='chromium',
    branch='src',
    treeStableTimer=60,
    builderNames=['Chromium Linux Reliability (valgrind)',
                  'Chromium Linux Browser Builder (valgrind)',
                  'Chromium Linux Browser (valgrind) (1)',
                  'Chromium Linux Browser (valgrind) (2)',
                  'Chromium Linux Browser (valgrind) (3)',
                  'Chromium Linux Browser (valgrind) (4)',
                  'Chromium Builder',
                  'Chromium Linux Perf',
                  'Chromium Windows Perf',
                  'Chromium Mac Perf',
                  'Chromium Cros32 Perf',
                  'Chromium Cros64 Perf',
                  'Chromium Windows Instant Extended',
                  'Chromium Linux Buildrunner',
                  'Chromium Windows Buildrunner',
                  'Chromium Mac Buildrunner',
                  'Chromium Mac 10.8 Buildrunner',
                  'Chromium Builder (dbg)',
                  'Chromium Win Multiple',
                  'Chromium Win VS2012 (dbg)',
                  'Chromium Win VS2012',
                  'Chromium Win VS2012 Goma (dbg)',
                  'Chromium Win VS2012 Goma',
                  'Chromium Win Ninja Goma',
                  'Chromium Win Ninja Goma (shared)',
                  'Chromium Win x64 Clobber',
                  'Chromium Win7 Ninja Goma',
                  'Chromium Win7 Ninja Goma (shared)',
                  'Linux Tests (tsan RV)',
                  'Chromium Linux TSan v2',
                  'Chromium Linux LSan (and ASan)',
                  'Chromium Mac 10.6 (tsan)',
                  'Windows Tests (DrMemory XP)',
                  'Windows Unit (DrMemory full) (1)',
                  'Windows Unit (DrMemory full) (2)',
                  'Windows Browser (DrMemory full) (1)',
                  'Windows Browser (DrMemory full) (2)',
                  'Windows Browser (DrMemory full) (3)',
                  'Windows Browser (DrMemory full) (4)',
                  'Windows Builder (DrMemory)',
                  'Windows Tests (TSan Win 7)',
                  'Chromium Vista Memory',
                  'Chromium Linux Memory',
                  'Chromium Mac Memory',
                  'Chromium Linux Redux',
                  'Linux ARM Cross-Compile',
                  'Android Builder (dbg)',
                  'Android x86 Builder (dbg)',
                  'Android User Builder Tests',
                  'Android Asan Builder Tests (dbg)',
                  'Android Builder Tests (JB Nexus7)(shared)',
                  'Android AOSP Builder (dbg)',
                  'Chromium iOS Simulator (dbg)',
                  'Chromium iOS Device',
                  'More NaCl Tests (mac)',
                  'More NaCl Tests (linux)',
                  'Chromium Linux Goma Canary',
                  'Chromium Linux Precise Goma LinkTest',
                  'Chromium Linux32 Goma Canary',
                  'Chromium Mac 10.6 Goma Canary',
                  'Chromium Mac 10.7 Goma Canary',
                  'Chromium Mac 10.6 Ninja Goma Canary',
                  'Chromium Mac 10.7 Ninja Goma Canary',
                  'Chromium Mac 10.8 x64 (experimental)',
                  'Windows 8 App Certification',
                  'ChromiumOS Linux Tests',
                  ] + [
                      'Chromium Win Aura Ash (%d)' % shard
                       for shard in range(1, ASH_SHARDS+1)
                  ])

# Triggerable scheduler for Windows Release.
s_chromium_win_rel = Triggerable(
    name='win_rel',
    builderNames=['Chrome Frame Perf',
                  'Chrome Frame Tests (ie6)(peruser)',
                  'Chrome Frame Tests (ie7)(peruser)',
                  'Chrome Frame Tests (ie8)(peruser)',
                  'Chromium Win MiniInstaller Tests',
                  'More NaCl Tests (win32)',
                  'More NaCl Tests (win64)',
                  'Win8 Tests (1)',
                  'Win8 Tests (2)',
                  'Windows Tests (Memory benchmark)'])

# Triggerable scheduler for Windows Debug.
s_chromium_win_dbg = Triggerable(
    name='win_dbg',
    builderNames=['Vista Tests (dbg)(1)',
                  'Vista Tests (dbg)(2)',
                  'Chrome Frame Tests (ie8)(dbg)'])

# Triggerable scheduler for Android Builder
s_chromium_android_dbg = Triggerable(
    name='android_dbg',
    builderNames=['Android Tests (JB GalaxyNexus)(dbg)',
                  'Android Tests (ICS GalaxyNexus)(dbg)',
                  'Android Tests (JB Nexus7)(dbg)',
                  'Android Tests (JB Manta)(dbg)',
                  'Android ChromeDriver Tests (dbg)'])

s_chromium_linux_browser_valgrind_trigger = Triggerable(
    'chromium_linux_browser_valgrind',
    ['Chromium Linux Browser (valgrind) (1)',
     'Chromium Linux Browser (valgrind) (2)',
     'Chromium Linux Browser (valgrind) (3)',
     'Chromium Linux Browser (valgrind) (4)',
    ])

s_chromium_windows_drmemory_trigger = Triggerable(
    name='chromium_windows_drmemory',
    builderNames=[
     'Windows Unit (DrMemory full) (1)',
     'Windows Unit (DrMemory full) (2)',
     'Windows Browser (DrMemory full) (1)',
     'Windows Browser (DrMemory full) (2)',
     'Windows Browser (DrMemory full) (3)',
     'Windows Browser (DrMemory full) (4)',
    ])

# Triggerable scheduler for Codesearch.
s_chromium_codesearch = Triggerable(
    name='chromium_codesearch',
    builderNames=[
      'Chromium Linux Codesearch',
      'ChromiumOS Codesearch',
    ])


# Triggerable scheduler for Linux ARM
s_chromium_linux_arm = Triggerable(
    name='chromium_linux_arm',
    builderNames=[
        'Linux ARM Tests (Panda)'
    ])

# Triggerable scheduler for 10.8 x64 tests
s_chromium_mac_108_x64_experimental = Triggerable(
    name='chromium_mac_108_x64_experimental',
    builderNames=[
        'Chromium Mac 10.8 x64 tester (experimental)'
    ])

# Triggerable scheduler for Windows Coverage
s_chromium_win_coverage = Triggerable(
    name='chromium_win_coverage',
    builderNames=[
        'Win Coverage Tests (1)',
        'Win Coverage Tests (2)',
        'Win Coverage Tests (3)',
        'Win Coverage Tests (4)',
        'Win Coverage Tests (5)',
    ])

# 4-hourly scheduler.
#
# The Codesearch Scheduler bot will trigger the s_chromium_codesearch scheduler,
# so all codesearch bots will start on the same revision.
s_chromium_4hourly = Nightly(name='chromium_4hourly',
                             builderNames=[
                               'Chromium Codesearch Scheduler',
                             ],
                             branch='src',
                             hour=range(0, 24, 4),
                             minute=0)

# 4 times daily build of metro_driver and delegate_execute for Win8.
s_chromium_6hourly = Nightly(name='chromium_6hourly',
                             builderNames=['Win8 (delegate_execute)',
                                           'Win8 (metro_driver)'],
                             branch='src',
                             hour=range(0, 24, 6),
                             minute=0)

# Once an hour scheduler to provide a periodic poll of lkgr.  The
# coverage builds "run" once an hour but nop themselves if lkgr hasn't
# changed.
s_chromium_hourly = Periodic(name="hourly",
                             builderNames=['Linux Coverage (dbg)',
                                           'Win Coverage Processor'],
                             periodicBuildTimer=60*60)  # in seconds


c['schedulers'] = [s_chromium,
                   s_chromium_hourly,
                   s_chromium_4hourly,
                   s_chromium_6hourly,
                   s_chromium_android_dbg,
                   s_chromium_codesearch,
                   s_chromium_win_rel,
                   s_chromium_win_dbg,
                   s_chromium_linux_browser_valgrind_trigger,
                   s_chromium_windows_drmemory_trigger,
                   s_chromium_linux_arm,
                   s_chromium_mac_108_x64_experimental,
                   s_chromium_win_coverage,
                  ]

# Tests that are single-machine shard-safe.
sharded_tests = [
  'aura_unittests',
  'base_unittests',
  'browser_tests',
  'cacheinvalidation_unittests',
  'cc_unittests',
  'chromedriver2_tests',
  'chromedriver2_unittests',
  'components_unittests',
  'content_browsertests',
  'content_unittests',
  'crypto_unittests',
  'device_unittests',
  'gpu_unittests',
  'jingle_unittests',
  'media_unittests',
  'net_unittests',
  'ppapi_unittests',
  'printing_unittests',
  'remoting_unittests',
  'sync_integration_tests',
  'sync_unit_tests',
  'ui_unittests',
  'unit_tests',
  'views_unittests',
  'webkit_compositor_bindings_unittests',
]

####### BUILDERS

# buildbot/process/factory.py provides several BuildFactory classes you can
# start with, which implement build processes for common targets (GNU
# autoconf projects, CPAN perl modules, etc). The factory.BuildFactory is the
# base class, and is configured with a series of BuildSteps. When the build
# is run, the appropriate buildslave is told to execute each Step in turn.

# the first BuildStep is typically responsible for obtaining a copy of the
# sources. There are source-obtaining Steps in buildbot/process/step.py for
# CVS, SVN, and others.

builders = []

# ----------------------------------------------------------------------------
# FACTORIES

F = chromium_factory.ChromiumFactory
def win(): return F('src/chrome', 'win32')
def win_build(): return F('src/build', 'win32')
def win_out(): return F('src/out', 'win32')
def win_metro(): return F('src/metro_driver', 'win32')
def win_delegate(): return F('src/delegate_execute', 'win32')
def mac(): return F('src/xcodebuild', 'darwin')
def linux(**kwargs): return F('src/out', 'linux2', **kwargs)
def ios(): return F('src/xcodebuild', 'darwin')

def codesearch():
  return F('src/build', 'linux2', pull_internal=False, full_checkout=True,
           additional_svn_urls=[config.Master.trunk_url_tools])

def codesearch_scheduler():
  return F('src/build', 'linux2', pull_internal=False)

def chromeos():
  return F('src/build', 'linux2')

def linux_android(custom_deps_list=None):
  return F('src/build', 'linux2', nohooks_on_update=True, target_os='android',
           custom_deps_list=custom_deps_list)

chromium_rel_archive = master_config.GetArchiveUrl(
    'ChromiumFYI',
    'Chromium Builder',
    'chromium-rel-builder',
    'win32')

chromium_dbg_archive = master_config.GetArchiveUrl(
    'ChromiumFYI',
    'Chromium Builder (dbg)',
    'chromium-dbg-builder',
    'win32')

chromium_linux_browser_valgrind_archive = master_config.GetArchiveUrl(
    'ChromiumFYI',
    'Chromium Linux Browser Builder (valgrind)',
    'chromium-rel-linux-browser-valgrind-builder',
    'linux')

chromium_windows_drmemory_archive = master_config.GetArchiveUrl(
    'ChromiumFYI',
    'Windows Builder (DrMemory)',
    'drm-cr',
    'win32')

chromium_linux_arm_archive = master_config.GetGSBuildCacheUrl(
    ActiveMaster.project_name, 'Linux ARM Cross-Compile')

chromium_dbg_win_drmemory_archive_ext = ('http://vm832-m1/b/build/slave/'
                                         'chromium-dbg-win-drmemory-builder/'
                                         'chrome_staging/full-build-win32.zip')

chromium_rel_archive_ext = ('http://master.chromium.org:8802/b/build/slave'
                            '/chromium-rel-builder/chrome_staging/'
                            'full-build-win32.zip')

chromium_android_fyi_dbg_archive = master_config.GetGSUtilUrl(
    'chromium-android', 'android_fyi_dbg')

chromium_mac_108_x64_experimental_archive = master_config.GetGSUtilUrl(
    'chromium-qa', 'Chromium Mac 10.8 x64 (experimental)')

# The identifier of the factory is the build configuration. If two factories
# are using the same build configuration, they should have the same identifier.
f_chromium_rel_builder = win_build().ChromiumFactory(
    slave_type='Builder',
    project='all.sln;chromium_builder_tests',
    factory_properties={'trigger': 'win_rel',
                        'gclient_env': {'GYP_DEFINES': 'fastbuild=1'}})

f_chromium_dbg_builder = win_build().ChromiumFactory(
    slave_type='Builder',
    target='Debug',
    project='all.sln;chromium_builder_tests',
    factory_properties={'trigger': 'win_dbg',
                        'gclient_env': {'GYP_DEFINES': 'fastbuild=1'}})

f_linux_perf = linux().ChromiumFactory(target='Release',
    slave_type='Builder',
    options=['--compiler=goma', '--', 'chromium_builder_perf'],
    factory_properties={
      'show_perf_results': True,
      'expectations': True,
      'halt_on_missing_build': True,
      'perf_id': 'linux-release-fyi'},
    tests=['page_cycler_moz',
      'page_cycler_morejs',
      'page_cycler_intl_ar_fa_he',
      'page_cycler_intl_es_fr_pt-BR',
      'page_cycler_intl_hi_ru',
      'page_cycler_intl_ja_zh',
      'page_cycler_intl_ko_th_vi',
      'page_cycler_typical_25',
      'page_cycler_bloat',
      'page_cycler_dhtml',
      'page_cycler_indexeddb',
      'smoothness_top_25',
      'jsgamebench',
      'kraken',
      'robohornet_pro',
      'memory_top_25',
      'telemetry_perf_unittests',
      'telemetry_unittests'])

f_win_perf = win_build().ChromiumFactory(slave_type='Builder',
    project='all.sln;chromium_builder_perf',
    factory_properties={
      'show_perf_results': True,
      'expectations': True,
      'halt_on_missing_build': True,
      'perf_id': 'chromium-rel-win7-dual-fyi',
      'process_dumps': True,
      'start_crash_handler': True,},
    tests=['page_cycler_moz',
      'page_cycler_morejs',
      'page_cycler_intl_ar_fa_he',
      'page_cycler_intl_es_fr_pt-BR',
      'page_cycler_intl_hi_ru',
      'page_cycler_intl_ja_zh',
      'page_cycler_intl_ko_th_vi',
      'page_cycler_typical_25',
      'page_cycler_bloat',
      'page_cycler_dhtml',
      'page_cycler_indexeddb',
      'smoothness_top_25',
      'jsgamebench',
      'kraken',
      'robohornet_pro',
      'memory_top_25',
      'telemetry_perf_unittests',
      'telemetry_unittests'])

f_mac_perf = mac().ChromiumFactory(slave_type='Builder',
    options=['--compiler=goma-clang', '--', '-target', 'chromium_builder_perf'],
    factory_properties={
      'archive_build': False,
      'show_perf_results': True,
      'expectations': True,
      'halt_on_missing_build': True,
      'perf_id': 'chromium-rel-mac7-fyi', },
    tests=['page_cycler_moz',
      'page_cycler_morejs',
      'page_cycler_intl_ar_fa_he',
      'page_cycler_intl_es_fr_pt-BR',
      'page_cycler_intl_hi_ru',
      'page_cycler_intl_ja_zh',
      'page_cycler_intl_ko_th_vi',
      'page_cycler_typical_25',
      'page_cycler_bloat',
      'page_cycler_dhtml',
      'page_cycler_indexeddb',
      'smoothness_top_25',
      'jsgamebench',
      'kraken',
      'robohornet_pro',
      'memory_top_25',
      'telemetry_perf_unittests',
      'telemetry_unittests'])

f_cros32_perf = chromeos_factory.CbuildbotFactory(
  buildroot='/b/cbuild.cros32_perf',
  pass_revision=True,
  params='x86-generic-telemetry').get_factory()

f_cros64_perf = chromeos_factory.CbuildbotFactory(
  buildroot='/b/cbuild.cros64_perf',
  pass_revision=True,
  params='amd64-generic-telemetry').get_factory()

f_win_instantextended = win_build().ChromiumFactory(
           project='all.sln;chromium_builder_tests',
           tests=[
               'instant_extended_manual_tests',
               'buildrunner_tests',
           ],
           slave_type='BuilderTester',
           factory_properties={
               'gclient_env': {
                   'GYP_DEFINES': 'fastbuild=1',
               },
               'process_dumps': True,
               'start_crash_handler': True,
               'generate_gtest_json': True,
           })

f_linux_buildrunner = linux().ChromiumFactory(
           tests=['base_unittests_br',
                  'browser_tests_br',
                  'cacheinvalidation_br',
                  'content_browsertests_br',
                  'crypto_br',
                  'dbus_br',
                  'googleurl_br',
                  'gpu_br',
                  'jingle_br',
                  'media_br',
                  'net_br',
                  'ppapi_unittests_br',
                  'printing_br',
                  'remoting_br',
                  'unit_br',
                  'buildrunner_tests',
           ],
           options=['--compiler=goma'],
           slave_type='Builder',
           factory_properties={
               'archive_build': False,
               'generate_gtest_json': True,
               'gclient_env': {
                   'GYP_DEFINES': 'target_arch=x64 '
                   'tests_run=noop,component=shared_library'}
           })

f_win_buildrunner = win_build().ChromiumFactory(
           project='all.sln;chromium_builder_tests',
           tests=['base_unittests_br',
                  'browser_tests_br',
                  'cacheinvalidation_br',
                  'content_browsertests_br',
                  'courgette_br',
                  'crypto_br',
                  'googleurl_br',
                  'gpu_br',
                  'installer_br',
                  'jingle_br',
                  'media_br',
                  'ppapi_unittests_br',
                  'printing_br',
                  'remoting_br',
                  'sandbox_br',
                  'buildrunner_tests',
           ],
           slave_type='Builder',
           factory_properties={'gclient_env': {'GYP_DEFINES': 'fastbuild=1',
                                               'GYP_MSVS_VERSION': '2008'},
                               'process_dumps': True,
                               'start_crash_handler': True,
                               'generate_gtest_json': True,
                               'archive_build': False,
           })

f_mac_buildrunner = mac().ChromiumFactory(
           tests=['base_unittests_br',
                  'browser_tests_br',
                  'cacheinvalidation_br',
                  'content_browsertests_br',
                  'crypto_br',
                  'googleurl_br',
                  'gpu_br',
                  'jingle_br',
                  'media_br',
                  'message_center_unittests_br',
                  'ppapi_unittests_br',
                  'printing_br',
                  'remoting_br',
                  'buildrunner_tests',
           ],
           options=['--compiler=goma-clang', '--', '-target',
                    'chromium_builder_tests'],
           factory_properties={
               'archive_build': False,
               'generate_gtest_json': True
           })


def without(these, notthese):
  return [x for x in these if x not in notthese]

tests_win_1 = ['base_unittests',
               'cacheinvalidation_unittests',
               'components_unittests',
               'courgette_unittests',
               'crypto_unittests',
               'device_unittests',
               'google_apis_unittests',
               'googleurl',
               'gpu',
               'installer',
               'jingle',
               'media',
               'net',
               'ppapi_unittests',
               'printing',
               'remoting',
               'sandbox',
               'unit',]
tests_win_2 = ['browser_tests',
               'content_browsertests']

f_chromium_rel_multiple_builder_tests = win_build().ChromiumFactory(
    slave_type='BuilderTester',
    options=['--build-tool=ninja', '--', 'chromium_builder_tests'],
    factory_properties={
        'gclient_env': {
            'GYP_DEFINES': ('component=static_library '
                            'fastbuild=1 '
                            'chrome_multiple_dll=1'),
            'GYP_GENERATORS': 'ninja',
        }})

f_chromium_rel_delegate = win_delegate().ChromiumFactory(slave_type='Builder')
f_chromium_rel_metro = win_metro().ChromiumFactory(slave_type='Builder')

f_chromium_dbg_tests_1 = win_build().ChromiumFactory(
    slave_type='Tester',
    target='Debug',
    build_url=chromium_dbg_archive,
    tests=tests_win_1,
    factory_properties={'process_dumps': True,
                        'start_crash_handler': True})

f_chromium_dbg_tests_2 = win_build().ChromiumFactory(
    slave_type='Tester',
    target='Debug',
    build_url=chromium_dbg_archive,
    tests=tests_win_2,
    factory_properties={'process_dumps': True,
                        'start_crash_handler': True})

f_chromium_rel_tests_1 = win_build().ChromiumFactory(
    slave_type='Tester',
    build_url=chromium_rel_archive,
    tests=tests_win_1,
    factory_properties={'process_dumps': True,
                        'start_crash_handler': True})

f_chromium_rel_tests_2 = win_build().ChromiumFactory(
    slave_type='Tester',
    build_url=chromium_rel_archive,
    tests=tests_win_2,
    factory_properties={'process_dumps': True,
                        'start_crash_handler': True})

f_cr_win_rel_mini_installer = win_build().ChromiumFactory(
    slave_type='Tester',
    build_url=chromium_rel_archive,
    tests=['mini_installer'],
    factory_properties={'process_dumps': True,
                        'start_crash_handler': True,})

f_cr_rel_perf_frame = win_build().ChromiumFactory(
    slave_type='Tester',
    build_url=chromium_rel_archive_ext,
    tests=['chrome_frame_perftests'],
    factory_properties={'show_perf_results': True,
                        'expectations': True,
                        'perf_id': 'chromium-rel-frame',
                        'process_dumps': True,
                        'start_crash_handler': True,})

f_cr_rel_frame = win_build().ChromiumFactory(
    slave_type='Tester',
    build_url=chromium_rel_archive,
    tests=['chrome_frame'],
    factory_properties={'process_dumps': True,
                        'start_crash_handler': True,})

f_cr_dbg_frame = win_build().ChromiumFactory(
    target='Debug',
    slave_type='Tester',
    build_url=chromium_dbg_archive,
    tests=['chrome_frame'],
    factory_properties={'process_dumps': True,
                        'start_crash_handler': True,})

f_chromium_linux_redux = linux().ChromiumFactory(
    tests=[
      'base_unittests',
      'cacheinvalidation_unittests',
      'crypto_unittests',
      'device_unittests',
      'jingle',
      'net',
      'unit',
      'check_deps2git',
    ],
    options=['base_unittests',
             'cacheinvalidation_unittests',
             'content_unittests',
             'crypto_unittests',
             'device_unittests',
             'ipc_tests',
             'jingle_unittests',
             'media_unittests',
             'net_unittests',
             'ppapi_unittests',
             'printing_unittests',
             'remoting_unittests',
             'sql_unittests',
             'sync_unit_tests',
             'ui_unittests',
             'unit_tests',
             'url_unittests',
             ],
    factory_properties={
        'gclient_env': {
            'GYP_DEFINES': ('linux_fpic=1 '
                            'enable_touch_events=1 '
                            'disable_nacl=1 '
                            'linux_use_tcmalloc=0 '
                            'linux_breakpad=0 '
                            'remoting=0 '
                            'configuration_policy=0 '
                            'safe_browsing=0 '
                            'use_openssl=1')}})

# Windows Tests (DrMemory XP)
f_chromium_dbg_win_drmemory = win_out().ChromiumFactory(
    slave_type='Tester',
    target='Debug',
    build_url=chromium_dbg_win_drmemory_archive_ext,
    tests=[
      'drmemory_light_url',
      'drmemory_light_printing',
      'drmemory_light_media',
      'drmemory_light_sql',
      'drmemory_light_crypto',
      'drmemory_light_remoting',
      'drmemory_light_ipc_tests',
      'drmemory_light_base_unittests',
      'drmemory_light_net',
      # run tests in shards to decrease the number of reports per shard.
      'drmemory_light_unit_1_of_3',
      'drmemory_light_unit_2_of_3',
      'drmemory_light_unit_3_of_3',
    ],
    factory_properties={'needs_drmemory': True}
)

# Windows Unit (DrMemory full) (1)
f_chromium_dbg_win_drmemory_full_1 = win_out().ChromiumFactory(
    slave_type='Tester',
    target='Debug',
    build_url=chromium_windows_drmemory_archive,
    tests=[
      'drmemory_full_url',
      'drmemory_full_printing',
      'drmemory_full_media',
      'drmemory_full_sql',
      'drmemory_full_crypto',
      'drmemory_full_remoting',
      'drmemory_full_ipc_tests',
      'drmemory_full_base_unittests',
      'drmemory_full_net',
    ],
    factory_properties={'needs_drmemory': True},
)

# Windows Unit (DrMemory full) (2)
f_chromium_dbg_win_drmemory_full_2 = win_out().ChromiumFactory(
    slave_type='Tester',
    target='Debug',
    build_url=chromium_windows_drmemory_archive,
    tests=[
      # Full mode has a high memory overhead currently, so shard the tests
      # more.
      'drmemory_full_unit_1_of_6',
      'drmemory_full_unit_2_of_6',
      'drmemory_full_unit_3_of_6',
      'drmemory_full_unit_4_of_6',
      'drmemory_full_unit_5_of_6',
      'drmemory_full_unit_6_of_6',
    ],
    factory_properties={'needs_drmemory': True},
)


f_chromium_rel_win_morenacl = win().ChromiumFactory(
    target='Release',
    slave_type='Tester',
    build_url=chromium_rel_archive,
    tests=['nacl_integration'],
    factory_properties={'process_dumps': True,
                        'start_crash_handler': True})

f_chromium_rel_mac_morenacl = mac().ChromiumFactory(
    target='Release',
    tests=['nacl_integration'],
    options=['--compiler=goma-clang'])

f_chromium_rel_linux_morenacl = linux().ChromiumFactory(
    target='Release',
    tests=['nacl_integration'])


f_cr_dbg_mac_106_tsan = mac().ChromiumFactory(
    target='Debug',
    tests=['tsan_base_unittests',
           'tsan_content',
           'tsan_crypto',
           'tsan_googleurl',
           'tsan_net',
           'tsan_ipc_tests',
           'tsan_media',
           'tsan_printing',
           'tsan_remoting',
           'tsan_sql',
           'tsan_sync',
           'tsan_ui_unittests',
           ],
    options=['--', '-project', '../build/all.xcodeproj',
             '-target', 'chromium_builder_dbg_tsan_mac'],
    factory_properties={
        'needs_valgrind': True,
        # Running out of address space on 10.5... try to buy some time.
        'gclient_env': {
            'GYP_DEFINES': 'build_for_tool=memcheck target_arch=ia32'}})

f_chromium_rel_linux_tsan_v2 = linux().ChromiumFactory(
    target='Release',
    slave_type='BuilderTester',
    options=[
      '--compiler=goma-clang',
      '--build-tool=ninja',
      '--llvm-tsan',
      'base_unittests',
      'browser_tests',
      'cacheinvalidation_unittests',
      'content_browsertests',
      'content_unittests',
      'crypto_unittests',
      'device_unittests',
      'gpu_unittests',
      'ipc_tests',
      'jingle_unittests',
      'media_unittests',
      'net_unittests',
      'ppapi_unittests',
      'printing_unittests',
      'remoting_unittests',
      'sandbox_linux_unittests',
      'sql_unittests',
      'sync_unit_tests',
      'ui_unittests',
      'unit_tests',
      'url_unittests',
    ],
    factory_properties={
        'tsan': True,
        'sharded_tests': sharded_tests,
        'gclient_env': {
            'GYP_DEFINES': ('tsan=1 '
                            'linux_use_tcmalloc=0 '
                            'release_extra_cflags="-gline-tables-only" '
                            'disable_nacl=1 '),
            'GYP_GENERATORS': 'ninja', }},
    tests=[
      'base_unittests',
      'browser_tests',
      'cacheinvalidation_unittests',
      'content_browsertests',
      'content_unittests',
      'crypto_unittests',
      'device_unittests',
      'googleurl',
      'gpu',
      'jingle',
      'net',
      'media',
      'ppapi_unittests',
      'printing',
      'remoting',
      'sandbox_linux_unittests',
      'unit_tests',
    ],
)

f_chromium_rel_linux_lsan_asan = linux().ChromiumFactory(
    target='Release',
    slave_type='BuilderTester',
    options=[
      '--compiler=goma-clang',
      '--build-tool=ninja',
      'browser_tests',
      'content_browsertests',
    ],
    factory_properties={
        'asan': True,
        'cluster_size': 1,
        'gclient_env': {
            'GYP_DEFINES': ('asan=1 '
                            'lsan=1 '
                            'linux_use_tcmalloc=0 '
                            'release_extra_cflags="-gline-tables-only" '),
            'GYP_GENERATORS': 'ninja', },
        'lsan': True,
        'lsan_run_all_tests': True,
        'sharded_tests': sharded_tests,
    },
    tests=[
      'browser_tests',
      'content_browsertests',
    ],
)

# GYP_DEFINES for running coverage.  Why we do each:
# coverage=1: turn it on!  (e.g. add -ftest-coverage on Linux, enable
#   the 'coverage' target, etc)
# fastbuild=1, enable_svg=0: try and make it smaller so we don't choke on link.
# (Sadly those two don't make us small enough to link with the 10.5 SDK.)
GYP_DEFINES_FOR_COVERAGE_WIN = ('coverage=1 '
                                'enable_svg=0')
# fastbuild=1 prevents PDB generation on Windows and it's necessary for
# code coverage, so we only add it for the other plaforms.
GYP_DEFINES_FOR_COVERAGE_POSIX = '%s fastbuild=1' % GYP_DEFINES_FOR_COVERAGE_WIN

f_coverage_dbg_linux = linux().ChromiumFactory(
    target='Debug',
{'fraction_non_alphanumeric': 0.10802714434187198, 'fraction_numerical': 0.009567769150822279, 'mean_word_length': 2.267039496679483, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 26, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '115602', 'n_tokens_mistral': 21221, 'n_tokens_neox': 20109, 'n_words': 3814}