summaryrefslogtreecommitdiff
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"
TEST_TARGET_IP ?= ""
TEST_SERVER_IP ?= ""
+TEST_EXPORT_SDK_PACKAGES ?= ""
+TEST_EXPORT_SDK_ENABLED ?= "0"
+TEST_EXPORT_SDK_NAME ?= "testexport-tools-nativesdk"
+TEST_EXPORT_SDK_DIR ?= "sdk"
+
TEST_EXPORT_DEPENDS = ""
TEST_EXPORT_DEPENDS += "${@bb.utils.contains('IMAGE_PKGTYPE', 'rpm', 'cpio-native:do_populate_sysroot', '', d)}"
+TEST_EXPORT_DEPENDS += "${@bb.utils.contains('TEST_EXPORT_SDK_ENABLED', '1', 'testexport-tarball:do_populate_sdk', '', d)}"
TEST_EXPORT_LOCK = "${TMPDIR}/testimage.lock"
python do_testexport() {
@@ -136,6 +142,16 @@ def exportTests(d,tc):
dst_f = os.path.join(export_pkg_dir, root.replace(test_pkg_dir, "").lstrip("/"), f)
shutil.copy2(src_f, dst_f)
+ # Copy SDK
+ if d.getVar("TEST_EXPORT_SDK_ENABLED", True) == "1":
+ sdk_deploy = d.getVar("SDK_DEPLOY", True)
+ tarball_name = "%s.sh" % d.getVar("TEST_EXPORT_SDK_NAME", True)
+ tarball_path = os.path.join(sdk_deploy, tarball_name)
+ export_sdk_dir = os.path.join(d.getVar("TEST_EXPORT_DIR", True),
+ d.getVar("TEST_EXPORT_SDK_DIR", True))
+ bb.utils.mkdirhier(export_sdk_dir)
+ shutil.copy2(tarball_path, export_sdk_dir)
+
bb.plain("Exported tests to: %s" % exportpath)
def 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:
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "oeqa")))
from oeqa.oetest import ExportTestContext
+from oeqa.utils.commands import runCmd
from oeqa.utils.sshcontrol import SSHControl
-from oeqa.utils.dump import get_host_dumper
# this isn't pretty but we need a fake target object
# for running the tests externally as we don't care
@@ -107,6 +107,8 @@ def main():
if not os.path.isdir(d["DEPLOY_DIR"]):
print("WARNING: The path to DEPLOY_DIR does not exist: %s" % d["DEPLOY_DIR"])
+ extract_sdk(d)
+
target = FakeTarget(d)
for key in loaded["target"].keys():
setattr(target, key, loaded["target"][key])
@@ -118,6 +120,37 @@ def main():
return 0
+def extract_sdk(d):
+ """
+ Extract SDK if needed
+ """
+
+ export_dir = os.path.dirname(os.path.realpath(__file__))
+ tools_dir = d.getVar("TEST_EXPORT_SDK_DIR", True)
+ tarball_name = "%s.sh" % d.getVar("TEST_EXPORT_SDK_NAME", True)
+ tarball_path = os.path.join(export_dir, tools_dir, tarball_name)
+ extract_path = os.path.join(export_dir, "sysroot")
+ if os.path.isfile(tarball_path):
+ print ("Found SDK tarball %s. Extracting..." % tarball_path)
+ result = runCmd("%s -y -d %s" % (tarball_path, extract_path))
+ for f in os.listdir(extract_path):
+ if f.startswith("environment-setup"):
+ print("Setting up SDK environment...")
+ env_file = os.path.join(extract_path, f)
+ update_env(env_file)
+
+def update_env(env_file):
+ """
+ Source a file and update environment
+ """
+
+ cmd = ". %s; env -0" % env_file
+ result = runCmd(cmd)
+
+ for line in result.output.split("\0"):
+ (key, _, value) = line.partition("=")
+ os.environ[key] = value
+
if __name__ == "__main__":
try:
ret = main()