From 120f7067c802a02856d44c2c241da6c0f7fd5126 Mon Sep 17 00:00:00 2001 From: Mariano Lopez Date: Mon, 6 Jun 2016 07:15:44 +0000 Subject: testexport.bbclass: Add support for testexport-tarball Add support to export the SDK tarball needed when a test system doesn't have the required software to perform runtime tests. The support is when exporting the test and when running the test on a remote system. The user of this feature just need to set TEST_EXPORT_SDK_ENABLED to "1" and declare the sdk packages in TEST_EXPORT_SDK_PACKAGES. [YOCTO #7850] (From OE-Core rev: a6041f81b81baa7564e4c712fc88de2b997e52e4) (From OE-Core rev: 05e6c89f0f71311f8bd32cdb86a2deb789c58035) Signed-off-by: Mariano Lopez Signed-off-by: Richard Purdie --- meta/lib/oeqa/runexported.py | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'meta/lib') 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() -- cgit 1.2.3-korg