blob: 622a268aa97c7c3aa77266ebfd264d3f3c8022bf [file] [log] [blame]
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import ast, os, random
from autotest_lib.client.common_lib.cros import dev_server
from autotest_lib.server import frontend
from autotest_lib.server.cros.dynamic_suite import constants, tools
"""A wrapper around a dynamic suite control file to enable local testing.
usage: server/autoserv test_suites/ pulls in a suite control file from disk and injects all the
variables that are normally injected by the create_suite_job() RPC, without
which the suite cannot be successfully executed.
This file can be passed directly to autoserv and executed locally,
allowing for the testing of test suite control file changes without
staging them in the context of a build. It also means that one can
test code changes in the dynamic_suite infrastructure without being
forced to reimage the DUTs every time (by setting SKIP_IMAGE to
# __file__ is not defined when this is run by autoserv, so hard-code :-/
CONF_FILE = '/usr/local/autotest/test_suites/dev_harness_conf'
SUITE_CONTROL_FILE = 'test_suites/control.dummy'
config_dict = {}
new_globals = globals()
if os.path.exists(CONF_FILE):
with open(CONF_FILE, 'r') as config:
# Default values. Put a raw dict into CONF_FILE to override.
config_dict = {'build': 'x86-mario-release/R23-2814.0.0',
'board': 'x86-mario',
'check_hosts': True,
'pool': None,
'num': 2,
'file_bugs': False,
'SKIP_IMAGE': False}
ds = dev_server.ImageServer.resolve(new_globals['build'])
if new_globals['SKIP_IMAGE']:
AFE = frontend.AFE(debug=True)
repo_url = tools.package_url_pattern() % (ds.url(), new_globals['build'])
m = random.choice(AFE.get_hostnames(label='board:'+new_globals['board']))
label = AFE.get_labels(
AFE.set_host_attribute(constants.JOB_REPO_URL, repo_url, hostname=m)
new_globals['devserver_url'] = ds.url()
execfile(os.path.join(job.autodir, SUITE_CONTROL_FILE), new_globals, locals())