mirror of
https://git.yoctoproject.org/poky
synced 2026-09-19 09:49:33 +02:00
oeqa: fix hasPackage, add hasPackageMatch
hasPackage() was looking for the string provided as an RE substring in the manifest, which resulted in a large number of false positives (i.e. libgtkfoo would match "gtk+"). Rewrite the manifest loader to parse the files into a proper data structure, change hasPackage to do full string matches, and add hasPackageMatch which does RE substring matches. (From OE-Core rev: b9409863af71899e02275439949e3f4cdfaf2d0f) (From OE-Core rev: 990db70dac60541ef14977177fff4361e31c51eb) Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> Signed-off-by: Armin Kuster <akuster808@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
3428c1db71
commit
c71ea3831a
@@ -58,14 +58,24 @@ class oeTest(unittest.TestCase):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def hasPackage(self, pkg):
|
def hasPackage(self, pkg):
|
||||||
for item in oeTest.tc.pkgmanifest.split('\n'):
|
"""
|
||||||
if re.match(pkg, item):
|
True if the full package name exists in the manifest, False otherwise.
|
||||||
|
"""
|
||||||
|
return pkg in oeTest.tc.pkgmanifest
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def hasPackageMatch(self, match):
|
||||||
|
"""
|
||||||
|
True if match exists in the manifest as a regular expression substring,
|
||||||
|
False otherwise.
|
||||||
|
"""
|
||||||
|
for s in oeTest.tc.pkgmanifest:
|
||||||
|
if re.match(match, s):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def hasFeature(self,feature):
|
def hasFeature(self,feature):
|
||||||
|
|
||||||
if feature in oeTest.tc.imagefeatures or \
|
if feature in oeTest.tc.imagefeatures or \
|
||||||
feature in oeTest.tc.distrofeatures:
|
feature in oeTest.tc.distrofeatures:
|
||||||
return True
|
return True
|
||||||
@@ -340,17 +350,18 @@ class ImageTestContext(TestContext):
|
|||||||
self.target = target
|
self.target = target
|
||||||
self.host_dumper = host_dumper
|
self.host_dumper = host_dumper
|
||||||
|
|
||||||
|
self.pkgmanifest = {}
|
||||||
manifest = os.path.join(d.getVar("DEPLOY_DIR_IMAGE", True),
|
manifest = os.path.join(d.getVar("DEPLOY_DIR_IMAGE", True),
|
||||||
d.getVar("IMAGE_LINK_NAME", True) + ".manifest")
|
d.getVar("IMAGE_LINK_NAME", True) + ".manifest")
|
||||||
nomanifest = d.getVar("IMAGE_NO_MANIFEST", True)
|
nomanifest = d.getVar("IMAGE_NO_MANIFEST", True)
|
||||||
if nomanifest is None or nomanifest != "1":
|
if nomanifest is None or nomanifest != "1":
|
||||||
try:
|
try:
|
||||||
with open(manifest) as f:
|
with open(manifest) as f:
|
||||||
self.pkgmanifest = f.read()
|
for line in f:
|
||||||
|
(pkg, arch, version) = line.strip().split()
|
||||||
|
self.pkgmanifest[pkg] = (version, arch)
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
bb.fatal("No package manifest file found. Did you build the image?\n%s" % e)
|
bb.fatal("No package manifest file found. Did you build the image?\n%s" % e)
|
||||||
else:
|
|
||||||
self.pkgmanifest = ""
|
|
||||||
|
|
||||||
self.sigterm = False
|
self.sigterm = False
|
||||||
self.origsigtermhandler = signal.getsignal(signal.SIGTERM)
|
self.origsigtermhandler = signal.getsignal(signal.SIGTERM)
|
||||||
@@ -396,8 +407,11 @@ class SDKTestContext(TestContext):
|
|||||||
if not hasattr(self, 'target_manifest'):
|
if not hasattr(self, 'target_manifest'):
|
||||||
self.target_manifest = d.getVar("SDK_TARGET_MANIFEST", True)
|
self.target_manifest = d.getVar("SDK_TARGET_MANIFEST", True)
|
||||||
try:
|
try:
|
||||||
|
self.pkgmanifest = {}
|
||||||
with open(self.target_manifest) as f:
|
with open(self.target_manifest) as f:
|
||||||
self.pkgmanifest = f.read()
|
for line in f:
|
||||||
|
(pkg, arch, version) = line.strip().split()
|
||||||
|
self.pkgmanifest[pkg] = (version, arch)
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
bb.fatal("No package manifest file found. Did you build the sdk image?\n%s" % e)
|
bb.fatal("No package manifest file found. Did you build the sdk image?\n%s" % e)
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import subprocess
|
|||||||
def setUpModule():
|
def setUpModule():
|
||||||
if not oeRuntimeTest.hasFeature("package-management"):
|
if not oeRuntimeTest.hasFeature("package-management"):
|
||||||
skipModule("Image doesn't have package management feature")
|
skipModule("Image doesn't have package management feature")
|
||||||
if not oeRuntimeTest.hasPackage("smart"):
|
if not oeRuntimeTest.hasPackage("smartpm"):
|
||||||
skipModule("Image doesn't have smart installed")
|
skipModule("Image doesn't have smart installed")
|
||||||
if "package_rpm" != oeRuntimeTest.tc.d.getVar("PACKAGE_CLASSES", True).split()[0]:
|
if "package_rpm" != oeRuntimeTest.tc.d.getVar("PACKAGE_CLASSES", True).split()[0]:
|
||||||
skipModule("Rpm is not the primary package manager")
|
skipModule("Rpm is not the primary package manager")
|
||||||
@@ -105,7 +105,7 @@ class PtestRunnerTest(oeRuntimeTest):
|
|||||||
def test_ptestrunner(self):
|
def test_ptestrunner(self):
|
||||||
self.add_smart_channel()
|
self.add_smart_channel()
|
||||||
(runnerstatus, result) = self.target.run('which ptest-runner', 0)
|
(runnerstatus, result) = self.target.run('which ptest-runner', 0)
|
||||||
cond = oeRuntimeTest.hasPackage("ptest-runner") and oeRuntimeTest.hasFeature("ptest") and oeRuntimeTest.hasPackage("-ptest") and (runnerstatus != 0)
|
cond = oeRuntimeTest.hasPackage("ptest-runner") and oeRuntimeTest.hasFeature("ptest") and oeRuntimeTest.hasPackageMatch("-ptest") and (runnerstatus != 0)
|
||||||
if cond:
|
if cond:
|
||||||
self.install_packages(self.install_complementary("*-ptest"))
|
self.install_packages(self.install_complementary("*-ptest"))
|
||||||
self.install_packages(['ptest-runner'])
|
self.install_packages(['ptest-runner'])
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ from oeqa.oetest import oeRuntimeTest, skipModule
|
|||||||
from oeqa.utils.decorators import *
|
from oeqa.utils.decorators import *
|
||||||
|
|
||||||
def setUpModule():
|
def setUpModule():
|
||||||
if not oeRuntimeTest.hasPackage("python"):
|
if not oeRuntimeTest.hasPackage("python-core"):
|
||||||
skipModule("No python package in the image")
|
skipModule("No python package in the image")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ from oeqa.utils.httpserver import HTTPService
|
|||||||
def setUpModule():
|
def setUpModule():
|
||||||
if not oeRuntimeTest.hasFeature("package-management"):
|
if not oeRuntimeTest.hasFeature("package-management"):
|
||||||
skipModule("Image doesn't have package management feature")
|
skipModule("Image doesn't have package management feature")
|
||||||
if not oeRuntimeTest.hasPackage("smart"):
|
if not oeRuntimeTest.hasPackage("smartpm"):
|
||||||
skipModule("Image doesn't have smart installed")
|
skipModule("Image doesn't have smart installed")
|
||||||
if "package_rpm" != oeRuntimeTest.tc.d.getVar("PACKAGE_CLASSES", True).split()[0]:
|
if "package_rpm" != oeRuntimeTest.tc.d.getVar("PACKAGE_CLASSES", True).split()[0]:
|
||||||
skipModule("Rpm is not the primary package manager")
|
skipModule("Rpm is not the primary package manager")
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from oeqa.utils.decorators import *
|
|||||||
from oeqa.utils.targetbuild import SDKBuildProject
|
from oeqa.utils.targetbuild import SDKBuildProject
|
||||||
|
|
||||||
def setUpModule():
|
def setUpModule():
|
||||||
if not oeSDKTest.hasPackage("gtk\+"):
|
if not oeSDKTest.hasPackage("gtk+"):
|
||||||
skipModule("Image doesn't have gtk+ in manifest")
|
skipModule("Image doesn't have gtk+ in manifest")
|
||||||
|
|
||||||
class SudokuTest(oeSDKTest):
|
class SudokuTest(oeSDKTest):
|
||||||
|
|||||||
Reference in New Issue
Block a user