[oe-commits] [openembedded-core] 34/56: oetest.py: Add json file support to specify packages needed in runtime tests

git at git.openembedded.org git at git.openembedded.org
Mon May 30 08:38:57 UTC 2016


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

commit 1f24ef9a339a2ad34e010f39aa93abdc8d085c85
Author: Mariano Lopez <mariano.lopez at linux.intel.com>
AuthorDate: Tue May 24 12:44:13 2016 +0000

    oetest.py: Add json file support to specify packages needed in runtime tests
    
    This adds the functionality to use a json file to
    specify the packages needed for a particular test.
    
    The content of the json file is a dictionary with
    dictionaries inside, using the test name as the hash.
    
    The json file must have the same name as the class
    module name and must be in the same path.
    
    [YOCTO #7850]
    
    Signed-off-by: Mariano Lopez <mariano.lopez at linux.intel.com>
    Signed-off-by: Ross Burton <ross.burton at intel.com>
---
 meta/lib/oeqa/oetest.py | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/meta/lib/oeqa/oetest.py b/meta/lib/oeqa/oetest.py
index 8ad3715..7abd850 100644
--- a/meta/lib/oeqa/oetest.py
+++ b/meta/lib/oeqa/oetest.py
@@ -385,6 +385,43 @@ class RuntimeTestContext(TestContext):
         if oeTest.hasPackage("procps"):
             oeRuntimeTest.pscmd = "ps -ef"
 
+    def _getJsonFile(self, module):
+        """
+        Returns the path of the JSON file for a module, empty if doesn't exitst.
+        """
+
+        module_file = module.filename
+        json_file = "%s.json" % module_file.rsplit(".", 1)[0]
+        if os.path.isfile(module_file) and os.path.isfile(json_file):
+            return json_file
+        else:
+            return ""
+
+    def _getNeededPackages(self, json_file, test=None):
+        """
+        Returns a dict with needed packages based on a JSON file.
+
+
+        If a test is specified it will return the dict just for that test.
+        """
+
+        import json
+
+        needed_packages = {}
+
+        with open(json_file) as f:
+            test_packages = json.load(f)
+        for key,value in test_packages.items():
+            needed_packages[key] = value
+
+        if test:
+            if test in needed_packages:
+                needed_packages = needed_packages[test]
+            else:
+                needed_packages = {}
+
+        return needed_packages
+
 class ImageTestContext(RuntimeTestContext):
     def __init__(self, d, target, host_dumper):
         super(ImageTestContext, self).__init__(d, target)

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


More information about the Openembedded-commits mailing list