diff options
Diffstat (limited to 'meta/classes')
-rw-r--r-- | meta/classes/testexport.bbclass | 33 | ||||
-rw-r--r-- | meta/classes/testimage.bbclass | 18 |
2 files changed, 46 insertions, 5 deletions
diff --git a/meta/classes/testexport.bbclass b/meta/classes/testexport.bbclass index c86eaac197..8046e29655 100644 --- a/meta/classes/testexport.bbclass +++ b/meta/classes/testexport.bbclass | |||
@@ -16,6 +16,9 @@ | |||
16 | 16 | ||
17 | TEST_LOG_DIR ?= "${WORKDIR}/testexport" | 17 | TEST_LOG_DIR ?= "${WORKDIR}/testexport" |
18 | TEST_EXPORT_DIR ?= "${TMPDIR}/testexport/${PN}" | 18 | TEST_EXPORT_DIR ?= "${TMPDIR}/testexport/${PN}" |
19 | TEST_EXPORT_PACKAGED_DIR ?= "packages/packaged" | ||
20 | TEST_EXPORT_EXTRACTED_DIR ?= "packages/extracted" | ||
21 | |||
19 | TEST_TARGET ?= "simpleremote" | 22 | TEST_TARGET ?= "simpleremote" |
20 | TEST_TARGET_IP ?= "" | 23 | TEST_TARGET_IP ?= "" |
21 | TEST_SERVER_IP ?= "" | 24 | TEST_SERVER_IP ?= "" |
@@ -28,9 +31,9 @@ python do_testexport() { | |||
28 | } | 31 | } |
29 | 32 | ||
30 | addtask testexport | 33 | addtask testexport |
31 | do_testimage[nostamp] = "1" | 34 | do_testexport[nostamp] = "1" |
32 | do_testimage[depends] += "${TEST_EXPORT_DEPENDS}" | 35 | do_testexport[depends] += "${TEST_EXPORT_DEPENDS} ${TESTIMAGEDEPENDS}" |
33 | do_testimage[lockfiles] += "${TEST_EXPORT_LOCK}" | 36 | do_testexport[lockfiles] += "${TEST_EXPORT_LOCK}" |
34 | 37 | ||
35 | def exportTests(d,tc): | 38 | def exportTests(d,tc): |
36 | import json | 39 | import json |
@@ -96,6 +99,9 @@ def exportTests(d,tc): | |||
96 | shutil.copytree(foldername, target_folder) | 99 | shutil.copytree(foldername, target_folder) |
97 | if not isfolder: | 100 | if not isfolder: |
98 | shutil.copy2(mod.path, os.path.join(exportpath, "oeqa/runtime")) | 101 | shutil.copy2(mod.path, os.path.join(exportpath, "oeqa/runtime")) |
102 | json_file = "%s.json" % mod.path.rsplit(".", 1)[0] | ||
103 | if os.path.isfile(json_file): | ||
104 | shutil.copy2(json_file, os.path.join(exportpath, "oeqa/runtime")) | ||
99 | # Get meta layer | 105 | # Get meta layer |
100 | for layer in d.getVar("BBLAYERS", True).split(): | 106 | for layer in d.getVar("BBLAYERS", True).split(): |
101 | if os.path.basename(layer) == "meta": | 107 | if os.path.basename(layer) == "meta": |
@@ -115,6 +121,20 @@ def exportTests(d,tc): | |||
115 | for f in files: | 121 | for f in files: |
116 | shutil.copy2(os.path.join(root, f), os.path.join(exportpath, "oeqa/runtime/files")) | 122 | shutil.copy2(os.path.join(root, f), os.path.join(exportpath, "oeqa/runtime/files")) |
117 | 123 | ||
124 | # Copy packages needed for runtime testing | ||
125 | export_pkg_dir = os.path.join(d.getVar("TEST_EXPORT_DIR", True), "packages") | ||
126 | test_pkg_dir = d.getVar("TEST_NEEDED_PACKAGES_DIR", True) | ||
127 | for root, subdirs, files in os.walk(test_pkg_dir): | ||
128 | for subdir in subdirs: | ||
129 | tmp_dir = os.path.join(root.replace(test_pkg_dir, "").lstrip("/"), subdir) | ||
130 | new_dir = os.path.join(export_pkg_dir, tmp_dir) | ||
131 | bb.utils.mkdirhier(new_dir) | ||
132 | |||
133 | for f in files: | ||
134 | src_f = os.path.join(root, f) | ||
135 | dst_f = os.path.join(export_pkg_dir, root.replace(test_pkg_dir, "").lstrip("/"), f) | ||
136 | shutil.copy2(src_f, dst_f) | ||
137 | |||
118 | bb.plain("Exported tests to: %s" % exportpath) | 138 | bb.plain("Exported tests to: %s" % exportpath) |
119 | 139 | ||
120 | def testexport_main(d): | 140 | def testexport_main(d): |
@@ -122,9 +142,11 @@ def testexport_main(d): | |||
122 | from oeqa.targetcontrol import get_target_controller | 142 | from oeqa.targetcontrol import get_target_controller |
123 | from oeqa.utils.dump import get_host_dumper | 143 | from oeqa.utils.dump import get_host_dumper |
124 | 144 | ||
145 | test_create_extract_dirs(d) | ||
146 | export_dir = d.getVar("TEST_EXPORT_DIR", True) | ||
125 | bb.utils.mkdirhier(d.getVar("TEST_LOG_DIR", True)) | 147 | bb.utils.mkdirhier(d.getVar("TEST_LOG_DIR", True)) |
126 | bb.utils.remove(d.getVar("TEST_EXPORT_DIR", True), recurse=True) | 148 | bb.utils.remove(export_dir, recurse=True) |
127 | bb.utils.mkdirhier(d.getVar("TEST_EXPORT_DIR", True)) | 149 | bb.utils.mkdirhier(export_dir) |
128 | 150 | ||
129 | # the robot dance | 151 | # the robot dance |
130 | target = get_target_controller(d) | 152 | target = get_target_controller(d) |
@@ -141,6 +163,7 @@ def testexport_main(d): | |||
141 | import traceback | 163 | import traceback |
142 | bb.fatal("Loading tests failed:\n%s" % traceback.format_exc()) | 164 | bb.fatal("Loading tests failed:\n%s" % traceback.format_exc()) |
143 | 165 | ||
166 | tc.extract_packages() | ||
144 | exportTests(d,tc) | 167 | exportTests(d,tc) |
145 | 168 | ||
146 | testexport_main[vardepsexclude] =+ "BB_ORIGENV" | 169 | testexport_main[vardepsexclude] =+ "BB_ORIGENV" |
diff --git a/meta/classes/testimage.bbclass b/meta/classes/testimage.bbclass index a2e13df710..a70d3a885e 100644 --- a/meta/classes/testimage.bbclass +++ b/meta/classes/testimage.bbclass | |||
@@ -30,6 +30,10 @@ | |||
30 | TEST_LOG_DIR ?= "${WORKDIR}/testimage" | 30 | TEST_LOG_DIR ?= "${WORKDIR}/testimage" |
31 | 31 | ||
32 | TEST_EXPORT_DIR ?= "${TMPDIR}/testimage/${PN}" | 32 | TEST_EXPORT_DIR ?= "${TMPDIR}/testimage/${PN}" |
33 | TEST_INSTALL_TMP_DIR ?= "${WORKDIR}/testimage/install_tmp" | ||
34 | TEST_NEEDED_PACKAGES_DIR ?= "${WORKDIR}/testimage/packages" | ||
35 | TEST_EXTRACTED_DIR ?= "${TEST_NEEDED_PACKAGES_DIR}/extracted" | ||
36 | TEST_PACKAGED_DIR ?= "${TEST_NEEDED_PACKAGES_DIR}/packaged" | ||
33 | 37 | ||
34 | RPMTESTSUITE = "${@bb.utils.contains('IMAGE_PKGTYPE', 'rpm', 'smart rpm', '', d)}" | 38 | RPMTESTSUITE = "${@bb.utils.contains('IMAGE_PKGTYPE', 'rpm', 'smart rpm', '', d)}" |
35 | MINTESTSUITE = "ping" | 39 | MINTESTSUITE = "ping" |
@@ -100,6 +104,7 @@ testimage_dump_host () { | |||
100 | python do_testimage() { | 104 | python do_testimage() { |
101 | testimage_main(d) | 105 | testimage_main(d) |
102 | } | 106 | } |
107 | |||
103 | addtask testimage | 108 | addtask testimage |
104 | do_testimage[nostamp] = "1" | 109 | do_testimage[nostamp] = "1" |
105 | do_testimage[depends] += "${TESTIMAGEDEPENDS}" | 110 | do_testimage[depends] += "${TESTIMAGEDEPENDS}" |
@@ -117,6 +122,7 @@ def testimage_main(d): | |||
117 | 122 | ||
118 | pn = d.getVar("PN", True) | 123 | pn = d.getVar("PN", True) |
119 | bb.utils.mkdirhier(d.getVar("TEST_LOG_DIR", True)) | 124 | bb.utils.mkdirhier(d.getVar("TEST_LOG_DIR", True)) |
125 | test_create_extract_dirs(d) | ||
120 | 126 | ||
121 | # we need the host dumper in test context | 127 | # we need the host dumper in test context |
122 | host_dumper = get_host_dumper(d) | 128 | host_dumper = get_host_dumper(d) |
@@ -136,6 +142,7 @@ def testimage_main(d): | |||
136 | import traceback | 142 | import traceback |
137 | bb.fatal("Loading tests failed:\n%s" % traceback.format_exc()) | 143 | bb.fatal("Loading tests failed:\n%s" % traceback.format_exc()) |
138 | 144 | ||
145 | tc.extract_packages() | ||
139 | target.deploy() | 146 | target.deploy() |
140 | try: | 147 | try: |
141 | target.start() | 148 | target.start() |
@@ -155,6 +162,17 @@ def testimage_main(d): | |||
155 | signal.signal(signal.SIGTERM, tc.origsigtermhandler) | 162 | signal.signal(signal.SIGTERM, tc.origsigtermhandler) |
156 | target.stop() | 163 | target.stop() |
157 | 164 | ||
165 | def test_create_extract_dirs(d): | ||
166 | install_path = d.getVar("TEST_INSTALL_TMP_DIR", True) | ||
167 | package_path = d.getVar("TEST_PACKAGED_DIR", True) | ||
168 | extracted_path = d.getVar("TEST_EXTRACTED_DIR", True) | ||
169 | bb.utils.mkdirhier(d.getVar("TEST_LOG_DIR", True)) | ||
170 | bb.utils.remove(package_path, recurse=True) | ||
171 | bb.utils.mkdirhier(install_path) | ||
172 | bb.utils.mkdirhier(package_path) | ||
173 | bb.utils.mkdirhier(extracted_path) | ||
174 | |||
175 | |||
158 | testimage_main[vardepsexclude] =+ "BB_ORIGENV" | 176 | testimage_main[vardepsexclude] =+ "BB_ORIGENV" |
159 | 177 | ||
160 | inherit testsdk | 178 | inherit testsdk |