test_urls: Add kernelregex= option

For verifying detected kernel paths. Add a few basic examples. I
will use this in my local iso test suite for checking debian
iso vs http-iso case
This commit is contained in:
Cole Robinson 2018-10-18 13:01:59 -04:00
parent b8aff28087
commit fe9aa7085b
2 changed files with 16 additions and 6 deletions

View File

@ -141,6 +141,7 @@ url = https://d-i.debian.org/daily-images/amd64/
testxen = 1
distro = debiantesting
kernelarg = None
kernelregex = daily/netboot/debian-installer/.*
@ -152,6 +153,7 @@ kernelarg = None
[ubuntu8.04]
url = http://old-releases.ubuntu.com/ubuntu/dists/hardy/main/installer-amd64
distro = ubuntu8.04
kernelregex = current/images/netboot/ubuntu-installer/.*
testshortcircuit = 1
[ubuntu8.04-i686]
# Sneak a port parsing example in here

View File

@ -35,13 +35,14 @@ class _URLTestData(object):
Data is stored in test_urls.ini
"""
def __init__(self, name, url, detectdistro,
testxen, testshortcircuit, kernelarg):
testxen, testshortcircuit, kernelarg, kernelregex):
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.kernelregex = kernelregex
self.testxen = testxen
@ -198,15 +199,21 @@ def _testURL(fetcher, testdata):
# to fetch files for that part
def fakeAcquireFile(filename):
logging.debug("Fake acquiring %s", filename)
return fetcher.hasFile(filename)
if not fetcher.hasFile(filename):
return False
return filename
fetcher.acquireFile = fakeAcquireFile
# Fetch regular kernel
kernel, initrd, kernelargs = hvmstore.acquireKernel()
if kernel is not True or initrd is not True:
if kernel is False or initrd is False:
AssertionError("%s-%s: hvm kernel fetching failed" %
(distname, arch))
if testdata.kernelregex and not re.match(testdata.kernelregex, kernel):
raise AssertionError("kernel=%s but testdata.kernelregex='%s'" %
(kernel, testdata.kernelregex))
if testdata.kernelarg == "None":
if bool(kernelargs):
raise AssertionError("kernelargs='%s' but testdata.kernelarg='%s'"
@ -219,8 +226,8 @@ def _testURL(fetcher, testdata):
# Fetch xen kernel
if xenstore:
kernel, initrd, kernelargs = xenstore.acquireKernel()
if kernel is not True or initrd is not True:
raise AssertionError("%s-%s: xen kernel fetching" %
if kernel is False or initrd is False:
raise AssertionError("%s-%s: xen kernel fetching failed" %
(distname, arch))
@ -279,7 +286,8 @@ def _make_tests():
vals.get("distro", None),
vals.get("testxen", "0") == "1",
vals.get("testshortcircuit", "0") == "1",
vals.get("kernelarg", None))
vals.get("kernelarg", None),
vals.get("kernelregex", None))
urls[d.name] = d
keys = list(urls.keys())