提交 a0fc4fc5 编写于 作者: C Cleber Rosa

Avocado compatibility: rename args and options to config

To be consistent with the names on latest Avocado plugin interfaces
and configuration data (which is now a dictionary, and no longer the
result of command line arguments and an argparse.Namespace instance).
Signed-off-by: NCleber Rosa <crosa@redhat.com>
上级 51c65596
......@@ -36,20 +36,20 @@ from .test import VirtTest
LOG = logging.getLogger("avocado.app")
def guest_listing(options):
def guest_listing(config):
"""
List available guest operating systems and info about image availability
"""
if get_opt(options, 'vt_type') == 'lvsb':
if get_opt(config, 'vt_type') == 'lvsb':
raise ValueError("No guest types available for lvsb testing")
LOG.debug("Using %s for guest images\n",
os.path.join(data_dir.get_data_dir(), 'images'))
LOG.info("Available guests in config:")
guest_name_parser = standalone_test.get_guest_name_parser(options)
guest_name_parser = standalone_test.get_guest_name_parser(config)
for params in guest_name_parser.get_dicts():
base_dir = params.get("images_base_dir", data_dir.get_data_dir())
image_name = storage.get_image_filename(params, base_dir)
machine_type = get_opt(options, 'vt_machine_type')
machine_type = get_opt(config, 'vt_machine_type')
name = params['name'].replace('.%s' % machine_type, '')
if os.path.isfile(image_name):
out = name
......@@ -60,18 +60,18 @@ def guest_listing(options):
LOG.debug("")
def arch_listing(options):
def arch_listing(config):
"""
List available machine/archs for given guest operating systems
"""
guest_os = get_opt(options, 'vt_guest_os')
guest_os = get_opt(config, 'vt_guest_os')
if guest_os is not None:
extra = " for guest os \"%s\"" % guest_os
else:
extra = ""
LOG.info("Available arch profiles%s", extra)
guest_name_parser = standalone_test.get_guest_name_parser(options)
machine_type = get_opt(options, 'vt_machine_type')
guest_name_parser = standalone_test.get_guest_name_parser(config)
machine_type = get_opt(config, 'vt_machine_type')
for params in guest_name_parser.get_dicts():
LOG.debug(params['name'].replace('.%s' % machine_type, ''))
LOG.debug("")
......@@ -92,44 +92,48 @@ class VirtTestLoader(loader.TestLoader):
name = 'vt'
def __init__(self, args, extra_params):
def __init__(self, config, extra_params):
"""
Following extra_params are supported:
* avocado_vt_extra_params: Will override the "vt_extra_params"
of this plugins "self.args" (extends the --vt-extra-params)
of this plugins "self.config" (extends the --vt-extra-params)
"""
vt_extra_params = extra_params.pop("avocado_vt_extra_params", None)
super(VirtTestLoader, self).__init__(args, extra_params)
super(VirtTestLoader, self).__init__(config, extra_params)
# Avocado has renamed "args" to "config" in 84ae9a5d61, lets
# keep making the old name available for compatibility with
# new and old releases
if hasattr(self, 'config'):
self.args = self.config
self.args = self.config # pylint: disable=E0203
# And in case an older Avocado is used, the Loader class will
# contain an "args" attribute instead
else:
self.config = self.args # pylint: disable=E0203
if vt_extra_params:
# We don't want to override the original args
self.args = copy.deepcopy(self.args)
extra = get_opt(self.args, 'vt_extra_params')
# We don't want to override the original config
self.config = copy.deepcopy(self.config)
extra = get_opt(self.config, 'vt_extra_params')
if extra is not None:
extra += vt_extra_params
else:
extra = vt_extra_params
set_opt(self.args, 'vt_extra_params', extra)
set_opt(self.config, 'vt_extra_params', extra)
def _get_parser(self):
options_processor = VirtTestOptionsProcess(self.args)
options_processor = VirtTestOptionsProcess(self.config)
return options_processor.get_parser()
def get_extra_listing(self):
if get_opt(self.args, 'vt_list_guests'):
args = copy.copy(self.args)
set_opt(args, 'vt_config', None)
set_opt(args, 'vt_guest_os', None)
guest_listing(args)
if get_opt(self.args, 'vt_list_archs'):
args = copy.copy(self.args)
set_opt(args, 'vt_machine_type', None)
set_opt(args, 'vt_arch', None)
arch_listing(args)
if get_opt(self.config, 'vt_list_guests'):
config = copy.copy(self.config)
set_opt(config, 'vt_config', None)
set_opt(config, 'vt_guest_os', None)
guest_listing(config)
if get_opt(self.config, 'vt_list_archs'):
config = copy.copy(self.config)
set_opt(config, 'vt_machine_type', None)
set_opt(config, 'vt_arch', None)
arch_listing(config)
@staticmethod
def get_type_label_mapping():
......@@ -176,7 +180,7 @@ class VirtTestLoader(loader.TestLoader):
except cartesian_config.ParserError as details:
return self._report_bad_discovery(url, details, which_tests)
elif (which_tests is loader.DiscoverMode.DEFAULT and
not get_opt(self.args, 'vt_config')):
not get_opt(self.config, 'vt_config')):
# By default don't run anything unless vt_config provided
return []
# Create test_suite
......@@ -184,9 +188,9 @@ class VirtTestLoader(loader.TestLoader):
for params in (_ for _ in cartesian_parser.get_dicts()):
# Evaluate the proper avocado-vt test name
test_name = None
if get_opt(self.args, 'vt_config'):
if get_opt(self.config, 'vt_config'):
test_name = params.get("shortname")
elif get_opt(self.args, 'vt_type') == "spice":
elif get_opt(self.config, 'vt_type') == "spice":
short_name_map_file = params.get("_short_name_map_file")
if "tests-variants.cfg" in short_name_map_file:
test_name = short_name_map_file["tests-variants.cfg"]
......
此差异已折叠。
......@@ -166,10 +166,10 @@ class VTRun(CLI):
default=uri_current,
help=msg)
def run(self, args):
def run(self, config):
"""
Run test modules or simple tests.
:param args: Command line args received from the run subparser.
:param config: Command line args received from the run subparser.
"""
loader.register_plugin(VirtTestLoader)
......@@ -113,5 +113,5 @@ class VTLister(CLI):
add_basic_vt_options(vt_compat_group_lister)
add_qemu_bin_vt_option(vt_compat_group_lister)
def run(self, args):
def run(self, config):
loader.register_plugin(VirtTestLoader)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册