Commit 53eb0059 authored by Takuto Ikuta's avatar Takuto Ikuta Committed by Commit Bot

infra: remove some unused scripts under scripts

runisolatedtest.py seems not used other than by src/infra/scripts/legacy/scripts/slave/runtest.py
https://cs.chromium.org/search/?q=runisolatedtest&sq=package:chromium&type=cs

runtest.py seems not used other than by src/infra/scripts/runtest_wrapper.py
https://cs.chromium.org/search/?q=legacy+scripts+slave+runtest&sq=package:chromium&type=cs

slave_utils.py seems not used other than by src/infra/scripts/legacy/scripts/slave/runtest.py
https://cs.chromium.org/search/?q=import.*slave_utils+f:%5Esrc&ssfr=1&sq=package:chromium&type=cs

xvfb.py seems not used other than by src/infra/scripts/legacy/scripts/slave/runtest.py
https://cs.chromium.org/search/?q=import.*xvfb+f:%5Esrc&sq=package:chromium&type=cs

runtest_wrapper.py seems not used
https://cs.chromium.org/search/?q=runtest_wrapper&ssfr=1&sq=package:chromium&type=cs

Bug: 984869
Change-Id: Ifc48db6f7eeeb0127bdfea2b335384c1d4f49312
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2050052
Auto-Submit: Takuto Ikuta <tikuta@chromium.org>
Reviewed-by: default avatarYoshisato Yanagisawa <yyanagisawa@google.com>
Commit-Queue: Takuto Ikuta <tikuta@chromium.org>
Cr-Commit-Position: refs/heads/master@{#740594}
parent 197d175a
#!/usr/bin/env 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.
"""A tool to run a chrome test executable directly, or in isolated mode.
TODO(maruel): This script technically needs to die and be replaced by running
all the tests always isolated even when not run on Swarming. This will take a
while.
"""
import logging
import optparse
import os
import subprocess
import sys
USAGE = ('%s [options] /full/path/to/test.exe -- [original test command]' %
os.path.basename(sys.argv[0]))
LINUX_ISOLATE_ENABLED_TESTS = set((
'base_unittests',
'browser_tests',
'interactive_ui_tests',
'net_unittests',
'unit_tests',
))
# TODO(maruel): Not enabled because of lack of XCode support and missing
# dependencies for more complex tests.
MAC_ISOLATE_ENABLED_TESTS = set()
WIN_ISOLATE_ENABLED_TESTS = set((
'base_unittests',
'browser_tests',
'interactive_ui_tests',
'net_unittests',
'unit_tests',
))
# http://crbug.com/260311
# They are missing files for an unknown reason.
BUG_260311 = set((
'browser_tests',
'interactive_ui_tests',
))
ISOLATE_ENABLED_BUILDERS = {
# CI linux
'Linux Tests': LINUX_ISOLATE_ENABLED_TESTS,
# CI mac
'Mac10.6 Tests (1)': MAC_ISOLATE_ENABLED_TESTS,
'Mac10.7 Tests (1)': MAC_ISOLATE_ENABLED_TESTS,
# CI win
'Vista Tests (1)': WIN_ISOLATE_ENABLED_TESTS - BUG_260311,
'Vista Tests (2)': WIN_ISOLATE_ENABLED_TESTS - BUG_260311,
'Vista Tests (3)': WIN_ISOLATE_ENABLED_TESTS - BUG_260311,
'Win7 Tests (1)': WIN_ISOLATE_ENABLED_TESTS,
'Win7 Tests (2)': WIN_ISOLATE_ENABLED_TESTS,
'Win7 Tests (3)': WIN_ISOLATE_ENABLED_TESTS,
'XP Tests (1)': WIN_ISOLATE_ENABLED_TESTS - BUG_260311,
'XP Tests (2)': WIN_ISOLATE_ENABLED_TESTS - BUG_260311,
'XP Tests (3)': WIN_ISOLATE_ENABLED_TESTS - BUG_260311,
# Try Server
'linux_rel': LINUX_ISOLATE_ENABLED_TESTS,
'mac_rel': MAC_ISOLATE_ENABLED_TESTS,
'win_rel': WIN_ISOLATE_ENABLED_TESTS,
}
def should_run_as_isolated(builder_name, test_name):
logging.info('should_run_as_isolated(%s, %s)' % (builder_name, test_name))
return test_name in ISOLATE_ENABLED_BUILDERS.get(builder_name, [])
def run_command(command):
"""Inspired from chromium_utils.py's RunCommand()."""
print '\n' + subprocess.list2cmdline(command)
sys.stdout.flush()
sys.stderr.flush()
return subprocess.call(command)
def run_test_isolated(isolate_script, test_exe, original_command):
"""Runs the test under isolate.py run.
It compensates for discrepancies between sharding_supervisor.py arguments and
run_test_cases.py arguments.
The isolated file must be alongside the test executable, with the same
name and the .isolated extension.
"""
isolated_file = os.path.splitext(test_exe)[0] + '.isolated'
if not os.path.exists(isolated_file):
logging.error('No isolate file %s', isolated_file)
return 1
isolate_command = [sys.executable, isolate_script,
'run', '--isolated', isolated_file,
# Print info log lines, so isolate.py prints the path to
# the binary it's about to run, http://crbug.com/311625
'-v']
# Start setting the test specific options.
isolate_command.append('--')
isolate_command.append('--no-cr')
original_command = original_command[:]
while original_command:
item = original_command.pop(0)
if item == '--total-slave':
isolate_command.extend(['--shards', original_command.pop(0)])
elif item == '--slave-index':
isolate_command.extend(['--index', original_command.pop(0)])
elif item.startswith(('--gtest_filter',
'--gtest_output',
'--test-launcher')):
isolate_command.append(item)
return run_command(isolate_command)
def main(argv):
option_parser = optparse.OptionParser(USAGE)
option_parser.add_option('--test_name', default='',
help='The name of the test')
option_parser.add_option('--builder_name', default='',
help='The name of the builder that created this'
'test')
option_parser.add_option('--checkout_dir',
help='Checkout directory, used to locate the '
'swarm_client scripts.')
option_parser.add_option('-f', '--force-isolated', action='store_true',
help='Force test to run isolated. By default only '
'white listed builders and tests are run isolated.')
option_parser.add_option('-v', '--verbose', action='count', default=0,
help='Use to increase log verbosity. Can be passed '
'in multiple times for more detailed logs.')
options, args = option_parser.parse_args(argv)
test_exe = args[0]
original_command = args[1:]
# Initialize logging.
level = [logging.ERROR, logging.INFO, logging.DEBUG][min(2, options.verbose)]
logging.basicConfig(level=level,
format='%(asctime)s %(filename)s:%(lineno)-3d'
' %(levelname)s %(message)s',
datefmt='%y%m%d %H:%M:%S')
if (options.force_isolated or
should_run_as_isolated(options.builder_name, options.test_name)):
logging.info('Running test in isolate mode')
# Search first in swarming_client
isolate_script = os.path.join(options.checkout_dir, 'src', 'tools',
'swarming_client', 'isolate.py')
return run_test_isolated(isolate_script, test_exe, original_command)
else:
logging.info('Running test normally')
return run_command(original_command)
if '__main__' == __name__:
sys.exit(main(None))
#!/usr/bin/env 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.
"""A tool used to run a Chrome test executable and process the output.
This script is used by the buildbot slaves. It must be run from the outer
build directory, e.g. chrome-release/build/.
For a list of command-line options, call this script with '--help'.
"""
import copy
import logging
import optparse
import os
import platform
import re
import subprocess
import sys
from common import chromium_utils
from slave import build_directory
from slave import slave_utils
from slave import xvfb
USAGE = '%s [options] test.exe [test args]' % os.path.basename(sys.argv[0])
CHROME_SANDBOX_PATH = '/opt/chromium/chrome_sandbox'
# The directory that this script is in.
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
def _LaunchDBus():
"""Launches DBus to work around a bug in GLib.
Works around a bug in GLib where it performs operations which aren't
async-signal-safe (in particular, memory allocations) between fork and exec
when it spawns subprocesses. This causes threads inside Chrome's browser and
utility processes to get stuck, and this harness to hang waiting for those
processes, which will never terminate. This doesn't happen on users'
machines, because they have an active desktop session and the
DBUS_SESSION_BUS_ADDRESS environment variable set, but it does happen on the
bots. See crbug.com/309093 for more details.
Returns:
True if it actually spawned DBus.
"""
import platform
if (platform.uname()[0].lower() == 'linux' and
'DBUS_SESSION_BUS_ADDRESS' not in os.environ):
try:
print 'DBUS_SESSION_BUS_ADDRESS env var not found, starting dbus-launch'
dbus_output = subprocess.check_output(['dbus-launch']).split('\n')
for line in dbus_output:
m = re.match(r'([^=]+)\=(.+)', line)
if m:
os.environ[m.group(1)] = m.group(2)
print ' setting %s to %s' % (m.group(1), m.group(2))
return True
except (subprocess.CalledProcessError, OSError) as e:
print 'Exception while running dbus_launch: %s' % e
return False
def _ShutdownDBus():
"""Manually kills the previously-launched DBus daemon.
It appears that passing --exit-with-session to dbus-launch in
_LaunchDBus(), above, doesn't cause the launched dbus-daemon to shut
down properly. Manually kill the sub-process using the PID it gave
us at launch time.
This function is called when the flag --spawn-dbus is given, and if
_LaunchDBus(), above, actually spawned the dbus-daemon.
"""
import signal
if 'DBUS_SESSION_BUS_PID' in os.environ:
dbus_pid = os.environ['DBUS_SESSION_BUS_PID']
try:
os.kill(int(dbus_pid), signal.SIGTERM)
print ' killed dbus-daemon with PID %s' % dbus_pid
except OSError as e:
print ' error killing dbus-daemon with PID %s: %s' % (dbus_pid, e)
# Try to clean up any stray DBUS_SESSION_BUS_ADDRESS environment
# variable too. Some of the bots seem to re-invoke runtest.py in a
# way that this variable sticks around from run to run.
if 'DBUS_SESSION_BUS_ADDRESS' in os.environ:
del os.environ['DBUS_SESSION_BUS_ADDRESS']
print ' cleared DBUS_SESSION_BUS_ADDRESS environment variable'
def _BuildTestBinaryCommand(_build_dir, test_exe_path, options):
"""Builds a command to run a test binary.
Args:
build_dir: Path to the tools/build directory.
test_exe_path: Path to test command binary.
options: Options passed for this invocation of runtest.py.
Returns:
A command, represented as a list of command parts.
"""
command = [
test_exe_path,
]
if options.annotate == 'gtest':
command.append('--test-launcher-bot-mode')
if options.total_shards and options.shard_index:
command.extend([
'--test-launcher-total-shards=%d' % options.total_shards,
'--test-launcher-shard-index=%d' % (options.shard_index - 1)])
return command
def _GenerateRunIsolatedCommand(build_dir, test_exe_path, options, command):
"""Converts the command to run through the run isolate script.
All commands are sent through the run isolated script, in case
they need to be run in isolate mode.
"""
run_isolated_test = os.path.join(BASE_DIR, 'runisolatedtest.py')
isolate_command = [
sys.executable, run_isolated_test,
'--test_name', options.test_type,
'--builder_name', options.build_properties.get('buildername', ''),
'--checkout_dir', os.path.dirname(os.path.dirname(build_dir)),
]
if options.factory_properties.get('force_isolated'):
isolate_command += ['--force-isolated']
isolate_command += [test_exe_path, '--'] + command
return isolate_command
def _GetSanitizerSymbolizeCommand(strip_path_prefix=None, json_file_name=None):
script_path = os.path.abspath(os.path.join('src', 'tools', 'valgrind',
'asan', 'asan_symbolize.py'))
command = [sys.executable, script_path]
if strip_path_prefix:
command.append(strip_path_prefix)
if json_file_name:
command.append('--test-summary-json-file=%s' % json_file_name)
return command
def _Main(options, args, extra_env):
"""Using the target build configuration, run the executable given in the
first non-option argument, passing any following arguments to that
executable.
Args:
options: Command-line options for this invocation of runtest.py.
args: Command and arguments for the test.
extra_env: A dictionary of extra environment variables to set.
Returns:
Exit status code.
"""
if len(args) < 1:
raise chromium_utils.MissingArgument('Usage: %s' % USAGE)
xvfb_path = os.path.join(os.path.dirname(sys.argv[0]), '..', '..',
'third_party', 'xvfb', platform.architecture()[0])
build_dir = os.path.normpath(os.path.abspath(options.build_dir))
bin_dir = os.path.join(build_dir, options.target)
test_exe = args[0]
if options.run_python_script:
test_exe_path = test_exe
else:
test_exe_path = os.path.join(bin_dir, test_exe)
if not os.path.exists(test_exe_path):
if options.factory_properties.get('succeed_on_missing_exe', False):
print '%s missing but succeed_on_missing_exe used, exiting' % (
test_exe_path)
return 0
raise chromium_utils.PathNotFound('Unable to find %s' % test_exe_path)
if sys.platform == 'linux2':
# Unset http_proxy and HTTPS_PROXY environment variables. When set, this
# causes some tests to hang. See http://crbug.com/139638 for more info.
if 'http_proxy' in os.environ:
del os.environ['http_proxy']
print 'Deleted http_proxy environment variable.'
if 'HTTPS_PROXY' in os.environ:
del os.environ['HTTPS_PROXY']
print 'Deleted HTTPS_PROXY environment variable.'
# Path to SUID sandbox binary. This must be installed on all bots.
extra_env['CHROME_DEVEL_SANDBOX'] = CHROME_SANDBOX_PATH
extra_env['LD_LIBRARY_PATH'] = ''
if options.enable_lsan:
# Use the debug version of libstdc++ under LSan. If we don't, there will
# be a lot of incomplete stack traces in the reports.
extra_env['LD_LIBRARY_PATH'] += '/usr/lib/x86_64-linux-gnu/debug:'
extra_env['LD_LIBRARY_PATH'] += '%s:%s/lib:%s/lib.target' % (
bin_dir, bin_dir, bin_dir)
if options.run_shell_script:
command = ['bash', test_exe_path]
elif options.run_python_script:
command = [sys.executable, test_exe]
else:
command = _BuildTestBinaryCommand(build_dir, test_exe_path, options)
command.extend(args[1:])
log_processor = None
try:
# TODO(dpranke): checking on test_exe is a temporary hack until we
# can change the buildbot master to pass --xvfb instead of --no-xvfb
# for these two steps. See
# https://code.google.com/p/chromium/issues/detail?id=179814
start_xvfb = (
sys.platform == 'linux2' and (
options.xvfb or
'layout_test_wrapper' in test_exe or
'devtools_perf_test_wrapper' in test_exe))
if start_xvfb:
xvfb.StartVirtualX(
None, bin_dir,
with_wm=(options.factory_properties.get('window_manager', 'True') ==
'True'))
if options.test_launcher_summary_output:
command.append('--test-launcher-summary-output=%s' %
options.test_launcher_summary_output)
command = _GenerateRunIsolatedCommand(build_dir, test_exe_path, options,
command)
env = os.environ.copy()
if extra_env:
print 'Additional test environment:'
for k, v in sorted(extra_env.items()):
print ' %s=%s' % (k, v)
env.update(extra_env or {})
# Trigger bot mode (test retries, redirection of stdio, possibly faster,
# etc.) - using an environment variable instead of command-line flags
# because some internal waterfalls run this for totally non-gtest code.
# TODO(phajdan.jr): Clean this up when internal waterfalls are fixed.
env.update({'CHROMIUM_TEST_LAUNCHER_BOT_MODE': '1'})
if options.use_symbolization_script:
symbolize_command = _GetSanitizerSymbolizeCommand(
strip_path_prefix=options.strip_path_prefix)
command_process = subprocess.Popen(
command, env=env, stdout=subprocess.PIPE)
symbolize_process = subprocess.Popen(
symbolize_command, env=env, stdin=command_process.stdout)
command_process.stdout.close()
command_process.wait()
symbolize_process.wait()
result = command_process.returncode
if result == 0:
result = symbolize_process.returncode
else:
result = subprocess.call(command, env=env)
finally:
if start_xvfb:
xvfb.StopVirtualX(None)
return result
def _ConfigureSanitizerTools(options, args, extra_env):
if (options.enable_asan or options.enable_tsan or
options.enable_msan or options.enable_lsan):
# Instruct GTK to use malloc while running ASan, TSan, MSan or LSan tests.
extra_env['G_SLICE'] = 'always-malloc'
extra_env['NSS_DISABLE_ARENA_FREE_LIST'] = '1'
extra_env['NSS_DISABLE_UNLOAD'] = '1'
symbolizer_path = os.path.abspath(os.path.join('src', 'third_party',
'llvm-build', 'Release+Asserts', 'bin', 'llvm-symbolizer'))
disable_sandbox_flag = '--no-sandbox'
if args and 'layout_test_wrapper' in args[0]:
disable_sandbox_flag = '--additional-drt-flag=%s' % disable_sandbox_flag
# Symbolization of sanitizer reports.
if sys.platform in ['win32', 'cygwin']:
# On Windows, the in-process symbolizer works even when sandboxed.
symbolization_options = []
elif options.enable_tsan or options.enable_lsan:
# TSan and LSan are not sandbox-compatible, so we can use online
# symbolization. In fact, they need symbolization to be able to apply
# suppressions.
symbolization_options = ['symbolize=1',
'external_symbolizer_path=%s' % symbolizer_path,
'strip_path_prefix=%s' % options.strip_path_prefix]
elif options.enable_asan or options.enable_msan:
# ASan and MSan use a script for offline symbolization.
# Important note: when running ASan or MSan with leak detection enabled,
# we must use the LSan symbolization options above.
symbolization_options = ['symbolize=0']
# Set the path to llvm-symbolizer to be used by asan_symbolize.py
extra_env['LLVM_SYMBOLIZER_PATH'] = symbolizer_path
options.use_symbolization_script = True
def AddToExistingEnv(env_dict, key, options_list):
# Adds a key to the supplied environment dictionary but appends it to
# existing environment variables if it already contains values.
assert type(env_dict) is dict
assert type(options_list) is list
env_dict[key] = ' '.join(filter(bool, [os.environ.get(key)]+options_list))
# ThreadSanitizer
if options.enable_tsan:
tsan_options = symbolization_options
AddToExistingEnv(extra_env, 'TSAN_OPTIONS', tsan_options)
# Disable sandboxing under TSan for now. http://crbug.com/223602.
args.append(disable_sandbox_flag)
# LeakSanitizer
if options.enable_lsan:
# Symbolization options set here take effect only for standalone LSan.
lsan_options = symbolization_options
AddToExistingEnv(extra_env, 'LSAN_OPTIONS', lsan_options)
# Disable sandboxing under LSan.
args.append(disable_sandbox_flag)
# AddressSanitizer
if options.enable_asan:
asan_options = symbolization_options
if options.enable_lsan:
asan_options += ['detect_leaks=1']
AddToExistingEnv(extra_env, 'ASAN_OPTIONS', asan_options)
# MemorySanitizer
if options.enable_msan:
msan_options = symbolization_options
if options.enable_lsan:
msan_options += ['detect_leaks=1']
AddToExistingEnv(extra_env, 'MSAN_OPTIONS', msan_options)
def main():
"""Entry point for runtest.py.
This function:
(1) Sets up the command-line options.
(2) Sets environment variables based on those options.
(3) Delegates to the platform-specific main functions.
Returns:
Exit code for this script.
"""
option_parser = optparse.OptionParser(usage=USAGE)
# Since the trailing program to run may have has command-line args of its
# own, we need to stop parsing when we reach the first positional argument.
option_parser.disable_interspersed_args()
option_parser.add_option('--target', default='Release',
help='build target (Debug or Release)')
option_parser.add_option('--pass-target', action='store_true', default=False,
help='pass --target to the spawned test script')
option_parser.add_option('--build-dir', help='ignored')
option_parser.add_option('--pass-build-dir', action='store_true',
default=False,
help='pass --build-dir to the spawned test script')
option_parser.add_option('--test-platform',
help='Platform to test on, e.g. ios-simulator')
option_parser.add_option('--total-shards', dest='total_shards',
default=None, type='int',
help='Number of shards to split this test into.')
option_parser.add_option('--shard-index', dest='shard_index',
default=None, type='int',
help='Shard to run. Must be between 1 and '
'total-shards.')
option_parser.add_option('--run-shell-script', action='store_true',
default=False,
help='treat first argument as the shell script'
'to run.')
option_parser.add_option('--run-python-script', action='store_true',
default=False,
help='treat first argument as a python script'
'to run.')
option_parser.add_option('--generate-json-file', action='store_true',
default=False,
help='output JSON results file if specified.')
option_parser.add_option('--xvfb', action='store_true', dest='xvfb',
default=True,
help='Start virtual X server on Linux.')
option_parser.add_option('--no-xvfb', action='store_false', dest='xvfb',
help='Do not start virtual X server on Linux.')
option_parser.add_option('-o', '--results-directory', default='',
help='output results directory for JSON file.')
option_parser.add_option('--chartjson-file', default='',
help='File to dump chartjson results.')
option_parser.add_option('--log-processor-output-file', default='',
help='File to dump gtest log processor results.')
option_parser.add_option('--builder-name', default=None,
help='The name of the builder running this script.')
option_parser.add_option('--slave-name', default=None,
help='The name of the slave running this script.')
option_parser.add_option('--master-class-name', default=None,
help='The class name of the buildbot master running '
'this script: examples include "Chromium", '
'"ChromiumWebkit", and "ChromiumGPU". The '
'flakiness dashboard uses this value to '
'categorize results. See buildershandler.py '
'in the flakiness dashboard code '
'(use codesearch) for the known values. '
'Defaults to fetching it from '
'slaves.cfg/builders.pyl.')
option_parser.add_option('--build-number', default=None,
help=('The build number of the builder running'
'this script.'))
option_parser.add_option('--step-name', default=None,
help=('The name of the step running this script.'))
option_parser.add_option('--test-type', default='',
help='The test name that identifies the test, '
'e.g. \'unit-tests\'')
option_parser.add_option('--test-results-server', default='',
help='The test results server to upload the '
'results.')
option_parser.add_option('--annotate', default='',
help='Annotate output when run as a buildstep. '
'Specify which type of test to parse, available'
' types listed with --annotate=list.')
option_parser.add_option('--parse-input', default='',
help='When combined with --annotate, reads test '
'from a file instead of executing a test '
'binary. Use - for stdin.')
option_parser.add_option('--parse-result', default=0,
help='Sets the return value of the simulated '
'executable under test. Only has meaning when '
'--parse-input is used.')
option_parser.add_option('--results-url', default='',
help='The URI of the perf dashboard to upload '
'results to.')
option_parser.add_option('--perf-dashboard-id', default='',
help='The ID on the perf dashboard to add results '
'to.')
option_parser.add_option('--perf-id', default='',
help='The perf builder id')
option_parser.add_option('--perf-config', default='',
help='Perf configuration dictionary (as a string). '
'This allows to specify custom revisions to be '
'the main revision at the Perf dashboard. '
'Example: --perf-config="{\'a_default_rev\': '
'\'r_webrtc_rev\'}"')
option_parser.add_option('--supplemental-columns-file',
default='supplemental_columns',
help='A file containing a JSON blob with a dict '
'that will be uploaded to the results '
'dashboard as supplemental columns.')
option_parser.add_option('--revision',
help='The revision number which will be is used as '
'primary key by the dashboard. If omitted it '
'is automatically extracted from the checkout.')
option_parser.add_option('--webkit-revision',
help='See --revision.')
option_parser.add_option('--enable-asan', action='store_true', default=False,
help='Enable fast memory error detection '
'(AddressSanitizer).')
option_parser.add_option('--enable-lsan', action='store_true', default=False,
help='Enable memory leak detection (LeakSanitizer).')
option_parser.add_option('--enable-msan', action='store_true', default=False,
help='Enable uninitialized memory reads detection '
'(MemorySanitizer).')
option_parser.add_option('--enable-tsan', action='store_true', default=False,
help='Enable data race detection '
'(ThreadSanitizer).')
option_parser.add_option('--strip-path-prefix',
default='build/src/out/Release/../../',
help='Source paths in stack traces will be stripped '
'of prefixes ending with this substring. This '
'option is used by sanitizer tools.')
option_parser.add_option('--test-launcher-summary-output',
help='Path to test results file with all the info '
'from the test launcher')
option_parser.add_option('--flakiness-dashboard-server',
help='The flakiness dashboard server to which the '
'results should be uploaded.')
option_parser.add_option('--verbose', action='store_true', default=False,
help='Prints more information.')
chromium_utils.AddPropertiesOptions(option_parser)
options, args = option_parser.parse_args()
# Initialize logging.
log_level = logging.INFO
if options.verbose:
log_level = logging.DEBUG
logging.basicConfig(level=log_level,
format='%(asctime)s %(filename)s:%(lineno)-3d'
' %(levelname)s %(message)s',
datefmt='%y%m%d %H:%M:%S')
logging.basicConfig(level=logging.DEBUG)
logging.getLogger().addHandler(logging.StreamHandler(stream=sys.stdout))
options.test_type = options.test_type or options.factory_properties.get(
'step_name', '')
if options.run_shell_script and options.run_python_script:
sys.stderr.write('Use either --run-shell-script OR --run-python-script, '
'not both.')
return 1
print '[Running on builder: "%s"]' % options.builder_name
did_launch_dbus = _LaunchDBus()
try:
options.build_dir = build_directory.GetBuildOutputDirectory()
if options.pass_target and options.target:
args.extend(['--target', options.target])
if options.pass_build_dir:
args.extend(['--build-dir', options.build_dir])
# We will use this to accumulate overrides for the command under test,
# That we may not need or want for other support commands.
extra_env = {}
# This option is used by sanitizer code. There is no corresponding command
# line flag.
options.use_symbolization_script = False
# Set up extra environment and args for sanitizer tools.
_ConfigureSanitizerTools(options, args, extra_env)
# Set the number of shards environment variables.
# NOTE: Chromium's test launcher will ignore these in favor of the command
# line flags passed in _BuildTestBinaryCommand.
if options.total_shards and options.shard_index:
extra_env['GTEST_TOTAL_SHARDS'] = str(options.total_shards)
extra_env['GTEST_SHARD_INDEX'] = str(options.shard_index - 1)
return _Main(options, args, extra_env)
finally:
if did_launch_dbus:
# It looks like the command line argument --exit-with-session
# isn't working to clean up the spawned dbus-daemon. Kill it
# manually.
_ShutdownDBus()
if '__main__' == __name__:
sys.exit(main())
# 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.
"""Functions specific to build slaves, shared by several buildbot scripts.
"""
import datetime
import glob
import os
import re
import shutil
import subprocess
import sys
import tempfile
import time
from common import chromium_utils
# These codes used to distinguish true errors from script warnings.
ERROR_EXIT_CODE = 1
WARNING_EXIT_CODE = 88
def WriteLogLines(logname, lines, perf=None):
logname = logname.rstrip()
lines = [line.rstrip() for line in lines]
for line in lines:
print '@@@STEP_LOG_LINE@%s@%s@@@' % (logname, line)
if perf:
perf = perf.rstrip()
print '@@@STEP_LOG_END_PERF@%s@%s@@@' % (logname, perf)
else:
print '@@@STEP_LOG_END@%s@@@' % logname
# 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.
"""Functions to setup xvfb, which is used by the linux machines.
"""
import os
import platform
import signal
import subprocess
import tempfile
import time
def _XvfbDisplayIndex(slave_build_name):
return '9'
def _XvfbPidFilename(slave_build_name):
"""Returns the filename to the Xvfb pid file. This name is unique for each
builder. This is used by the linux builders."""
return os.path.join(tempfile.gettempdir(),
'xvfb-' + _XvfbDisplayIndex(slave_build_name) + '.pid')
def StartVirtualX(slave_build_name, build_dir, with_wm=True, server_dir=None):
"""Start a virtual X server and set the DISPLAY environment variable so sub
processes will use the virtual X server. Also start openbox. This only works
on Linux and assumes that xvfb and openbox are installed.
Args:
slave_build_name: The name of the build that we use for the pid file.
E.g., webkit-rel-linux.
build_dir: The directory where binaries are produced. If this is non-empty,
we try running xdisplaycheck from |build_dir| to verify our X
connection.
with_wm: Whether we add a window manager to the display too.
server_dir: Directory to search for the server executable.
"""
# We use a pid file to make sure we don't have any xvfb processes running
# from a previous test run.
StopVirtualX(slave_build_name)
xdisplaycheck_path = None
if build_dir:
xdisplaycheck_path = os.path.join(build_dir, 'xdisplaycheck')
display = ':%s' % _XvfbDisplayIndex(slave_build_name)
# Note we don't add the optional screen here (+ '.0')
os.environ['DISPLAY'] = display
if xdisplaycheck_path and os.path.exists(xdisplaycheck_path):
print 'Verifying Xvfb is not running ...'
checkstarttime = time.time()
xdisplayproc = subprocess.Popen([xdisplaycheck_path, '--noserver'],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
# Wait for xdisplaycheck to exit.
logs = xdisplayproc.communicate()[0]
if xdisplayproc.returncode == 0:
print 'xdisplaycheck says there is a display still running, exiting...'
raise Exception('Display already present.')
xvfb_lock_filename = '/tmp/.X%s-lock' % _XvfbDisplayIndex(slave_build_name)
if os.path.exists(xvfb_lock_filename):
print 'Removing stale xvfb lock file %r' % xvfb_lock_filename
try:
os.unlink(xvfb_lock_filename)
except OSError as e:
print 'Removing xvfb lock file failed: %s' % e
# Figure out which X server to try.
cmd = 'Xvfb'
if server_dir and os.path.exists(server_dir):
cmd = os.path.join(server_dir, 'Xvfb.' + platform.architecture()[0])
if not os.path.exists(cmd):
cmd = os.path.join(server_dir, 'Xvfb')
if not os.path.exists(cmd):
print 'No Xvfb found in designated server path:', server_dir
raise Exception('No virtual server')
# Start a virtual X server that we run the tests in. This makes it so we can
# run the tests even if we didn't start the tests from an X session.
proc = subprocess.Popen([cmd, display, '-screen', '0', '1024x768x24', '-ac',
'-dpi', '96'],
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
xvfb_pid_filename = _XvfbPidFilename(slave_build_name)
open(xvfb_pid_filename, 'w').write(str(proc.pid))
# Verify that Xvfb has started by using xdisplaycheck.
if xdisplaycheck_path and os.path.exists(xdisplaycheck_path):
print 'Verifying Xvfb has started...'
checkstarttime = time.time()
xdisplayproc = subprocess.Popen([xdisplaycheck_path],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
# Wait for xdisplaycheck to exit.
logs = xdisplayproc.communicate()[0]
checktime = time.time() - checkstarttime
if xdisplayproc.returncode != 0:
print 'xdisplaycheck failed after %d seconds.' % checktime
print 'xdisplaycheck output:'
for l in logs.splitlines():
print '> %s' % l
rc = proc.poll()
if rc is None:
print 'Xvfb still running, stopping.'
proc.terminate()
else:
print 'Xvfb exited, code %d' % rc
print 'Xvfb output:'
for l in proc.communicate()[0].splitlines():
print '> %s' % l
raise Exception(logs)
else:
print 'xdisplaycheck succeeded after %d seconds.' % checktime
print 'xdisplaycheck output:'
for l in logs.splitlines():
print '> %s' % l
print '...OK'
if with_wm:
# Some ChromeOS tests need a window manager.
subprocess.Popen('openbox', stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
print 'Window manager (openbox) started.'
else:
print 'No window manager required.'
def StopVirtualX(slave_build_name):
"""Try and stop the virtual X server if one was started with StartVirtualX.
When the X server dies, it takes down the window manager with it.
If a virtual x server is not running, this method does nothing."""
xvfb_pid_filename = _XvfbPidFilename(slave_build_name)
if os.path.exists(xvfb_pid_filename):
xvfb_pid = int(open(xvfb_pid_filename).read())
print 'Stopping Xvfb with pid %d ...' % xvfb_pid
# If the process doesn't exist, we raise an exception that we can ignore.
try:
os.kill(xvfb_pid, signal.SIGKILL)
except OSError:
print '... killing failed, presuming unnecessary.'
os.remove(xvfb_pid_filename)
print 'Xvfb pid file removed'
#!/usr/bin/env python
# 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.
"""Wrapper for runtest.py, makes it possible to control src-side
which file gets used and test the changes on trybots before landing."""
import argparse
import copy
import os
import subprocess
import sys
SRC_DIR = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
def main(argv):
parser = argparse.ArgumentParser()
parser.add_argument('args', nargs='*', help='Arguments to pass to runtest.py')
args = parser.parse_args(argv)
env = copy.copy(os.environ)
# Reset PYTHONPATH to make sure we're not accidentally using
# the buildbot-provided value and build-side modules. That would make
# changes inside this directory not take effect on buildbot.
pythonpath = []
pythonpath.append(os.path.join(
SRC_DIR, 'infra', 'scripts', 'legacy', 'scripts'))
pythonpath.append(os.path.join(
SRC_DIR, 'infra', 'scripts', 'legacy', 'site_config'))
pythonpath.append(os.path.join(
SRC_DIR, 'third_party'))
env['PYTHONPATH'] = os.pathsep.join(pythonpath)
return subprocess.call([
sys.executable,
os.path.join(SRC_DIR, 'infra', 'scripts', 'legacy',
'scripts', 'slave', 'runtest.py')
] + args.args, env=env)
if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))
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