summaryrefslogtreecommitdiffstats
path: root/meta/classes/testsdk.bbclass
diff options
context:
space:
mode:
authorAníbal Limón <limon.anibal@gmail.com>2016-01-30 19:58:29 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-02-10 16:06:23 +0000
commitf3c2ce27390b008b210cc439b8130942eb380ce9 (patch)
tree03be07863b8450752941dcd4e5f3fa5c99c42067 /meta/classes/testsdk.bbclass
parent3577c35f6e09112b795b0cbc12c21911815568a6 (diff)
downloadpoky-f3c2ce27390b008b210cc439b8130942eb380ce9.tar.gz
classes/testsdk: Add function run_test_context
This helper functions will be serve as well to run extensible sdk tests so generalize it to get function context as arg. (From OE-Core rev: 51782e5f77cb3f32a31a221c6e0f9b33cf3a33c9) Signed-off-by: Aníbal Limón <limon.anibal@gmail.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/testsdk.bbclass')
-rw-r--r--meta/classes/testsdk.bbclass62
1 files changed, 32 insertions, 30 deletions
diff --git a/meta/classes/testsdk.bbclass b/meta/classes/testsdk.bbclass
index ba8897e5ea..88057e5a2e 100644
--- a/meta/classes/testsdk.bbclass
+++ b/meta/classes/testsdk.bbclass
@@ -5,13 +5,40 @@
5TEST_LOG_DIR ?= "${WORKDIR}/testimage" 5TEST_LOG_DIR ?= "${WORKDIR}/testimage"
6TESTSDKLOCK = "${TMPDIR}/testsdk.lock" 6TESTSDKLOCK = "${TMPDIR}/testsdk.lock"
7 7
8def run_test_context(CTestContext, d, testdir, tcname, pn):
9 import glob
10 import time
11
12 targets = glob.glob(d.expand(testdir + "/tc/environment-setup-*"))
13 for sdkenv in targets:
14 bb.plain("Testing %s" % sdkenv)
15 tc = CTestContext(d, testdir, sdkenv)
16
17 # this is a dummy load of tests
18 # we are doing that to find compile errors in the tests themselves
19 # before booting the image
20 try:
21 tc.loadTests()
22 except Exception as e:
23 import traceback
24 bb.fatal("Loading tests failed:\n%s" % traceback.format_exc())
25
26 starttime = time.time()
27 result = tc.runTests()
28 stoptime = time.time()
29 if result.wasSuccessful():
30 bb.plain("%s SDK(%s):%s - Ran %d test%s in %.3fs" % (pn, os.path.basename(tcname), os.path.basename(sdkenv),result.testsRun, result.testsRun != 1 and "s" or "", stoptime - starttime))
31 msg = "%s - OK - All required tests passed" % pn
32 skipped = len(result.skipped)
33 if skipped:
34 msg += " (skipped=%d)" % skipped
35 bb.plain(msg)
36 else:
37 raise bb.build.FuncFailed("%s - FAILED - check the task log and the commands log" % pn )
38
8def testsdk_main(d): 39def testsdk_main(d):
9 import unittest
10 import os 40 import os
11 import glob
12 import oeqa.runtime
13 import oeqa.sdk 41 import oeqa.sdk
14 import time
15 import subprocess 42 import subprocess
16 from oeqa.oetest import SDKTestContext 43 from oeqa.oetest import SDKTestContext
17 44
@@ -31,32 +58,7 @@ def testsdk_main(d):
31 bb.fatal("Couldn't install the SDK:\n%s" % e.output) 58 bb.fatal("Couldn't install the SDK:\n%s" % e.output)
32 59
33 try: 60 try:
34 targets = glob.glob(d.expand(sdktestdir + "/tc/environment-setup-*")) 61 run_test_context(SDKTestContext, d, sdktestdir, tcname, pn)
35 for sdkenv in targets:
36 bb.plain("Testing %s" % sdkenv)
37 tc = SDKTestContext(d, sdktestdir, sdkenv)
38
39 # this is a dummy load of tests
40 # we are doing that to find compile errors in the tests themselves
41 # before booting the image
42 try:
43 tc.loadTests()
44 except Exception as e:
45 import traceback
46 bb.fatal("Loading tests failed:\n%s" % traceback.format_exc())
47
48 starttime = time.time()
49 result = tc.runTests()
50 stoptime = time.time()
51 if result.wasSuccessful():
52 bb.plain("%s SDK(%s):%s - Ran %d test%s in %.3fs" % (pn, os.path.basename(tcname), os.path.basename(sdkenv),result.testsRun, result.testsRun != 1 and "s" or "", stoptime - starttime))
53 msg = "%s - OK - All required tests passed" % pn
54 skipped = len(result.skipped)
55 if skipped:
56 msg += " (skipped=%d)" % skipped
57 bb.plain(msg)
58 else:
59 raise bb.build.FuncFailed("%s - FAILED - check the task log and the commands log" % pn )
60 finally: 62 finally:
61 bb.utils.remove(sdktestdir, True) 63 bb.utils.remove(sdktestdir, True)
62 64