Pass lsan GYP variable to swarming's test_env so that we can disable the sandbox when it's set.
This copies the logic from tools/build/scripts/slave/runtest.py in swarming. I changed test_env.py so that it sets CHROME_DEVEL_SANDBOX to be an empty string, instead of unsetting it. The latter doesn't work as Chrome triggers checks in content/browser/browser_main_loop.cc. This is what runtest.py does. BUG=414808,336218 Review URL: https://codereview.chromium.org/605063004 Cr-Commit-Position: refs/heads/master@{#297330}
This commit is contained in:
build
chrome
content
ppapi/native_client/tools/browser_tester
testing
@ -118,6 +118,7 @@ def _GenerateDepsDirUsingIsolate(suite_name, isolate_file_path=None):
|
||||
'--config-variable', 'component', 'static_library',
|
||||
'--config-variable', 'fastbuild', '0',
|
||||
'--config-variable', 'icu_use_data_file_flag', '1',
|
||||
'--config-variable', 'lsan', '0',
|
||||
# TODO(maruel): This may not be always true.
|
||||
'--config-variable', 'target_arch', 'arm',
|
||||
'--config-variable', 'use_openssl', '0',
|
||||
|
@ -98,6 +98,7 @@
|
||||
'--config-variable',
|
||||
'internal_gles2_conform_tests=<(internal_gles2_conform_tests)',
|
||||
'--config-variable', 'icu_use_data_file_flag=<(icu_use_data_file_flag)',
|
||||
'--config-variable', 'lsan=<(lsan)',
|
||||
'--config-variable', 'libpeer_target_type=<(libpeer_target_type)',
|
||||
'--config-variable', 'use_openssl=<(use_openssl)',
|
||||
'--config-variable', 'target_arch=<(target_arch)',
|
||||
|
@ -13,6 +13,7 @@
|
||||
'<(PRODUCT_DIR)',
|
||||
'<(PRODUCT_DIR)/browser_tests<(EXECUTABLE_SUFFIX)',
|
||||
'--test-launcher-bot-mode',
|
||||
'--lsan=<(lsan)',
|
||||
],
|
||||
'isolate_dependency_tracked': [
|
||||
'../testing/xvfb.py',
|
||||
|
@ -10,6 +10,7 @@
|
||||
'<(PRODUCT_DIR)',
|
||||
'<(PRODUCT_DIR)/interactive_ui_tests<(EXECUTABLE_SUFFIX)',
|
||||
'--test-launcher-bot-mode',
|
||||
'--lsan=<(lsan)',
|
||||
],
|
||||
'isolate_dependency_tracked': [
|
||||
'../testing/xvfb.py',
|
||||
|
@ -40,6 +40,7 @@
|
||||
'<(PRODUCT_DIR)',
|
||||
'<(PRODUCT_DIR)/content_browsertests<(EXECUTABLE_SUFFIX)',
|
||||
'--test-launcher-bot-mode',
|
||||
'--lsan=<(lsan)',
|
||||
],
|
||||
'isolate_dependency_tracked': [
|
||||
'../testing/xvfb.py',
|
||||
|
@ -211,7 +211,7 @@ def RunTestsOnce(url, options):
|
||||
options.files.append(os.path.join(script_dir, 'browserdata', 'nacltest.js'))
|
||||
|
||||
# Setup the environment with the setuid sandbox path.
|
||||
test_env.enable_sandbox_if_required(os.environ)
|
||||
test_env.enable_sandbox_if_required(sys.argv, os.environ)
|
||||
|
||||
# Create server
|
||||
host = GetHostName()
|
||||
|
@ -17,13 +17,18 @@ CHROME_SANDBOX_ENV = 'CHROME_DEVEL_SANDBOX'
|
||||
CHROME_SANDBOX_PATH = '/opt/chromium/chrome_sandbox'
|
||||
|
||||
|
||||
def should_enable_sandbox(sandbox_path):
|
||||
def should_enable_sandbox(cmd, sandbox_path):
|
||||
"""Return a boolean indicating that the current slave is capable of using the
|
||||
sandbox and should enable it. This should return True iff the slave is a
|
||||
Linux host with the sandbox file present and configured correctly."""
|
||||
if not (sys.platform.startswith('linux') and
|
||||
os.path.exists(sandbox_path)):
|
||||
return False
|
||||
|
||||
# Copy the check in tools/build/scripts/slave/runtest.py.
|
||||
if '--lsan=1' in cmd:
|
||||
return False
|
||||
|
||||
sandbox_stat = os.stat(sandbox_path)
|
||||
if ((sandbox_stat.st_mode & stat.S_ISUID) and
|
||||
(sandbox_stat.st_mode & stat.S_IRUSR) and
|
||||
@ -33,23 +38,20 @@ def should_enable_sandbox(sandbox_path):
|
||||
return False
|
||||
|
||||
|
||||
def enable_sandbox_if_required(env, verbose=False):
|
||||
def enable_sandbox_if_required(cmd, env, verbose=False):
|
||||
"""Checks enables the sandbox if it is required, otherwise it disables it."""
|
||||
chrome_sandbox_path = env.get(CHROME_SANDBOX_ENV, CHROME_SANDBOX_PATH)
|
||||
|
||||
if should_enable_sandbox(chrome_sandbox_path):
|
||||
if should_enable_sandbox(cmd, chrome_sandbox_path):
|
||||
if verbose:
|
||||
print 'Enabling sandbox. Setting environment variable:'
|
||||
print ' %s="%s"' % (CHROME_SANDBOX_ENV, chrome_sandbox_path)
|
||||
env[CHROME_SANDBOX_ENV] = chrome_sandbox_path
|
||||
else:
|
||||
if verbose:
|
||||
print 'Sandbox not properly installed. Unsetting:'
|
||||
print ' %s' % CHROME_SANDBOX_ENV
|
||||
# The variable should be removed from the environment, making
|
||||
# the variable empty silently disables the sandbox.
|
||||
if env.get(CHROME_SANDBOX_ENV):
|
||||
env.pop(CHROME_SANDBOX_ENV)
|
||||
print 'Disabling sandbox. Setting environment variable:'
|
||||
print ' CHROME_DEVEL_SANDBOX=""'
|
||||
env['CHROME_DEVEL_SANDBOX'] = ''
|
||||
|
||||
|
||||
def fix_python_path(cmd):
|
||||
@ -74,7 +76,7 @@ def run_executable(cmd, env):
|
||||
# Used by base/base_paths_linux.cc as an override. Just make sure the default
|
||||
# logic is used.
|
||||
env.pop('CR_SOURCE_ROOT', None)
|
||||
enable_sandbox_if_required(env)
|
||||
enable_sandbox_if_required(cmd, env)
|
||||
# Ensure paths are correctly separated on windows.
|
||||
cmd[0] = cmd[0].replace('/', os.path.sep)
|
||||
cmd = fix_python_path(cmd)
|
||||
|
Reference in New Issue
Block a user