Commit a55584f1 authored by dpranke's avatar dpranke Committed by Commit bot

Rework how isolates are generated in MB.

This patch changes how MB will generate the .isolate files
for a GN build:

First, we rename 'ninja_to_gn.pyl' to 'gn_isolate_map.pyl',
and change it from a straight compile_target -> gn_label map to
a map of compile_target -> { "label": gn_label, "type": string,
"args": optional list<string> }.

Valid values for "type" are
"windowed_test_launcher"
: the test is a gtest-based test that uses the
  'brave-new-test-launcher' from //base/test:test_support and
  needs to run under Xvfb if run on an X11-based platform
  (i.e., if use_x11=true in GN).
"console_test_launcher"
: the test is a gtest-based test that uses the
  'brave-new-test-launcher' from //base/test:test_support but does
  not need Xvfb.
"raw"
: the test is just an executable and may take an optional list
  of command-line arguments (specified in the 'args' key),
  but does not need any extra files or other special processing.
"unknown"
: (the default), which indicates that we don't know what the command
  line needs to be (this is a fatal error).

Second, we read the new file in, and build a lookup map of test
types to command lines. We will probably need to keep iterating
on the list of test types and command lines, and perhaps provide
some escape hatches so that we can handle the full variety of tests.

TBR=maruel@chromium.org
BUG=503942, 504079

Review URL: https://codereview.chromium.org/1239343003

