diff options
Diffstat (limited to 'meta/lib/oeqa/oetest.py')
-rw-r--r-- | meta/lib/oeqa/oetest.py | 57 |
1 files changed, 28 insertions, 29 deletions
diff --git a/meta/lib/oeqa/oetest.py b/meta/lib/oeqa/oetest.py index 0db6cb80a9..0b7e7dc42d 100644 --- a/meta/lib/oeqa/oetest.py +++ b/meta/lib/oeqa/oetest.py @@ -10,25 +10,29 @@ import os, re, mmap import unittest import inspect - - -def loadTests(tc): - - # set the context object passed from the test class - setattr(oeTest, "tc", tc) - # set ps command to use - setattr(oeRuntimeTest, "pscmd", "ps -ef" if oeTest.hasPackage("procps") else "ps") - # prepare test suite, loader and runner - suite = unittest.TestSuite() +import subprocess +from oeqa.utils.decorators import LogResults + +def loadTests(tc, type="runtime"): + if type == "runtime": + # set the context object passed from the test class + setattr(oeTest, "tc", tc) + # set ps command to use + setattr(oeRuntimeTest, "pscmd", "ps -ef" if oeTest.hasPackage("procps") else "ps") + # prepare test suite, loader and runner + suite = unittest.TestSuite() + elif type == "sdk": + # set the context object passed from the test class + setattr(oeTest, "tc", tc) testloader = unittest.TestLoader() testloader.sortTestMethodsUsing = None suite = testloader.loadTestsFromNames(tc.testslist) return suite -def runTests(tc): +def runTests(tc, type="runtime"): - suite = loadTests(tc) + suite = loadTests(tc, type) print("Test modules %s" % tc.testslist) print("Found %s tests" % suite.countTestCases()) runner = unittest.TextTestRunner(verbosity=2) @@ -36,24 +40,10 @@ def runTests(tc): return result - +@LogResults class oeTest(unittest.TestCase): longMessage = True - testFailures = [] - testSkipped = [] - testErrors = [] - - def run(self, result=None): - super(oeTest, self).run(result) - - # we add to our own lists the results, we use those for decorators - 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): @@ -71,13 +61,22 @@ class oeTest(unittest.TestCase): else: return False - class oeRuntimeTest(oeTest): - def __init__(self, methodName='runTest'): self.target = oeRuntimeTest.tc.target super(oeRuntimeTest, self).__init__(methodName) + #TODO: use package_manager.py to install packages on any type of image + def install_packages(self, packagelist): + for package in packagelist: + (status, result) = self.target.run("smart install -y "+package) + if status != 0: + return status + +class oeSDKTest(oeTest): + def __init__(self, methodName='runTest'): + self.sdktestdir = oeSDKTest.tc.sdktestdir + super(oeSDKTest, self).__init__(methodName) def getmodule(pos=2): # stack returns a list of tuples containg frame information |