[oe-commits] [openembedded-core] 10/16: lib/oeqa/otest.py: Fix import tests from other layers with python3

git at git.openembedded.org git at git.openembedded.org
Mon Jun 6 21:54:25 UTC 2016


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

commit a26f23d3ce8f7e9f59dbc9bf27516377fd7a0a6d
Author: Mariano Lopez <mariano.lopez at linux.intel.com>
AuthorDate: Mon Jun 6 07:15:40 2016 +0000

    lib/oeqa/otest.py: Fix import tests from other layers with python3
    
    In python3 the functionality to import modules has been changed and
    this broke the capability to add runtime tests from other layers.
    
    This commit returns this capability to testimage and testexport.
    
    [YOCTO #9705]
    
    Signed-off-by: Mariano Lopez <mariano.lopez at linux.intel.com>
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 meta/classes/testexport.bbclass   | 10 ++++++----
 meta/lib/oeqa/__init__.py         |  0
 meta/lib/oeqa/oetest.py           |  5 ++---
 meta/lib/oeqa/runtime/__init__.py |  3 ---
 4 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/meta/classes/testexport.bbclass b/meta/classes/testexport.bbclass
index 51b7d93..c86eaac 100644
--- a/meta/classes/testexport.bbclass
+++ b/meta/classes/testexport.bbclass
@@ -96,11 +96,13 @@ def exportTests(d,tc):
                         shutil.copytree(foldername, target_folder)
         if not isfolder:
             shutil.copy2(mod.path, os.path.join(exportpath, "oeqa/runtime"))
-    # copy __init__.py files
-    oeqadir = os.path.dirname(pkgutil.get_loader("oeqa").path)
-    shutil.copy2(os.path.join(oeqadir, "__init__.py"), os.path.join(exportpath, "oeqa"))
-    shutil.copy2(os.path.join(oeqadir, "runtime/__init__.py"), os.path.join(exportpath, "oeqa/runtime"))
+    # Get meta layer
+    for layer in d.getVar("BBLAYERS", True).split():
+        if os.path.basename(layer) == "meta":
+            meta_layer = layer
+            break
     # copy oeqa/oetest.py and oeqa/runexported.py
+    oeqadir = os.path.join(meta_layer, "lib/oeqa")
     shutil.copy2(os.path.join(oeqadir, "oetest.py"), os.path.join(exportpath, "oeqa"))
     shutil.copy2(os.path.join(oeqadir, "runexported.py"), exportpath)
     # copy oeqa/utils/*.py
diff --git a/meta/lib/oeqa/__init__.py b/meta/lib/oeqa/__init__.py
deleted file mode 100644
index e69de29..0000000
diff --git a/meta/lib/oeqa/oetest.py b/meta/lib/oeqa/oetest.py
index b4cf34b..819f959 100644
--- a/meta/lib/oeqa/oetest.py
+++ b/meta/lib/oeqa/oetest.py
@@ -203,8 +203,7 @@ class TestContext(object):
         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(
-            oeqa.runtime.__file__)), "files")
+        self.filesdir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "runtime/files")
         self.imagefeatures = d.getVar("IMAGE_FEATURES", True).split()
         self.distrofeatures = d.getVar("DISTRO_FEATURES", True).split()
 
@@ -460,7 +459,7 @@ class RuntimeTestContext(TestContext):
         Returns the path of the JSON file for a module, empty if doesn't exitst.
         """
 
-        module_file = module.filename
+        module_file = module.path
         json_file = "%s.json" % module_file.rsplit(".", 1)[0]
         if os.path.isfile(module_file) and os.path.isfile(json_file):
             return json_file
diff --git a/meta/lib/oeqa/runtime/__init__.py b/meta/lib/oeqa/runtime/__init__.py
deleted file mode 100644
index 4cf3fa7..0000000
--- a/meta/lib/oeqa/runtime/__init__.py
+++ /dev/null
@@ -1,3 +0,0 @@
-# Enable other layers to have tests in the same named directory
-from pkgutil import extend_path
-__path__ = extend_path(__path__, __name__)

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


More information about the Openembedded-commits mailing list