tests: test_urls: Add urldetect kernel arg validation

This commit is contained in:
Cole Robinson 2018-04-02 16:50:41 -04:00
parent fb9b82e02d
commit eafdaf8b48
3 changed files with 32 additions and 16 deletions

View File

@ -12,6 +12,7 @@
[fedora-old]
url = https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/14/Fedora/x86_64/os/
distro = fedora14
kernelarg = method=
[fedora-old-i686]
url = https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/14/Fedora/i386/os/
distro = fedora14
@ -33,6 +34,7 @@ url = http://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/Server/x8
distro = testsuite-fedora-rawhide
testxen = 1
testbootiso = 1
kernelarg = inst.repo=
@ -100,12 +102,14 @@ distro = opensuse13.2
[opensuseleap-42.3]
url = http://download.opensuse.org/distribution/leap/42.3/repo/oss/
distro = opensuse42.3
kernelarg = install=
# opensuse tumbleweed (rolling distro)
# Test for xen for full coverage
[opensusetumbleweed]
url = http://download.opensuse.org/tumbleweed/repo/oss/
distro = opensusetumbleweed
testxen = 1
kernelarg = install=
@ -139,6 +143,7 @@ url = https://d-i.debian.org/daily-images/amd64/
testxen = 1
testbootiso = 1
distro = debiantesting
kernelarg = None

View File

@ -35,12 +35,13 @@ class _URLTestData(object):
Data is stored in test_urls.ini
"""
def __init__(self, name, url, detectdistro,
testxen, testbootiso, testshortcircuit):
testxen, testbootiso, testshortcircuit, kernelarg):
self.name = name
self.url = url
self.detectdistro = detectdistro
self.arch = self._find_arch()
self.distroclass = self._distroclass_for_name(self.name)
self.kernelarg = kernelarg
self.testxen = testxen
self.testbootiso = testbootiso
@ -212,19 +213,24 @@ def _testURL(fetcher, testdata):
(distname, arch))
# Fetch regular kernel
kern = hvmstore.acquireKernel()
logging.debug("acquireKernel (hvm): %s", str(kern))
if kern[0] is not True or kern[1] is not True:
kernel, initrd, kernelargs = hvmstore.acquireKernel()
if kernel is not True or initrd is not True:
AssertionError("%s-%s: hvm kernel fetching failed" %
(distname, arch))
if testdata.kernelarg == "None":
if bool(kernelargs):
raise AssertionError("kernelargs='%s' but testdata.kernelarg='%s'"
% (kernelargs, testdata.kernelarg))
elif testdata.kernelarg:
if not kernelargs.startswith(testdata.kernelarg):
raise AssertionError("kernelargs='%s' but testdata.kernelarg='%s'"
% (kernelargs, testdata.kernelarg))
# Fetch xen kernel
if xenstore:
kern = xenstore.acquireKernel()
logging.debug("acquireKernel (xen): %s", str(kern))
if kern[0] is not True or kern[1] is not True:
kernel, initrd, kernelargs = xenstore.acquireKernel()
if kernel is not True or initrd is not True:
raise AssertionError("%s-%s: xen kernel fetching" %
(distname, arch))
@ -284,7 +290,8 @@ def _make_tests():
vals.get("distro", None),
vals.get("testxen", "0") == "1",
vals.get("testbootiso", "0") == "1",
vals.get("testshortcircuit", "0") == "1")
vals.get("testshortcircuit", "0") == "1",
vals.get("kernelarg", None))
urls[d.name] = d
keys = list(urls.keys())

View File

@ -290,8 +290,8 @@ class Distro(object):
{"distro": self.PRETTY_NAME})
args = ""
if not self.fetcher.location.startswith("/"):
args += "%s=%s" % (self._get_method_arg(), self.fetcher.location)
if not self.uri.startswith("/") and self._get_kernel_url_arg():
args += "%s=%s" % (self._get_kernel_url_arg(), self.uri)
kernel = self.fetcher.acquireFile(kernelpath)
try:
@ -326,8 +326,12 @@ class Distro(object):
return self.os_variant
def _get_method_arg(self):
return "method"
def _get_kernel_url_arg(self):
"""
Kernel argument name the distro's installer uses to reference
a network source, possibly bypassing some installer prompts
"""
return None
class GenericTreeinfoDistro(Distro):
@ -385,7 +389,7 @@ class RedHatDistro(GenericTreeinfoDistro):
def _detect_version(self):
pass
def _get_method_arg(self):
def _get_kernel_url_arg(self):
if (self._version_number is not None and
((self.urldistro == "rhel" and self._version_number >= 7) or
(self.urldistro == "fedora" and self._version_number >= 19))):
@ -592,7 +596,7 @@ class SuseDistro(Distro):
return osobj.name
return self.os_variant
def _get_method_arg(self):
def _get_kernel_url_arg(self):
return "install"