summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/classes/testexport.bbclass16
-rwxr-xr-xmeta/lib/oeqa/runexported.py35
2 files changed, 50 insertions, 1 deletions
diff --git a/meta/classes/testexport.bbclass b/meta/classes/testexport.bbclass
index a3208806bc..6009349341 100644
--- a/meta/classes/testexport.bbclass
+++ b/meta/classes/testexport.bbclass
@@ -23,8 +23,14 @@ TEST_TARGET ?= "simpleremote"
23TEST_TARGET_IP ?= "" 23TEST_TARGET_IP ?= ""
24TEST_SERVER_IP ?= "" 24TEST_SERVER_IP ?= ""
25 25
26TEST_EXPORT_SDK_PACKAGES ?= ""
27TEST_EXPORT_SDK_ENABLED ?= "0"
28TEST_EXPORT_SDK_NAME ?= "testexport-tools-nativesdk"
29TEST_EXPORT_SDK_DIR ?= "sdk"
30
26TEST_EXPORT_DEPENDS = "" 31TEST_EXPORT_DEPENDS = ""
27TEST_EXPORT_DEPENDS += "${@bb.utils.contains('IMAGE_PKGTYPE', 'rpm', 'cpio-native:do_populate_sysroot', '', d)}" 32TEST_EXPORT_DEPENDS += "${@bb.utils.contains('IMAGE_PKGTYPE', 'rpm', 'cpio-native:do_populate_sysroot', '', d)}"
33TEST_EXPORT_DEPENDS += "${@bb.utils.contains('TEST_EXPORT_SDK_ENABLED', '1', 'testexport-tarball:do_populate_sdk', '', d)}"
28TEST_EXPORT_LOCK = "${TMPDIR}/testimage.lock" 34TEST_EXPORT_LOCK = "${TMPDIR}/testimage.lock"
29 35
30python do_testexport() { 36python do_testexport() {
@@ -136,6 +142,16 @@ def exportTests(d,tc):
136 dst_f = os.path.join(export_pkg_dir, root.replace(test_pkg_dir, "").lstrip("/"), f) 142 dst_f = os.path.join(export_pkg_dir, root.replace(test_pkg_dir, "").lstrip("/"), f)
137 shutil.copy2(src_f, dst_f) 143 shutil.copy2(src_f, dst_f)
138 144
145 # Copy SDK
146 if d.getVar("TEST_EXPORT_SDK_ENABLED", True) == "1":
147 sdk_deploy = d.getVar("SDK_DEPLOY", True)
148 tarball_name = "%s.sh" % d.getVar("TEST_EXPORT_SDK_NAME", True)
149 tarball_path = os.path.join(sdk_deploy, tarball_name)
150 export_sdk_dir = os.path.join(d.getVar("TEST_EXPORT_DIR", True),
151 d.getVar("TEST_EXPORT_SDK_DIR", True))
152 bb.utils.mkdirhier(export_sdk_dir)
153 shutil.copy2(tarball_path, export_sdk_dir)
154
139 bb.plain("Exported tests to: %s" % exportpath) 155 bb.plain("Exported tests to: %s" % exportpath)
140 156
141def testexport_main(d): 157def testexport_main(d):
diff --git a/meta/lib/oeqa/runexported.py b/meta/lib/oeqa/runexported.py
index f1366a63d3..58867393bb 100755
--- a/meta/lib/oeqa/runexported.py
+++ b/meta/lib/oeqa/runexported.py
@@ -31,8 +31,8 @@ except ImportError:
31sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "oeqa"))) 31sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "oeqa")))
32 32
33from oeqa.oetest import ExportTestContext 33from oeqa.oetest import ExportTestContext
34from oeqa.utils.commands import runCmd
34from oeqa.utils.sshcontrol import SSHControl 35from oeqa.utils.sshcontrol import SSHControl
35from oeqa.utils.dump import get_host_dumper
36 36
37# this isn't pretty but we need a fake target object 37# this isn't pretty but we need a fake target object
38# for running the tests externally as we don't care 38# for running the tests externally as we don't care
@@ -107,6 +107,8 @@ def main():
107 if not os.path.isdir(d["DEPLOY_DIR"]): 107 if not os.path.isdir(d["DEPLOY_DIR"]):
108 print("WARNING: The path to DEPLOY_DIR does not exist: %s" % d["DEPLOY_DIR"]) 108 print("WARNING: The path to DEPLOY_DIR does not exist: %s" % d["DEPLOY_DIR"])
109 109
110 extract_sdk(d)
111
110 target = FakeTarget(d) 112 target = FakeTarget(d)
111 for key in loaded["target"].keys(): 113 for key in loaded["target"].keys():
112 setattr(target, key, loaded["target"][key]) 114 setattr(target, key, loaded["target"][key])
@@ -118,6 +120,37 @@ def main():
118 120
119 return 0 121 return 0
120 122
123def extract_sdk(d):
124 """
125 Extract SDK if needed
126 """
127
128 export_dir = os.path.dirname(os.path.realpath(__file__))
129 tools_dir = d.getVar("TEST_EXPORT_SDK_DIR", True)
130 tarball_name = "%s.sh" % d.getVar("TEST_EXPORT_SDK_NAME", True)
131 tarball_path = os.path.join(export_dir, tools_dir, tarball_name)
132 extract_path = os.path.join(export_dir, "sysroot")
133 if os.path.isfile(tarball_path):
134 print ("Found SDK tarball %s. Extracting..." % tarball_path)
135 result = runCmd("%s -y -d %s" % (tarball_path, extract_path))
136 for f in os.listdir(extract_path):
137 if f.startswith("environment-setup"):
138 print("Setting up SDK environment...")
139 env_file = os.path.join(extract_path, f)
140 update_env(env_file)
141
142def update_env(env_file):
143 """
144 Source a file and update environment
145 """
146
147 cmd = ". %s; env -0" % env_file
148 result = runCmd(cmd)
149
150 for line in result.output.split("\0"):
151 (key, _, value) = line.partition("=")
152 os.environ[key] = value
153
121if __name__ == "__main__": 154if __name__ == "__main__":
122 try: 155 try:
123 ret = main() 156 ret = main()