summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/runexported.py
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oeqa/runexported.py')
-rwxr-xr-xmeta/lib/oeqa/runexported.py65
1 files changed, 37 insertions, 28 deletions
diff --git a/meta/lib/oeqa/runexported.py b/meta/lib/oeqa/runexported.py
index dba0d7aec1..7e37213df6 100755
--- a/meta/lib/oeqa/runexported.py
+++ b/meta/lib/oeqa/runexported.py
@@ -1,9 +1,9 @@
-#!/usr/bin/env python
-
-
+#!/usr/bin/env python3
+#
# Copyright (C) 2013 Intel Corporation
#
-# Released under the MIT license (see COPYING.MIT)
+# SPDX-License-Identifier: MIT
+#
# This script should be used outside of the build system to run image tests.
# It needs a json file as input as exported by the build.
@@ -30,9 +30,9 @@ except ImportError:
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "oeqa")))
-from oeqa.oetest import runTests
+from oeqa.oetest import ExportTestContext
+from oeqa.utils.commands import runCmd, updateEnv
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
@@ -43,13 +43,13 @@ class FakeTarget(object):
self.ip = None
self.server_ip = None
self.datetime = time.strftime('%Y%m%d%H%M%S',time.gmtime())
- self.testdir = d.getVar("TEST_LOG_DIR", True)
- self.pn = d.getVar("PN", True)
+ self.testdir = d.getVar("TEST_LOG_DIR")
+ self.pn = d.getVar("PN")
def exportStart(self):
self.sshlog = os.path.join(self.testdir, "ssh_target_log.%s" % self.datetime)
sshloglink = os.path.join(self.testdir, "ssh_target_log")
- if os.path.exists(sshloglink):
+ if os.path.lexists(sshloglink):
os.remove(sshloglink)
os.symlink(self.sshlog, sshloglink)
print("SSH log file: %s" % self.sshlog)
@@ -69,11 +69,6 @@ class MyDataDict(dict):
def getVar(self, key, unused = None):
return self.get(key, "")
-class TestContext(object):
- def __init__(self):
- self.d = None
- self.target = None
-
def main():
parser = argparse.ArgumentParser()
@@ -86,6 +81,7 @@ def main():
specified in the json if that directory actually exists or it will error out.")
parser.add_argument("-l", "--log-dir", dest="log_dir", help="This sets the path for TEST_LOG_DIR. If not specified \
the current dir is used. This is used for usually creating a ssh log file and a scp test file.")
+ parser.add_argument("-a", "--tag", dest="tag", help="Only run test with specified tag.")
parser.add_argument("json", help="The json file exported by the build system", default="testdata.json", nargs='?')
args = parser.parse_args()
@@ -112,33 +108,46 @@ def main():
if not os.path.isdir(d["DEPLOY_DIR"]):
print("WARNING: The path to DEPLOY_DIR does not exist: %s" % d["DEPLOY_DIR"])
+ parsedArgs = {}
+ parsedArgs["tag"] = args.tag
+
+ extract_sdk(d)
target = FakeTarget(d)
for key in loaded["target"].keys():
setattr(target, key, loaded["target"][key])
- host_dumper = get_host_dumper(d)
- host_dumper.parent_dir = loaded["host_dumper"]["parent_dir"]
- host_dumper.cmds = loaded["host_dumper"]["cmds"]
-
- tc = TestContext()
- setattr(tc, "d", d)
- setattr(tc, "target", target)
- setattr(tc, "host_dumper", host_dumper)
- for key in loaded.keys():
- if key != "d" and key != "target" and key != "host_dumper":
- setattr(tc, key, loaded[key])
-
target.exportStart()
- runTests(tc)
+ tc = ExportTestContext(d, target, True, parsedArgs)
+ tc.loadTests()
+ tc.runTests()
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")
+ tarball_name = "%s.sh" % d.getVar("TEST_EXPORT_SDK_NAME")
+ 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)
+ updateEnv(env_file)
+
if __name__ == "__main__":
try:
ret = main()
except Exception:
ret = 1
import traceback
- traceback.print_exc(5)
+ traceback.print_exc()
sys.exit(ret)