[OE-core] [PATCH 4/4] meta: modify runexported script to inherit the features from baserunner
jwang
jing.j.wang at intel.com
Tue Sep 13 01:17:35 UTC 2016
From: zjh <junhuix.zhang at intel.com>
Signed-off-by: zjh <junhuix.zhang at intel.com>
---
meta/classes/testexport.bbclass | 2 ++
meta/lib/base/baserunner.py | 21 ++++++++++++++++++++-
meta/lib/oeqa/runexported.py | 12 +++++++++++-
3 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/meta/classes/testexport.bbclass b/meta/classes/testexport.bbclass
index 15fa470..c65ad55 100644
--- a/meta/classes/testexport.bbclass
+++ b/meta/classes/testexport.bbclass
@@ -128,6 +128,8 @@ def exportTests(d,tc):
for f in files:
shutil.copy2(os.path.join(root, f), os.path.join(exportpath, "oeqa/runtime/files"))
+ # copy base*
+ shutil.copytree(os.path.join(meta_layer, "lib", "base"), os.path.join(exportpath, "base"))
# Create tar file for common parts of testexport
create_tarball(d, "testexport.tar.gz", d.getVar("TEST_EXPORT_DIR", True))
diff --git a/meta/lib/base/baserunner.py b/meta/lib/base/baserunner.py
index d59872f..9b38f1b 100755
--- a/meta/lib/base/baserunner.py
+++ b/meta/lib/base/baserunner.py
@@ -57,9 +57,28 @@ class TestRunnerBase(object):
def configure(self, options=FakeOptions()):
'''configure before testing'''
self.test_options = options
- self.runner = unittest.TextTestRunner(stream=sys.stderr, \
+ if options.xunit:
+ try:
+ from xmlrunner import XMLTestRunner
+ except ImportError:
+ raise Exception("unittest-xml-reporting not installed")
+ self.runner = XMLTestRunner(stream=sys.stderr, \
+ verbosity=2, output=options.xunit)
+ else:
+ self.runner = unittest.TextTestRunner(stream=sys.stderr, \
verbosity=2)
+ if options.manifest:
+ fbname, fext = os.path.splitext(os.path.basename(options.manifest))
+ assert fbname == "manifest" or fext == ".manifest", \
+ "Please specify file name like xxx.manifest or manifest.xxx"
+ self.tclist = self.get_tc_from_manifest(options.manifest)
+
+ if options.tests:
+ tcs = [t[0:-3] if t.endswith(".py") else t[0:-1] \
+ if t.endswith("/") else t for t in options.tests]
+ self.tclist.extend([tc.replace("/", ".") for tc in tcs])
+
def result(self):
'''output test result '''
return self.test_result
diff --git a/meta/lib/oeqa/runexported.py b/meta/lib/oeqa/runexported.py
index 5886739..18e9543 100755
--- a/meta/lib/oeqa/runexported.py
+++ b/meta/lib/oeqa/runexported.py
@@ -69,6 +69,9 @@ class MyDataDict(dict):
def getVar(self, key, unused = None):
return self.get(key, "")
+class RunExportTestContext(ExportTestContext):
+ _configure_in_init = False
+
def main():
parser = argparse.ArgumentParser()
@@ -81,6 +84,12 @@ 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("-f", "--manifest", dest="manifest",
+ help="The test list file"),
+ parser.add_argument("-x", "--xunit", dest="xunit",
+ help="Output result path of in xUnit XML format"),
+ parser.add_argument("-e", "--tests", dest="tests", action="append",
+ help="Run tests by dot separated module path"),
parser.add_argument("json", help="The json file exported by the build system", default="testdata.json", nargs='?')
args = parser.parse_args()
@@ -114,7 +123,8 @@ def main():
setattr(target, key, loaded["target"][key])
target.exportStart()
- tc = ExportTestContext(d, target, True)
+ tc = RunExportTestContext(d, target, True)
+ tc.configure(args)
tc.loadTests()
tc.runTests()
--
2.1.4
More information about the Openembedded-core
mailing list