summaryrefslogtreecommitdiffstats
path: root/meta/classes
diff options
context:
space:
mode:
authorAníbal Limón <anibal.limon@linux.intel.com>2016-11-30 10:56:09 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-01-23 12:05:19 +0000
commit92c57a5db7848edc993b3d9450c473f6e8861224 (patch)
tree7470504cf147dec04741e83146ae645389fb6f8f /meta/classes
parent8a37763ae9e5b8bfa4ed89c2ab8642b8f5bfc287 (diff)
downloadpoky-92c57a5db7848edc993b3d9450c473f6e8861224.tar.gz
classes/testsdk: Migrates testsdk.bbclass to use new OESDKTestContext
The functionality provided is the same with imporvements on code reuse and better interfaces. (From OE-Core rev: 7a1ae3149965b162fb2c71fc7067e07a7a189249) Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes')
-rw-r--r--meta/classes/testsdk.bbclass75
1 files changed, 60 insertions, 15 deletions
diff --git a/meta/classes/testsdk.bbclass b/meta/classes/testsdk.bbclass
index 063b9080a5..7304129b49 100644
--- a/meta/classes/testsdk.bbclass
+++ b/meta/classes/testsdk.bbclass
@@ -50,30 +50,75 @@ def run_test_context(CTestContext, d, testdir, tcname, pn, *args):
50 50
51def testsdk_main(d): 51def testsdk_main(d):
52 import os 52 import os
53 import oeqa.sdk
54 import subprocess 53 import subprocess
55 from oeqa.oetest import SDKTestContext 54 import json
55 import logging
56 56
57 pn = d.getVar("PN") 57 from bb.utils import export_proxies
58 bb.utils.mkdirhier(d.getVar("TEST_LOG_DIR")) 58 from oeqa.core.runner import OEStreamLogger
59 from oeqa.sdk.context import OESDKTestContext, OESDKTestContextExecutor
60 from oeqa.utils import make_logger_bitbake_compatible
61
62 pn = d.getVar("PN", True)
63 logger = make_logger_bitbake_compatible(logging.getLogger("BitBake"))
64
65 # sdk use network for download projects for build
66 export_proxies(d)
67
68 test_log_dir = d.getVar("TEST_LOG_DIR", True)
69
70 bb.utils.mkdirhier(test_log_dir)
59 71
60 tcname = d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.sh") 72 tcname = d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.sh")
61 if not os.path.exists(tcname): 73 if not os.path.exists(tcname):
62 bb.fatal("The toolchain %s is not built. Build it before running the tests: 'bitbake <image> -c populate_sdk' ." % tcname) 74 bb.fatal("The toolchain %s is not built. Build it before running the tests: 'bitbake <image> -c populate_sdk' ." % tcname)
63 75
64 sdktestdir = d.expand("${WORKDIR}/testimage-sdk/") 76 tdname = d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.testdata.json")
65 bb.utils.remove(sdktestdir, True) 77 test_data = json.load(open(tdname, "r"))
66 bb.utils.mkdirhier(sdktestdir) 78 test_data['TEST_LOG_DIR'] = test_log_dir
79
80 target_pkg_manifest = OESDKTestContextExecutor._load_manifest(
81 d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.target.manifest"))
82 host_pkg_manifest = OESDKTestContextExecutor._load_manifest(
83 d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.host.manifest"))
84
85 sdk_dir = d.expand("${WORKDIR}/testimage-sdk/")
86 bb.utils.remove(sdk_dir, True)
87 bb.utils.mkdirhier(sdk_dir)
67 try: 88 try:
68 subprocess.check_output("cd %s; %s <<EOF\n./tc\nY\nEOF" % (sdktestdir, tcname), shell=True) 89 subprocess.check_output("cd %s; %s <<EOF\n./\nY\nEOF" % (sdk_dir, tcname), shell=True)
69 except subprocess.CalledProcessError as e: 90 except subprocess.CalledProcessError as e:
70 bb.fatal("Couldn't install the SDK:\n%s" % e.output.decode("utf-8")) 91 bb.fatal("Couldn't install the SDK:\n%s" % e.output.decode("utf-8"))
71 92
72 try: 93 fail = False
73 run_test_context(SDKTestContext, d, sdktestdir, tcname, pn) 94 sdk_envs = OESDKTestContextExecutor._get_sdk_environs(sdk_dir)
74 finally: 95 for s in sdk_envs:
75 bb.utils.remove(sdktestdir, True) 96 sdk_env = sdk_envs[s]
97 bb.plain("SDK testing environment: %s" % s)
98 tc = OESDKTestContext(td=test_data, logger=logger, sdk_dir=sdk_dir,
99 sdk_env=sdk_env, target_pkg_manifest=target_pkg_manifest,
100 host_pkg_manifest=host_pkg_manifest)
76 101
102 try:
103 tc.loadTests(OESDKTestContextExecutor.default_cases)
104 except Exception as e:
105 import traceback
106 bb.fatal("Loading tests failed:\n%s" % traceback.format_exc())
107
108 result = tc.runTests()
109
110 component = "%s %s" % (pn, OESDKTestContextExecutor.name)
111 context_msg = "%s:%s" % (os.path.basename(tcname), os.path.basename(sdk_env))
112
113 tc.logSummary(result, component, context_msg)
114 tc.logDetails()
115
116 if not result.wasSuccessful():
117 fail = True
118
119 if fail:
120 bb.fatal("%s - FAILED - check the task log and the commands log" % pn)
121
77testsdk_main[vardepsexclude] =+ "BB_ORIGENV" 122testsdk_main[vardepsexclude] =+ "BB_ORIGENV"
78 123
79python do_testsdk() { 124python do_testsdk() {
@@ -88,13 +133,13 @@ TESTSDKEXTLOCK = "${TMPDIR}/testsdkext.lock"
88 133
89def testsdkext_main(d): 134def testsdkext_main(d):
90 import os 135 import os
91 import oeqa.sdkext 136 import json
92 import subprocess 137 import subprocess
138 import logging
139
93 from bb.utils import export_proxies 140 from bb.utils import export_proxies
94 from oeqa.oetest import SDKTestContext, SDKExtTestContext
95 from oeqa.utils import avoid_paths_in_environ 141 from oeqa.utils import avoid_paths_in_environ
96 142
97
98 # extensible sdk use network 143 # extensible sdk use network
99 export_proxies(d) 144 export_proxies(d)
100 145