summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Stanacar <stefanx.stanacar@intel.com>2013-11-01 12:37:56 +0200
committerSaul Wold <sgw@linux.intel.com>2013-11-04 10:01:17 -0800
commitcd4ed41a070bd52c446ac3df8337f17ab9421145 (patch)
tree657a3b58b98f2fcff126124618acdb7d9564539d
parent1132c4210eddd59b22b2640935ab0bb8f48c0124 (diff)
downloadopenembedded-core-cd4ed41a070bd52c446ac3df8337f17ab9421145.tar.gz
openembedded-core-cd4ed41a070bd52c446ac3df8337f17ab9421145.tar.bz2
openembedded-core-cd4ed41a070bd52c446ac3df8337f17ab9421145.zip
lib/oeqa: add oeTest superclass
Add oeTest superclass, make oeRuntimeTest inherit that and make the necesarry adjustments. Tests in lib/oeqa/runtime don't change, they still inherit oeRuntimeTest. We should do this because oetest.py in the future can be a base module for more stuff than oeRuntimeTest. Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com> Signed-off-by: Saul Wold <sgw@linux.intel.com>
-rw-r--r--meta/lib/oeqa/oetest.py40
-rw-r--r--meta/lib/oeqa/utils/decorators.py10
2 files changed, 26 insertions, 24 deletions
diff --git a/meta/lib/oeqa/oetest.py b/meta/lib/oeqa/oetest.py
index 529abdc19a..3bb3589468 100644
--- a/meta/lib/oeqa/oetest.py
+++ b/meta/lib/oeqa/oetest.py
@@ -17,9 +17,9 @@ from oeqa.utils.sshcontrol import SSHControl
def runTests(tc):
# set the context object passed from the test class
- setattr(oeRuntimeTest, "tc", tc)
+ setattr(oeTest, "tc", tc)
# set ps command to use
- setattr(oeRuntimeTest, "pscmd", "ps -ef" if oeRuntimeTest.hasPackage("procps") else "ps")
+ setattr(oeRuntimeTest, "pscmd", "ps -ef" if oeTest.hasPackage("procps") else "ps")
# prepare test suite, loader and runner
suite = unittest.TestSuite()
testloader = unittest.TestLoader()
@@ -36,33 +36,28 @@ def runTests(tc):
-class oeRuntimeTest(unittest.TestCase):
+class oeTest(unittest.TestCase):
longMessage = True
testFailures = []
testSkipped = []
testErrors = []
- def __init__(self, methodName='runTest'):
- self.target = oeRuntimeTest.tc.target
- super(oeRuntimeTest, self).__init__(methodName)
-
-
def run(self, result=None):
- super(oeRuntimeTest, self).run(result)
+ super(oeTest, self).run(result)
# we add to our own lists the results, we use those for decorators
- if len(result.failures) > len(oeRuntimeTest.testFailures):
- oeRuntimeTest.testFailures.append(str(result.failures[-1][0]).split()[0])
- if len(result.skipped) > len(oeRuntimeTest.testSkipped):
- oeRuntimeTest.testSkipped.append(str(result.skipped[-1][0]).split()[0])
- if len(result.errors) > len(oeRuntimeTest.testErrors):
- oeRuntimeTest.testErrors.append(str(result.errors[-1][0]).split()[0])
+ if len(result.failures) > len(oeTest.testFailures):
+ oeTest.testFailures.append(str(result.failures[-1][0]).split()[0])
+ if len(result.skipped) > len(oeTest.testSkipped):
+ oeTest.testSkipped.append(str(result.skipped[-1][0]).split()[0])
+ if len(result.errors) > len(oeTest.testErrors):
+ oeTest.testErrors.append(str(result.errors[-1][0]).split()[0])
@classmethod
def hasPackage(self, pkg):
- pkgfile = os.path.join(oeRuntimeTest.tc.d.getVar("WORKDIR", True), "installed_pkgs.txt")
+ pkgfile = os.path.join(oeTest.tc.d.getVar("WORKDIR", True), "installed_pkgs.txt")
with open(pkgfile) as f:
data = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)
@@ -77,12 +72,19 @@ class oeRuntimeTest(unittest.TestCase):
@classmethod
def hasFeature(self,feature):
- if feature in oeRuntimeTest.tc.d.getVar("IMAGE_FEATURES", True).split() or \
- feature in oeRuntimeTest.tc.d.getVar("DISTRO_FEATURES", True).split():
+ if feature in oeTest.tc.d.getVar("IMAGE_FEATURES", True).split() or \
+ feature in oeTest.tc.d.getVar("DISTRO_FEATURES", True).split():
return True
else:
return False
+
+class oeRuntimeTest(oeTest):
+
+ def __init__(self, methodName='runTest'):
+ self.target = oeRuntimeTest.tc.target
+ super(oeRuntimeTest, self).__init__(methodName)
+
@classmethod
def restartTarget(self,params=None):
@@ -102,7 +104,7 @@ def getmodule(pos=2):
def skipModule(reason, pos=2):
modname = getmodule(pos)
- if modname not in oeRuntimeTest.tc.testsrequired:
+ if modname not in oeTest.tc.testsrequired:
raise unittest.SkipTest("%s: %s" % (modname, reason))
else:
raise Exception("\nTest %s wants to be skipped.\nReason is: %s" \
diff --git a/meta/lib/oeqa/utils/decorators.py b/meta/lib/oeqa/utils/decorators.py
index 33fed5a10b..b99da8d76d 100644
--- a/meta/lib/oeqa/utils/decorators.py
+++ b/meta/lib/oeqa/utils/decorators.py
@@ -15,7 +15,7 @@ class skipIfFailure(object):
def __call__(self,f):
def wrapped_f(*args):
- if self.testcase in (oeRuntimeTest.testFailures or oeRuntimeTest.testErrors):
+ if self.testcase in (oeTest.testFailures or oeTest.testErrors):
raise unittest.SkipTest("Testcase dependency not met: %s" % self.testcase)
return f(*args)
wrapped_f.__name__ = f.__name__
@@ -28,7 +28,7 @@ class skipIfSkipped(object):
def __call__(self,f):
def wrapped_f(*args):
- if self.testcase in oeRuntimeTest.testSkipped:
+ if self.testcase in oeTest.testSkipped:
raise unittest.SkipTest("Testcase dependency not met: %s" % self.testcase)
return f(*args)
wrapped_f.__name__ = f.__name__
@@ -41,9 +41,9 @@ class skipUnlessPassed(object):
def __call__(self,f):
def wrapped_f(*args):
- if self.testcase in oeRuntimeTest.testSkipped or \
- self.testcase in oeRuntimeTest.testFailures or \
- self.testcase in oeRuntimeTest.testErrors:
+ if self.testcase in oeTest.testSkipped or \
+ self.testcase in oeTest.testFailures or \
+ self.testcase in oeTest.testErrors:
raise unittest.SkipTest("Testcase dependency not met: %s" % self.testcase)
return f(*args)
wrapped_f.__name__ = f.__name__