tests: clitest: More infrastructure to skip default arguments

To allow testing virt-install without default --ram added for example
This commit is contained in:
Cole Robinson 2019-06-11 12:23:09 -04:00
parent b3e6ebe28b
commit cb0e37786f
2 changed files with 14 additions and 6 deletions

View File

@ -1,5 +1,6 @@
Using default --name vm1 Using default --name vm1
ERROR ERROR
--memory amount in MiB is required
--disk storage must be specified (override with --disk none) --disk storage must be specified (override with --disk none)
An install method must be specified An install method must be specified
(--location URL, --cdrom CD/ISO, --pxe, --import, --boot hd|cdrom|...) (--location URL, --cdrom CD/ISO, --pxe, --import, --boot hd|cdrom|...)

View File

@ -367,7 +367,7 @@ class App(object):
self.skip_checks = SkipChecks(None, **kwargs) self.skip_checks = SkipChecks(None, **kwargs)
self.uri = uri self.uri = uri
def _default_args(self, cli, iscompare, auto_printarg): def _default_args(self, cli, iscompare):
args = "" args = ""
if not iscompare: if not iscompare:
args = "--debug" args = "--debug"
@ -380,7 +380,7 @@ class App(object):
if "--ram " not in cli: if "--ram " not in cli:
args += " --ram 64" args += " --ram 64"
if iscompare and auto_printarg: if iscompare:
if self.appname == "virt-install": if self.appname == "virt-install":
if ("--print-xml" not in cli and if ("--print-xml" not in cli and
"--print-step" not in cli and "--print-step" not in cli and
@ -402,9 +402,16 @@ class App(object):
def _add(self, catname, testargs, compbase, **kwargs): def _add(self, catname, testargs, compbase, **kwargs):
category = self.categories[catname] category = self.categories[catname]
args = category.default_args + " " + testargs args = category.default_args + " " + testargs
defargs = self._default_args(
args, bool(compbase), bool(kwargs.pop("auto_printarg", True))) use_default_args = kwargs.pop("use_default_args", True)
cmdstr = "./%s %s %s" % (self.appname, args, defargs) if use_default_args:
args = category.default_args + " " + testargs
defargs = self._default_args(args, bool(compbase))
args += " " + defargs
else:
args = testargs
cmdstr = "./%s %s" % (self.appname, args)
kwargs["skip_checks"] = category.skip_checks kwargs["skip_checks"] = category.skip_checks
if compbase: if compbase:
@ -826,7 +833,7 @@ c.add_compare("--cdrom %(EXISTIMG2)s --os-variant win2k3 --wait 0 --vcpus cores=
c.add_invalid("--paravirt --import --print-xml 2") # PV Import install, no second XML step c.add_invalid("--paravirt --import --print-xml 2") # PV Import install, no second XML step
c = vinst.add_category("misc-install", "--nographics --noautoconsole") c = vinst.add_category("misc-install", "--nographics --noautoconsole")
c.add_compare("", "noargs-fail", auto_printarg=False) # No arguments c.add_compare("--connect %s" % (utils.URIs.test_suite), "noargs-fail", use_default_args=False) # No arguments
c.add_valid("--panic help --disk=? --check=help", grep="path_in_use") # Make sure introspection doesn't blow up c.add_valid("--panic help --disk=? --check=help", grep="path_in_use") # Make sure introspection doesn't blow up
c.add_valid("--test-stub-command") # --test-stub-command c.add_valid("--test-stub-command") # --test-stub-command
c.add_valid("--nodisks --pxe", grep="VM performance may suffer") # os variant warning c.add_valid("--nodisks --pxe", grep="VM performance may suffer") # os variant warning