Switch WebRTC's MB to RBE-CAS.
This CL updates WebRTC's MB to support RBE-CAS with the "mb run" command. Bug: chromium:1166990, webrtc:12072 Change-Id: Id51fbe002714679f59ad46e0eee271358c8e119e Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/202029 Reviewed-by: Andrey Logvin <landrey@webrtc.org> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#33120}
This commit is contained in:
committed by
Commit Bot
parent
b853d72250
commit
989e6e7d22
@ -13,7 +13,9 @@ import ast
|
||||
import json
|
||||
import StringIO
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
import mb
|
||||
@ -32,6 +34,7 @@ class FakeMBW(mb.MetaBuildWrapper):
|
||||
self.platform = 'win32'
|
||||
self.executable = 'c:\\python\\python.exe'
|
||||
self.sep = '\\'
|
||||
self.cwd = 'c:\\fake_src\\out\\Default'
|
||||
else:
|
||||
self.src_dir = '/fake_src'
|
||||
self.default_config = '/fake_src/tools_webrtc/mb/mb_config.pyl'
|
||||
@ -39,8 +42,10 @@ class FakeMBW(mb.MetaBuildWrapper):
|
||||
self.executable = '/usr/bin/python'
|
||||
self.platform = 'linux2'
|
||||
self.sep = '/'
|
||||
self.cwd = '/fake_src/out/Default'
|
||||
|
||||
self.files = {}
|
||||
self.dirs = set()
|
||||
self.calls = []
|
||||
self.cmds = []
|
||||
self.cross_compile = None
|
||||
@ -52,21 +57,24 @@ class FakeMBW(mb.MetaBuildWrapper):
|
||||
return '$HOME/%s' % path
|
||||
|
||||
def Exists(self, path):
|
||||
return self.files.get(path) is not None
|
||||
abs_path = self._AbsPath(path)
|
||||
return (self.files.get(abs_path) is not None or abs_path in self.dirs)
|
||||
|
||||
def MaybeMakeDirectory(self, path):
|
||||
self.files[path] = True
|
||||
abpath = self._AbsPath(path)
|
||||
self.dirs.add(abpath)
|
||||
|
||||
def PathJoin(self, *comps):
|
||||
return self.sep.join(comps)
|
||||
|
||||
def ReadFile(self, path):
|
||||
return self.files[path]
|
||||
return self.files[self._AbsPath(path)]
|
||||
|
||||
def WriteFile(self, path, contents, force_verbose=False):
|
||||
if self.args.dryrun or self.args.verbose or force_verbose:
|
||||
self.Print('\nWriting """\\\n%s""" to %s.\n' % (contents, path))
|
||||
self.files[path] = contents
|
||||
abpath = self._AbsPath(path)
|
||||
self.files[abpath] = contents
|
||||
|
||||
def Call(self, cmd, env=None, buffer_output=True):
|
||||
self.calls.append(cmd)
|
||||
@ -83,18 +91,34 @@ class FakeMBW(mb.MetaBuildWrapper):
|
||||
else:
|
||||
self.out += sep.join(args) + end
|
||||
|
||||
def TempDir(self):
|
||||
tmp_dir = os.path.join(tempfile.gettempdir(), 'mb_test')
|
||||
self.dirs.add(tmp_dir)
|
||||
return tmp_dir
|
||||
|
||||
def TempFile(self, mode='w'):
|
||||
return FakeFile(self.files)
|
||||
|
||||
def RemoveFile(self, path):
|
||||
del self.files[path]
|
||||
abpath = self._AbsPath(path)
|
||||
self.files[abpath] = None
|
||||
|
||||
def RemoveDirectory(self, path):
|
||||
self.rmdirs.append(path)
|
||||
files_to_delete = [f for f in self.files if f.startswith(path)]
|
||||
abpath = self._AbsPath(path)
|
||||
self.rmdirs.append(abpath)
|
||||
files_to_delete = [f for f in self.files if f.startswith(abpath)]
|
||||
for f in files_to_delete:
|
||||
self.files[f] = None
|
||||
|
||||
def _AbsPath(self, path):
|
||||
if not ((self.platform == 'win32' and path.startswith('c:')) or
|
||||
(self.platform != 'win32' and path.startswith('/'))):
|
||||
path = self.PathJoin(self.cwd, path)
|
||||
if self.sep == '\\':
|
||||
return re.sub(r'\\+', r'\\', path)
|
||||
else:
|
||||
return re.sub('/+', '/', path)
|
||||
|
||||
|
||||
class FakeFile(object):
|
||||
def __init__(self, files):
|
||||
@ -176,13 +200,20 @@ class UnitTest(unittest.TestCase):
|
||||
mbw.files[path] = contents
|
||||
return mbw
|
||||
|
||||
def check(self, args, mbw=None, files=None, out=None, err=None, ret=None):
|
||||
def check(self, args, mbw=None, files=None, out=None, err=None, ret=None,
|
||||
env=None):
|
||||
if not mbw:
|
||||
mbw = self.fake_mbw(files)
|
||||
|
||||
actual_ret = mbw.Main(args)
|
||||
|
||||
self.assertEqual(actual_ret, ret)
|
||||
try:
|
||||
prev_env = os.environ.copy()
|
||||
os.environ = env if env else prev_env
|
||||
actual_ret = mbw.Main(args)
|
||||
finally:
|
||||
os.environ = prev_env
|
||||
self.assertEqual(
|
||||
actual_ret, ret,
|
||||
"ret: %s, out: %s, err: %s" % (actual_ret, mbw.out, mbw.err))
|
||||
if out is not None:
|
||||
self.assertEqual(mbw.out, out)
|
||||
if err is not None:
|
||||
@ -564,8 +595,8 @@ class UnitTest(unittest.TestCase):
|
||||
|
||||
def test_gen_windowed_test_launcher_win(self):
|
||||
files = {
|
||||
'/tmp/swarming_targets': 'unittests\n',
|
||||
'/fake_src/testing/buildbot/gn_isolate_map.pyl': (
|
||||
'c:\\fake_src\\out\\Default\\tmp\\swarming_targets': 'unittests\n',
|
||||
'c:\\fake_src\\testing\\buildbot\\gn_isolate_map.pyl': (
|
||||
"{'unittests': {"
|
||||
" 'label': '//somewhere:unittests',"
|
||||
" 'type': 'windowed_test_launcher',"
|
||||
@ -579,9 +610,10 @@ class UnitTest(unittest.TestCase):
|
||||
mbw = self.fake_mbw(files=files, win32=True)
|
||||
self.check(['gen',
|
||||
'-c', 'debug_goma',
|
||||
'--swarming-targets-file', '/tmp/swarming_targets',
|
||||
'--swarming-targets-file',
|
||||
'c:\\fake_src\\out\\Default\\tmp\\swarming_targets',
|
||||
'--isolate-map-file',
|
||||
'/fake_src/testing/buildbot/gn_isolate_map.pyl',
|
||||
'c:\\fake_src\\testing\\buildbot\\gn_isolate_map.pyl',
|
||||
'//out/Default'], mbw=mbw, ret=0)
|
||||
|
||||
isolate_file = mbw.files['c:\\fake_src\\out\\Default\\unittests.isolate']
|
||||
@ -750,23 +782,40 @@ class UnitTest(unittest.TestCase):
|
||||
|
||||
def test_run_swarmed(self):
|
||||
files = {
|
||||
'/fake_src/testing/buildbot/gn_isolate_map.pyl': (
|
||||
"{'base_unittests': {"
|
||||
" 'label': '//base:base_unittests',"
|
||||
" 'type': 'raw',"
|
||||
" 'args': [],"
|
||||
"}}\n"
|
||||
),
|
||||
'/fake_src/out/Default/base_unittests.runtime_deps': (
|
||||
"base_unittests\n"
|
||||
),
|
||||
'out/Default/base_unittests.archive.json': (
|
||||
"{\"base_unittests\":\"fake_hash\"}"),
|
||||
'/fake_src/testing/buildbot/gn_isolate_map.pyl':
|
||||
("{'base_unittests': {"
|
||||
" 'label': '//base:base_unittests',"
|
||||
" 'type': 'console_test_launcher',"
|
||||
"}}\n"),
|
||||
'/fake_src/out/Default/base_unittests.runtime_deps':
|
||||
("base_unittests\n"),
|
||||
'/fake_src/out/Default/base_unittests.archive.json':
|
||||
("{\"base_unittests\":\"fake_hash\"}"),
|
||||
'/fake_src/third_party/depot_tools/cipd_manifest.txt':
|
||||
("# vpython\n"
|
||||
"/some/vpython/pkg git_revision:deadbeef\n"),
|
||||
}
|
||||
task_json = json.dumps({'tasks': [{'task_id': '00000'}]})
|
||||
collect_json = json.dumps({'00000': {'results': {}}})
|
||||
|
||||
mbw = self.fake_mbw(files=files)
|
||||
mbw.files[mbw.PathJoin(mbw.TempDir(), 'task.json')] = task_json
|
||||
mbw.files[mbw.PathJoin(mbw.TempDir(), 'collect_output.json')] = collect_json
|
||||
original_impl = mbw.ToSrcRelPath
|
||||
|
||||
def to_src_rel_path_stub(path):
|
||||
if path.endswith('base_unittests.archive.json'):
|
||||
return 'base_unittests.archive.json'
|
||||
return original_impl(path)
|
||||
|
||||
mbw.ToSrcRelPath = to_src_rel_path_stub
|
||||
|
||||
self.check(['run', '-s', '-c', 'debug_goma', '//out/Default',
|
||||
'base_unittests'], mbw=mbw, ret=0)
|
||||
mbw = self.fake_mbw(files=files)
|
||||
mbw.files[mbw.PathJoin(mbw.TempDir(), 'task.json')] = task_json
|
||||
mbw.files[mbw.PathJoin(mbw.TempDir(), 'collect_output.json')] = collect_json
|
||||
mbw.ToSrcRelPath = to_src_rel_path_stub
|
||||
self.check(['run', '-s', '-c', 'debug_goma', '-d', 'os', 'Win7',
|
||||
'//out/Default', 'base_unittests'], mbw=mbw, ret=0)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user