aboutsummaryrefslogtreecommitdiffstats
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 15:51:03 +0000
commit51782e5f77cb3f32a31a221c6e0f9b33cf3a33c9 (patch)
tree5455cad8f38270f592139894789aaf3a740b4cb5 /meta/classes/testsdk.bbclass
parent03af7b99e3ce36ce3e29dc31e33d2cc74eb14849 (diff)
downloadopenembedded-core-51782e5f77cb3f32a31a221c6e0f9b33cf3a33c9.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. Signed-off-by: Aníbal Limón <limon.anibal@gmail.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
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 @@
TEST_LOG_DIR ?= "${WORKDIR}/testimage"
TESTSDKLOCK = "${TMPDIR}/testsdk.lock"
+def run_test_context(CTestContext, d, testdir, tcname, pn):
+ import glob
+ import time
+
+ targets = glob.glob(d.expand(testdir + "/tc/environment-setup-*"))
+ for sdkenv in targets:
+ bb.plain("Testing %s" % sdkenv)
+ tc = CTestContext(d, testdir, sdkenv)
+
+ # this is a dummy load of tests
+ # we are doing that to find compile errors in the tests themselves
+ # before booting the image
+ try:
+ tc.loadTests()
+ except Exception as e:
+ import traceback
+ bb.fatal("Loading tests failed:\n%s" % traceback.format_exc())
+
+ starttime = time.time()
+ result = tc.runTests()
+ stoptime = time.time()
+ if result.wasSuccessful():
+ 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))
+ msg = "%s - OK - All required tests passed" % pn
+ skipped = len(result.skipped)
+ if skipped:
+ msg += " (skipped=%d)" % skipped
+ bb.plain(msg)
+ else:
+ raise bb.build.FuncFailed("%s - FAILED - check the task log and the commands log" % pn )
+
def testsdk_main(d):
- import unittest
import os
- import glob
- import oeqa.runtime
import oeqa.sdk
- import time
import subprocess
from oeqa.oetest import SDKTestContext
@@ -31,32 +58,7 @@ def testsdk_main(d):
bb.fatal("Couldn't install the SDK:\n%s" % e.output)
try:
- targets = glob.glob(d.expand(sdktestdir + "/tc/environment-setup-*"))
- for sdkenv in targets:
- bb.plain("Testing %s" % sdkenv)
- tc = SDKTestContext(d, sdktestdir, sdkenv)
-
- # this is a dummy load of tests
- # we are doing that to find compile errors in the tests themselves
- # before booting the image
- try:
- tc.loadTests()
- except Exception as e:
- import traceback
- bb.fatal("Loading tests failed:\n%s" % traceback.format_exc())
-
- starttime = time.time()
- result = tc.runTests()
- stoptime = time.time()
- if result.wasSuccessful():
- 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))
- msg = "%s - OK - All required tests passed" % pn
- skipped = len(result.skipped)
- if skipped:
- msg += " (skipped=%d)" % skipped
- bb.plain(msg)
- else:
- raise bb.build.FuncFailed("%s - FAILED - check the task log and the commands log" % pn )
+ run_test_context(SDKTestContext, d, sdktestdir, tcname, pn)
finally:
bb.utils.remove(sdktestdir, True)