summaryrefslogtreecommitdiffstats
path: root/meta/classes/testexport.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes/testexport.bbclass')
-rw-r--r--meta/classes/testexport.bbclass32
1 files changed, 32 insertions, 0 deletions
diff --git a/meta/classes/testexport.bbclass b/meta/classes/testexport.bbclass
index 6009349341..15fa470785 100644
--- a/meta/classes/testexport.bbclass
+++ b/meta/classes/testexport.bbclass
@@ -128,9 +128,13 @@ def exportTests(d,tc):
128 for f in files: 128 for f in files:
129 shutil.copy2(os.path.join(root, f), os.path.join(exportpath, "oeqa/runtime/files")) 129 shutil.copy2(os.path.join(root, f), os.path.join(exportpath, "oeqa/runtime/files"))
130 130
131 # Create tar file for common parts of testexport
132 create_tarball(d, "testexport.tar.gz", d.getVar("TEST_EXPORT_DIR", True))
133
131 # Copy packages needed for runtime testing 134 # Copy packages needed for runtime testing
132 export_pkg_dir = os.path.join(d.getVar("TEST_EXPORT_DIR", True), "packages") 135 export_pkg_dir = os.path.join(d.getVar("TEST_EXPORT_DIR", True), "packages")
133 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
134 for root, subdirs, files in os.walk(test_pkg_dir): 138 for root, subdirs, files in os.walk(test_pkg_dir):
135 for subdir in subdirs: 139 for subdir in subdirs:
136 tmp_dir = os.path.join(root.replace(test_pkg_dir, "").lstrip("/"), subdir) 140 tmp_dir = os.path.join(root.replace(test_pkg_dir, "").lstrip("/"), subdir)
@@ -138,10 +142,18 @@ def exportTests(d,tc):
138 bb.utils.mkdirhier(new_dir) 142 bb.utils.mkdirhier(new_dir)
139 143
140 for f in files: 144 for f in files:
145 need_pkg_dir = True
141 src_f = os.path.join(root, f) 146 src_f = os.path.join(root, f)
142 dst_f = os.path.join(export_pkg_dir, root.replace(test_pkg_dir, "").lstrip("/"), f) 147 dst_f = os.path.join(export_pkg_dir, root.replace(test_pkg_dir, "").lstrip("/"), f)
143 shutil.copy2(src_f, dst_f) 148 shutil.copy2(src_f, dst_f)
144 149
150 if need_pkg_dir:
151 # 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)
153 else:
154 # Remov packages dir from exported test
155 bb.utils.remove(export_pkg_dir, True)
156
145 # Copy SDK 157 # Copy SDK
146 if d.getVar("TEST_EXPORT_SDK_ENABLED", True) == "1": 158 if d.getVar("TEST_EXPORT_SDK_ENABLED", True) == "1":
147 sdk_deploy = d.getVar("SDK_DEPLOY", True) 159 sdk_deploy = d.getVar("SDK_DEPLOY", True)
@@ -152,6 +164,9 @@ def exportTests(d,tc):
152 bb.utils.mkdirhier(export_sdk_dir) 164 bb.utils.mkdirhier(export_sdk_dir)
153 shutil.copy2(tarball_path, export_sdk_dir) 165 shutil.copy2(tarball_path, export_sdk_dir)
154 166
167 # Create tar file for the sdk
168 create_tarball(d, "testexport_sdk_%s.tar.gz" % d.getVar("SDK_ARCH", True), export_sdk_dir)
169
155 bb.plain("Exported tests to: %s" % exportpath) 170 bb.plain("Exported tests to: %s" % exportpath)
156 171
157def testexport_main(d): 172def testexport_main(d):
@@ -183,6 +198,23 @@ def testexport_main(d):
183 tc.extract_packages() 198 tc.extract_packages()
184 exportTests(d,tc) 199 exportTests(d,tc)
185 200
201def create_tarball(d, tar_name, src_dir):
202
203 import tarfile
204
205 tar_path = os.path.join(d.getVar("TEST_EXPORT_DIR", True), tar_name)
206 current_dir = os.getcwd()
207 src_dir = src_dir.rstrip('/')
208 dir_name = os.path.dirname(src_dir)
209 base_name = os.path.basename(src_dir)
210
211 os.chdir(dir_name)
212 tar = tarfile.open(tar_path, "w:gz")
213 tar.add(base_name)
214 tar.close()
215 os.chdir(current_dir)
216
217
186testexport_main[vardepsexclude] =+ "BB_ORIGENV" 218testexport_main[vardepsexclude] =+ "BB_ORIGENV"
187 219
188inherit testimage 220inherit testimage