Cr-Commit-Position: refs/heads/master@{#339804}
parent bbc76fef
This diff is collapsed.
...@@ -40,7 +40,6 @@ SKIP = { ...@@ -40,7 +40,6 @@ SKIP = {
# http://crbug.com/480053 # http://crbug.com/480053
'Linux GN', 'Linux GN',
'Linux GN (dbg)', 'Linux GN (dbg)',
'linux_chromium_gn_rel',
# Unmaintained builders on chromium.fyi # Unmaintained builders on chromium.fyi
'ClangToTMac', 'ClangToTMac',
...@@ -138,7 +137,7 @@ def process_file(mode, test_name, tests_location, filepath, ninja_targets, ...@@ -138,7 +137,7 @@ def process_file(mode, test_name, tests_location, filepath, ninja_targets,
for d in data['gtest_tests']: for d in data['gtest_tests']:
if (d['test'] not in ninja_targets and if (d['test'] not in ninja_targets and
d['test'] not in SKIP_NINJA_TO_GN_TARGETS): d['test'] not in SKIP_NINJA_TO_GN_TARGETS):
raise Error('%s: %s / %s is not listed in ninja_to_gn.pyl.' % raise Error('%s: %s / %s is not listed in gn_isolate_map.pyl.' %
(filename, builder, d['test'])) (filename, builder, d['test']))
elif d['test'] in ninja_targets: elif d['test'] in ninja_targets:
ninja_targets_seen.add(d['test']) ninja_targets_seen.add(d['test'])
...@@ -268,8 +267,9 @@ def main(): ...@@ -268,8 +267,9 @@ def main():
'count_run_local': 0, 'count_run_on_swarming': 0, 'local_configs': {} 'count_run_local': 0, 'count_run_on_swarming': 0, 'local_configs': {}
}) })
with open(os.path.join(THIS_DIR, "ninja_to_gn.pyl")) as fp: with open(os.path.join(THIS_DIR, "gn_isolate_map.pyl")) as fp:
ninja_targets = ast.literal_eval(fp.read()) gn_isolate_map = ast.literal_eval(fp.read())
ninja_targets = dict((k, v['label']) for k, v in gn_isolate_map.items())
try: try:
result = 0 result = 0
......
# Copyright 2015 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.
# ninja_to_gn - A mapping of Ninja build target names to GN labels for
# the tests run on the bots.
#
# This mapping is used by MB so that we can uniformly refer to test binaries
# by their Ninja target names in the recipes and not need to worry about how
# they are referred to in GN or GYP specifically (the GYP target name is pretty
# much always the same as the Ninja target name, since GYP target names are not
# hierarchical).
{
"base_unittests": "//base:base_unittests",
"accessibility_unittests": "//ui/accessibility:accessibility_unittests",
"angle_unittests": "//gpu:angle_unittests",
"app_list_unittests": "//ui/app_list:app_list_unittests",
"app_shell_unittests": "//extensions/shell:app_shell_unittests",
"ash_unittests": "//ash:ash_unittests",
"aura_unittests": "//ui/aura:aura_unittests",
"blink_heap_unittests": "//third_party/WebKit/public:blink_heap_unittests",
"blink_platform_unittests": "//third_party/WebKit/public:blink_platform_unittests",
"browser_tests": "//chrome/test:browser_tests",
"cacheinvalidation_unittests": "//third_party/cacheinvalidation:cacheinvalidation_unittests",
"cast_base_unittests": "//chromecast/base:cast_base_unittests",
"cast_crash_unittests": "//chromecast/crash:cast_crash_unittests",
"cast_media_unittests": "//chromecast/media:cast_media_unittests",
"cast_shell_unittests": "//chromecast/app:cast_shell_unittests",
"cast_unittests": "//media/cast:cast_unittests",
"cc_unittests": "//cc:cc_unittests",
"chromedriver_unittests": "//chrome/test/chromedriver:chromedriver_unittests",
"chrome_elf_unittests": "//chrome_elf:chrome_elf_unittests",
"chromeos_unittests": "//chromeos:chromeos_unittests",
"components_browsertests": "//components:components_browsertests",
"components_unittests": "//components:components_unittests",
"compositor_unittests": "//ui/compositor:compositor_unittests",
"content_browsertests": "//content/test:content_browsertests",
"content_unittests": "//content/test:content_unittests",
"courgette_unittests": "//courgette:courgette_unittests",
"crypto_unittests": "//crypto:crypto_unittests",
"dbus_unittests": "//dbus:dbus_unittests",
"device_unittests": "//device:device_unittests",
"display_unittests": "//ui/display:display_unittests",
"events_unittests": "//ui/events:events_unittests",
"extensions_browsertests": "//extensions:extensions_browsertests",
"extensions_unittests": "//extensions:extensions_unittests",
"gcm_unit_tests": "//google_apis/gcm:gcm_unit_tests",
"gfx_unittests": "//ui/gfx:gfx_unittests",
"gl_unittests": "//ui/gl:gl_unittests",
"gn_unittests": "//tools/gn:gn_unittests",
"google_apis_unittests": "//google_apis:google_apis_unittests",
"gpu_unittests": "//gpu:gpu_unittests",
"html_viewer_unittests": "//components/html_viewer:html_viewer_unittests",
"installer_util_unittests": "//chrome/installer/util:installer_util_unittests",
"interactive_ui_tests": "//chrome/test:interactive_ui_tests",
"ipc_mojo_unittests": "//ipc/mojo:ipc_mojo_unittests",
"ipc_tests": "//ipc:ipc_tests",
"jingle_unittests": "//jingle:jingle_unittests",
"keyboard_unittests": "//ui/keyboard:keyboard_unittests",
"media_unittests": "//media:media_unittests",
"midi_unittests": "//media:midi_unittests",
"mojo_common_unittests": "//mojo/common:mojo_common_unittests",
"mojo_public_application_unittests": "//third_party/mojo/src/mojo/edk/test:mojo_public_applicaiton_unittests",
"mojo_public_bindings_unittests": "//third_party/mojo/src/mojo/edk/test:mojo_public_bindings_unittests",
"mojo_public_environment_unittests": "//third_party/mojo/src/mojo/edk/test:mojo_public_environment_unittests",
"mojo_public_system_unittests": "//third_party/mojo/src/mojo/edk/test:mojo_public_system_unittests",
"mojo_public_utility_unittests": "//third_party/mojo/src/mojo/edk/test:mojo_public_utility_unittests",
"mojo_runner_unittests": "//mojo/runner:mojo_runner_unittests",
"mojo_shell_unittests": "//mojo/shell:mojo_shell_unittests",
"mojo_surfaces_lib_unittests": "//mojo/converters/surfaces/tests:mojo_surfaces_lib_unittests",
"mojo_system_unittests": "//third_party/mojo/src/mojo/edk/system:mojo_system_unittests",
"mojo_view_manager_lib_unittests": "//components/view_manager/public/cpp/tests:mojo_view_manager_lib_unittests",
"message_center_unittests": "//ui/message_center:message_center_unittests",
"nacl_loader_unittests": "//components/nacl:nacl_loader_unittests",
"net_unittests": "//net:net_unittests",
"ozone_unittests": "//ui/ozone:ozone_unittests",
"ppapi_unittests": "//ppapi:ppapi_unittests",
"printing_unittests": "//printing:printing_unittests",
"remoting_unittests": "//remoting:remoting_unittests",
"resource_provider_unittests": "//components/resource_provider:resource_provider_unittests",
"sandbox_linux_unittests": "//sandbox/linux:sandbox_linux_unittests",
"sandbox_mac_unittests": "//sandbox/mac:sandbox_mac_unittests",
"sbox_integration_tests": "//sandbox/win:sbox_integration_tests",
"sbox_unittests": "//sandbox/win:sbox_unittests",
"sbox_validation_tests": "//sandbox/win:sbox_validation_tests",
"setup_unittests": "//chrome/installer/setup:setup_unittests",
"skia_unittests": "//skia:skia_unittests",
"sql_unittests": "//sql:sql_unittests",
"sync_integration_tests": "//sync:sync_integration_tests",
"sync_unit_tests": "//sync:sync_unit_tests",
"ui_base_unittests": "//ui/base:ui_base_unittests",
"ui_chromeos_unittests": "//ui/chromeos:ui_chromeos_unittests",
"ui_touch_selection_unittests": "//ui/touch_selection:ui_touch_selection_unittests",
"unit_tests": "//chrome/test:unit_tests",
"url_unittests": "//url:url_unittests",
"view_manager_unittests": "//components/view_manager:view_manager_unittests",
"views_unittests": "//ui/views:views_unittests",
"webkit_unit_tests": "//third_party/WebKit/public:webkit_unit_tests",
"wm_unittests": "//ui/wm:wm_unittests",
"wtf_unittests": "//third_party/WebKit/public:wtf_unittests",
}
...@@ -336,14 +336,14 @@ class MetaBuildWrapper(object): ...@@ -336,14 +336,14 @@ class MetaBuildWrapper(object):
# the compile targets to the matching GN labels. # the compile targets to the matching GN labels.
contents = self.ReadFile(self.args.swarming_targets_file) contents = self.ReadFile(self.args.swarming_targets_file)
swarming_targets = contents.splitlines() swarming_targets = contents.splitlines()
ninja_targets_to_labels = ast.literal_eval(self.ReadFile(os.path.join( gn_isolate_map = ast.literal_eval(self.ReadFile(os.path.join(
self.chromium_src_dir, 'testing', 'buildbot', 'ninja_to_gn.pyl'))) self.chromium_src_dir, 'testing', 'buildbot', 'gn_isolate_map.pyl')))
gn_labels = [] gn_labels = []
for target in swarming_targets: for target in swarming_targets:
if not target in ninja_targets_to_labels: if not target in gn_isolate_map:
raise MBErr('test target "%s" not found in %s' % raise MBErr('test target "%s" not found in %s' %
(target, '//testing/buildbot/ninja_to_gn.pyl')) (target, '//testing/buildbot/gn_isolate_map.pyl'))
gn_labels.append(ninja_targets_to_labels[target]) gn_labels.append(gn_isolate_map[target]['label'])
gn_runtime_deps_path = self.ToAbsPath(path, 'runtime_deps') gn_runtime_deps_path = self.ToAbsPath(path, 'runtime_deps')
...@@ -363,7 +363,8 @@ class MetaBuildWrapper(object): ...@@ -363,7 +363,8 @@ class MetaBuildWrapper(object):
if not self.Exists(deps_path): if not self.Exists(deps_path):
raise MBErr('did not generate %s' % deps_path) raise MBErr('did not generate %s' % deps_path)
command, extra_files = self.GetIsolateCommand(target, vals) command, extra_files = self.GetIsolateCommand(target, vals,
gn_isolate_map)
runtime_deps = self.ReadFile(deps_path).splitlines() runtime_deps = self.ReadFile(deps_path).splitlines()
...@@ -448,15 +449,55 @@ class MetaBuildWrapper(object): ...@@ -448,15 +449,55 @@ class MetaBuildWrapper(object):
return ret return ret
def GetIsolateCommand(self, target, vals): def RunGNIsolate(self, vals):
extra_files = [] build_path = self.args.path[0]
inp = self.ReadInputJSON(['targets'])
if self.args.verbose:
self.Print()
self.Print('isolate input:')
self.PrintJSON(inp)
self.Print()
output_path = self.args.output_path[0]
# TODO(dpranke): We should probably pull this from for target in inp['targets']:
# the test list info in //testing/buildbot/*.json, runtime_deps_path = self.ToAbsPath(build_path, target + '.runtime_deps')
# and assert that the test has can_use_on_swarming_builders: True,
# but we hardcode it here for now.
test_type = {}.get(target, 'gtest_test')
if not self.Exists(runtime_deps_path):
self.WriteFailureAndRaise('"%s" does not exist' % runtime_deps_path,
output_path)
command, extra_files = self.GetIsolateCommand(target, vals, None)
runtime_deps = self.ReadFile(runtime_deps_path).splitlines()
isolate_path = self.ToAbsPath(build_path, target + '.isolate')
self.WriteFile(isolate_path,
pprint.pformat({
'variables': {
'command': command,
'files': sorted(runtime_deps + extra_files),
'read_only': 1,
}
}) + '\n')
self.WriteJSON(
{
'args': [
'--isolated',
self.ToSrcRelPath('%s/%s.isolated' % (build_path, target)),
'--isolate',
self.ToSrcRelPath('%s/%s.isolate' % (build_path, target)),
],
'dir': self.chromium_src_dir,
'version': 1,
},
isolate_path + 'd.gen.json',
)
return 0
def GetIsolateCommand(self, target, vals, gn_isolate_map):
# This needs to mirror the settings in //build/config/ui.gni: # This needs to mirror the settings in //build/config/ui.gni:
# use_x11 = is_linux && !use_ozone. # use_x11 = is_linux && !use_ozone.
# TODO(dpranke): Figure out how to keep this in sync better. # TODO(dpranke): Figure out how to keep this in sync better.
...@@ -470,41 +511,48 @@ class MetaBuildWrapper(object): ...@@ -470,41 +511,48 @@ class MetaBuildWrapper(object):
executable_suffix = '.exe' if sys.platform == 'win32' else '' executable_suffix = '.exe' if sys.platform == 'win32' else ''
if test_type == 'gtest_test': test_type = gn_isolate_map[target]['type']
extra_files.append('../../testing/test_env.py') cmdline = []
extra_files = []
if use_x11:
# TODO(dpranke): Figure out some way to figure out which
# test steps really need xvfb.
extra_files.append('xdisplaycheck')
extra_files.append('../../testing/xvfb.py')
cmdline = [ if use_x11 and test_type == 'windowed_test_launcher':
extra_files = [
'xdisplaycheck',
'../../testing/test_env.py',
'../../testing/xvfb.py', '../../testing/xvfb.py',
'.', ]
'./' + str(target), cmdline = [
'--brave-new-test-launcher', '../../testing/xvfb.py',
'--test-launcher-bot-mode', '.',
'--asan=%d' % asan, './' + str(target),
'--msan=%d' % msan, '--brave-new-test-launcher',
'--tsan=%d' % tsan, '--test-launcher-bot-mode',
] '--asan=%d' % asan,
else: '--msan=%d' % msan,
cmdline = [ '--tsan=%d' % tsan,
]
elif test_type in ('windowed_test_launcher', 'console_test_launcher'):
extra_files = [
'../../testing/test_env.py'
]
cmdline = [
'../../testing/test_env.py', '../../testing/test_env.py',
'.',
'./' + str(target) + executable_suffix, './' + str(target) + executable_suffix,
'--brave-new-test-launcher', '--brave-new-test-launcher',
'--test-launcher-bot-mode', '--test-launcher-bot-mode',
'--asan=%d' % asan, '--asan=%d' % asan,
'--msan=%d' % msan, '--msan=%d' % msan,
'--tsan=%d' % tsan, '--tsan=%d' % tsan,
] ]
else: elif test_type in ('raw'):
# TODO(dpranke): Handle script_tests and other types of swarmed tests. extra_files = []
self.WriteFailureAndRaise('unknown test type "%s" for %s' % cmdline = [
(test_type, target), output_path=None) './' + str(target) + executable_suffix,
] + gn_isolate_map[target].get('args')
else:
self.WriteFailureAndRaise('No command line for %s found (test type %s).'
% (target, test_type), output_path=None)
return cmdline, extra_files return cmdline, extra_files
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment