diff options
author | Mariano Lopez <mariano.lopez@linux.intel.com> | 2016-06-06 09:15:54 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-06-07 15:22:38 +0100 |
commit | 2228b16bef534e337bc0f7c988b9f96dea7a3271 (patch) | |
tree | 0a8ad2b25014f1bd548192236ae32ee76407e060 | |
parent | 120f7067c802a02856d44c2c241da6c0f7fd5126 (diff) | |
download | poky-2228b16bef534e337bc0f7c988b9f96dea7a3271.tar.gz |
testexport.bbclass: Create tarballs for easy release
This create tarballs in the testexport directory in order
to make easier to distribute the test in another systems.
There are three tarballs, one for the metadata that is not
arch dependant, another for packages needed by the DUT
(this depends of target MACHINE), and the last one for the
SDK needed by the systems that perform the tests.
This also create only the tarballs that are needed.
[YOCTO #8481]
(From OE-Core rev: f8a0456e100b07a966cc24a78f197400c5a2ccab)
(From OE-Core rev: a91a603676b088abcb648cc558c33da6292b9be6)
Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/classes/testexport.bbclass | 32 |
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 | ||
157 | def testexport_main(d): | 172 | def 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 | ||
201 | def 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 | |||
186 | testexport_main[vardepsexclude] =+ "BB_ORIGENV" | 218 | testexport_main[vardepsexclude] =+ "BB_ORIGENV" |
187 | 219 | ||
188 | inherit testimage | 220 | inherit testimage |