[oe-commits] [openembedded-core] 09/11: oetest.py: Use the real ExportTestContext in exported tests

git at git.openembedded.org git at git.openembedded.org
Tue May 17 18:06:56 UTC 2016


rpurdie pushed a commit to branch master-next
in repository openembedded-core.

commit a029459e60440ee2bbbe7294898e304cb93ef445
Author: Mariano Lopez <mariano.lopez at linux.intel.com>
AuthorDate: Mon May 2 13:19:19 2016 +0000

    oetest.py: Use the real ExportTestContext in exported tests
    
    There are parts of the fuctionallity missing when using the
    dummy ExportTestContext class in runexported.py.
    
    This changes the use of ExportTestContext dummy class from
    runexported.py to the real class in oetest.py.
    
    Signed-off-by: Mariano Lopez <mariano.lopez at linux.intel.com>
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 meta/lib/oeqa/oetest.py      | 26 +++++++++++++++++---------
 meta/lib/oeqa/runexported.py | 16 ++--------------
 2 files changed, 19 insertions(+), 23 deletions(-)

diff --git a/meta/lib/oeqa/oetest.py b/meta/lib/oeqa/oetest.py
index 6a908ee..70db119 100644
--- a/meta/lib/oeqa/oetest.py
+++ b/meta/lib/oeqa/oetest.py
@@ -186,11 +186,19 @@ def custom_verbose(msg, *args, **kwargs):
         _buffer_logger = ""
 
 class TestContext(object):
-    def __init__(self, d):
+    def __init__(self, d, exported=False):
         self.d = d
 
         self.testsuites = self._get_test_suites()
-        self.testslist = self._get_tests_list(d.getVar("BBPATH", True).split(':'))
+
+        if exported:
+            path = [os.path.dirname(os.path.abspath(__file__))]
+            extrapath = ""
+        else:
+            path = d.getVar("BBPATH", True).split(':')
+            extrapath = "lib/oeqa"
+
+        self.testslist = self._get_tests_list(path, extrapath)
         self.testsrequired = self._get_test_suites_required()
 
         self.filesdir = os.path.join(os.path.dirname(os.path.abspath(
@@ -213,7 +221,7 @@ class TestContext(object):
         return " ".join(tcs)
 
     # return test list by type also filter if TEST_SUITES is specified
-    def _get_tests_list(self, bbpath):
+    def _get_tests_list(self, bbpath, extrapath):
         testslist = []
 
         type = self._get_test_namespace()
@@ -227,11 +235,11 @@ class TestContext(object):
                     continue
                 found = False
                 for p in bbpath:
-                    if os.path.exists(os.path.join(p, 'lib', 'oeqa', type, testname + '.py')):
+                    if os.path.exists(os.path.join(p, extrapath, type, testname + ".py")):
                         testslist.append("oeqa." + type + "." + testname)
                         found = True
                         break
-                    elif os.path.exists(os.path.join(p, 'lib', 'oeqa', type, testname.split(".")[0] + '.py')):
+                    elif os.path.exists(os.path.join(p, extrapath, type, testname.split(".")[0] + ".py")):
                         testslist.append("oeqa." + type + "." + testname)
                         found = True
                         break
@@ -333,8 +341,8 @@ class TestContext(object):
         return runner.run(self.suite)
 
 class RuntimeTestContext(TestContext):
-    def __init__(self, d, target):
-        super(RuntimeTestContext, self).__init__(d)
+    def __init__(self, d, target, exported=False):
+        super(RuntimeTestContext, self).__init__(d, exported)
 
         self.tagexp =  d.getVar("TEST_SUITES_TAGS", True)
 
@@ -393,8 +401,8 @@ class ImageTestContext(RuntimeTestContext):
         self.target.stop()
 
 class ExportTestContext(RuntimeTestContext):
-    def __init__(self, d, target):
-        super(ExportTestContext, self).__init__(d, target)
+    def __init__(self, d, target, exported=False):
+        super(ExportTestContext, self).__init__(d, target, exported)
         self.sigterm = None
 
 class SDKTestContext(TestContext):
diff --git a/meta/lib/oeqa/runexported.py b/meta/lib/oeqa/runexported.py
index f333879..52c1171 100755
--- a/meta/lib/oeqa/runexported.py
+++ b/meta/lib/oeqa/runexported.py
@@ -30,7 +30,7 @@ except ImportError:
 
 sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "oeqa")))
 
-from oeqa.oetest import TestContext
+from oeqa.oetest import ExportTestContext
 from oeqa.utils.sshcontrol import SSHControl
 from oeqa.utils.dump import get_host_dumper
 
@@ -69,10 +69,6 @@ class MyDataDict(dict):
     def getVar(self, key, unused = None):
         return self.get(key, "")
 
-class ExportTestContext(TestContext):
-    def __init__(self, d):
-        self.d = d
-
 def main():
 
     parser = argparse.ArgumentParser()
@@ -111,20 +107,12 @@ def main():
         if not os.path.isdir(d["DEPLOY_DIR"]):
             print("WARNING: The path to DEPLOY_DIR does not exist: %s" % d["DEPLOY_DIR"])
 
-
     target = FakeTarget(d)
     for key in loaded["target"].keys():
         setattr(target, key, loaded["target"][key])
 
     target.exportStart()
-    tc = ExportTestContext(d)
-
-    setattr(tc, "d", d)
-    setattr(tc, "target", target)
-    for key in loaded.keys():
-        if key != "d" and key != "target" and key != "host_dumper":
-            setattr(tc, key, loaded[key])
-
+    tc = ExportTestContext(d, target, True)
     tc.loadTests()
     tc.runTests()
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list