Skip to contentSkip to conversation

testexport: Add support for testcase utils

PATCH In review Erik Botö 1 participant 2 messages Sep 18, 2018 – Sep 27, 2018

lore
Share & tools
lore

Erik Botö

author
#0 lore raw

PATCH v2 1/1 testexport: Add support for testcase utils

Add the possibility to ship a lib/oeqa/runtime/cases/utils directory that will be included in the generated testexport tarball.

This makes it easier to split common functionality from test suites into modules that can be imported from multiple test suites.

---
 meta/classes/testexport.bbclass | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
meta/classes/testexport.bbclass +23 -0
index d070f07afa..790ca3aff0 100644
@@ -74,6 +74,21 @@ def testexport_main(d):
 
     copy_needed_files(d, tc)
 
+def get_runtime_cases_utils_paths(d):
+    """
+    Returns a list of paths where testcase utils must reside. Utils can be e.g.
+    common functionality used by multiple test cases.
+
+    Testcase utils are expected in <LAYER_DIR>/lib/oeqa/runtime/cases/utils/
+    """
+    paths = []
+
+    for layer in d.getVar('BBLAYERS').split():
+        path = os.path.join(layer, 'lib/oeqa/runtime/cases/utils')
+        if os.path.isdir(path):
+            paths.append(path)
+    return paths
+
 def copy_needed_files(d, tc):
     import shutil
     import oe.path
@@ -121,6 +136,14 @@ def copy_needed_files(d, tc):
         if json_file:
             shutil.copy2(json_file, cases_path)
 
+    # Copy cases/utils provided by layers
+    utils_dest_path = os.path.join(export_path, 'lib', 'oeqa', 'runtime', 'cases', 'utils')
+    utils_source_paths = get_runtime_cases_utils_paths(d)
+
+    for f in utils_source_paths:
+        if os.path.isdir(f):
+            oe.path.copytree(f, utils_dest_path)
+
     # Copy test data
     image_name = ("%s/%s" % (d.getVar('DEPLOY_DIR_IMAGE'),
                             d.getVar('IMAGE_LINK_NAME')))
Signature · 1 line
2.19.0.rc1
author
#1 lore raw

Bumping this thread in hope to get some feedback.

Cheers,
Erik

Quoted 56 lines · Erik Botö

Add the possibility to ship a lib/oeqa/runtime/cases/utils directory that will be included in the generated testexport tarball.

This makes it easier to split common functionality from test suites into modules that can be imported from multiple test suites.

---
 meta/classes/testexport.bbclass | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
meta/classes/testexport.bbclass +23 -1
index d070f07afa..790ca3aff0 100644
@@ -74,6 +74,21 @@ def testexport_main(d):
 
     copy_needed_files(d, tc)
 
+def get_runtime_cases_utils_paths(d):
+    """
+    Returns a list of paths where testcase utils must reside. Utils can be e.g.
+    common functionality used by multiple test cases.
+
+    Testcase utils are expected in <LAYER_DIR>/lib/oeqa/runtime/cases/utils/
+    """
+    paths = []
+
+    for layer in d.getVar('BBLAYERS').split():
+        path = os.path.join(layer, 'lib/oeqa/runtime/cases/utils')
+        if os.path.isdir(path):
+            paths.append(path)
+    return paths
+
 def copy_needed_files(d, tc):
     import shutil
     import oe.path
@@ -121,6 +136,14 @@ def copy_needed_files(d, tc):
         if json_file:
             shutil.copy2(json_file, cases_path)
 
+    # Copy cases/utils provided by layers
+    utils_dest_path = os.path.join(export_path, 'lib', 'oeqa', 'runtime', 'cases', 'utils')
+    utils_source_paths = get_runtime_cases_utils_paths(d)
+
+    for f in utils_source_paths:
+        if os.path.isdir(f):
+            oe.path.copytree(f, utils_dest_path)
+
     # Copy test data
     image_name = ("%s/%s" % (d.getVar('DEPLOY_DIR_IMAGE'),
                             d.getVar('IMAGE_LINK_NAME')))
--

2.19.0.rc1