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))
This diff is collapsed.
# 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