summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/classes/testexport.bbclass24
-rw-r--r--meta/lib/oeqa/oetest.py17
2 files changed, 18 insertions, 23 deletions
diff --git a/meta/classes/testexport.bbclass b/meta/classes/testexport.bbclass
index 15fa470785..5147020820 100644
--- a/meta/classes/testexport.bbclass
+++ b/meta/classes/testexport.bbclass
@@ -47,6 +47,7 @@ def exportTests(d,tc):
47 import shutil 47 import shutil
48 import pkgutil 48 import pkgutil
49 import re 49 import re
50 import oe.path
50 51
51 exportpath = d.getVar("TEST_EXPORT_DIR", True) 52 exportpath = d.getVar("TEST_EXPORT_DIR", True)
52 53
@@ -103,7 +104,7 @@ def exportTests(d,tc):
103 isfolder = True 104 isfolder = True
104 target_folder = os.path.join(exportpath, "oeqa", "runtime", os.path.basename(foldername)) 105 target_folder = os.path.join(exportpath, "oeqa", "runtime", os.path.basename(foldername))
105 if not os.path.exists(target_folder): 106 if not os.path.exists(target_folder):
106 shutil.copytree(foldername, target_folder) 107 oe.path.copytree(foldername, target_folder)
107 if not isfolder: 108 if not isfolder:
108 shutil.copy2(mod.path, os.path.join(exportpath, "oeqa/runtime")) 109 shutil.copy2(mod.path, os.path.join(exportpath, "oeqa/runtime"))
109 json_file = "%s.json" % mod.path.rsplit(".", 1)[0] 110 json_file = "%s.json" % mod.path.rsplit(".", 1)[0]
@@ -132,27 +133,12 @@ def exportTests(d,tc):
132 create_tarball(d, "testexport.tar.gz", d.getVar("TEST_EXPORT_DIR", True)) 133 create_tarball(d, "testexport.tar.gz", d.getVar("TEST_EXPORT_DIR", True))
133 134
134 # Copy packages needed for runtime testing 135 # Copy packages needed for runtime testing
135 export_pkg_dir = os.path.join(d.getVar("TEST_EXPORT_DIR", True), "packages")
136 test_pkg_dir = d.getVar("TEST_NEEDED_PACKAGES_DIR", True) 136 test_pkg_dir = d.getVar("TEST_NEEDED_PACKAGES_DIR", True)
137 need_pkg_dir = False 137 if os.listdir(test_pkg_dir):
138 for root, subdirs, files in os.walk(test_pkg_dir): 138 export_pkg_dir = os.path.join(d.getVar("TEST_EXPORT_DIR", True), "packages")
139 for subdir in subdirs: 139 oe.path.copytree(test_pkg_dir, export_pkg_dir)
140 tmp_dir = os.path.join(root.replace(test_pkg_dir, "").lstrip("/"), subdir)
141 new_dir = os.path.join(export_pkg_dir, tmp_dir)
142 bb.utils.mkdirhier(new_dir)
143
144 for f in files:
145 need_pkg_dir = True
146 src_f = os.path.join(root, f)
147 dst_f = os.path.join(export_pkg_dir, root.replace(test_pkg_dir, "").lstrip("/"), f)
148 shutil.copy2(src_f, dst_f)
149
150 if need_pkg_dir:
151 # Create tar file for packages needed by the DUT 140 # Create tar file for packages needed by the DUT
152 create_tarball(d, "testexport_packages_%s.tar.gz" % d.getVar("MACHINE", True), export_pkg_dir) 141 create_tarball(d, "testexport_packages_%s.tar.gz" % d.getVar("MACHINE", True), export_pkg_dir)
153 else:
154 # Remov packages dir from exported test
155 bb.utils.remove(export_pkg_dir, True)
156 142
157 # Copy SDK 143 # Copy SDK
158 if d.getVar("TEST_EXPORT_SDK_ENABLED", True) == "1": 144 if d.getVar("TEST_EXPORT_SDK_ENABLED", True) == "1":
diff --git a/meta/lib/oeqa/oetest.py b/meta/lib/oeqa/oetest.py
index 7dca77a969..514631249c 100644
--- a/meta/lib/oeqa/oetest.py
+++ b/meta/lib/oeqa/oetest.py
@@ -443,6 +443,8 @@ class RuntimeTestContext(TestContext):
443 modules = self.getTestModules() 443 modules = self.getTestModules()
444 bbpaths = self.d.getVar("BBPATH", True).split(":") 444 bbpaths = self.d.getVar("BBPATH", True).split(":")
445 445
446 shutil.rmtree(self.d.getVar("TEST_EXTRACTED_DIR", True))
447 shutil.rmtree(self.d.getVar("TEST_PACKAGED_DIR", True))
446 for module in modules: 448 for module in modules:
447 json_file = self._getJsonFile(module) 449 json_file = self._getJsonFile(module)
448 if json_file: 450 if json_file:
@@ -454,6 +456,8 @@ class RuntimeTestContext(TestContext):
454 Extract packages that will be needed during runtime. 456 Extract packages that will be needed during runtime.
455 """ 457 """
456 458
459 import oe.path
460
457 extracted_path = self.d.getVar("TEST_EXTRACTED_DIR", True) 461 extracted_path = self.d.getVar("TEST_EXTRACTED_DIR", True)
458 packaged_path = self.d.getVar("TEST_PACKAGED_DIR", True) 462 packaged_path = self.d.getVar("TEST_PACKAGED_DIR", True)
459 463
@@ -477,13 +481,18 @@ class RuntimeTestContext(TestContext):
477 dst_dir = os.path.join(packaged_path) 481 dst_dir = os.path.join(packaged_path)
478 482
479 # Extract package and copy it to TEST_EXTRACTED_DIR 483 # Extract package and copy it to TEST_EXTRACTED_DIR
480 if extract and not os.path.exists(dst_dir): 484 pkg_dir = self._extract_in_tmpdir(pkg)
481 pkg_dir = self._extract_in_tmpdir(pkg) 485 if extract:
482 shutil.copytree(pkg_dir, dst_dir) 486
487 # Same package used for more than one test,
488 # don't need to extract again.
489 if os.path.exists(dst_dir):
490 continue
491 oe.path.copytree(pkg_dir, dst_dir)
483 shutil.rmtree(pkg_dir) 492 shutil.rmtree(pkg_dir)
484 493
485 # Copy package to TEST_PACKAGED_DIR 494 # Copy package to TEST_PACKAGED_DIR
486 elif not extract: 495 else:
487 self._copy_package(pkg) 496 self._copy_package(pkg)
488 497
489 def _getJsonFile(self, module): 498 def _getJsonFile(self, module):