mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #1139 from PrzemekWirkus/devel_interoperability
Tools: Interoperability test suite: Added simple interface chip tests / checks I'm merging this pull request, we can add more interoperability tests in the future. For now we can use this is CI. I'm expecting some issues with this but this is not essential functionality and we can always improve it in the future.pull/1221/head
commit
af7630d525
|
@ -0,0 +1,16 @@
|
|||
"""
|
||||
mbed SDK
|
||||
Copyright (c) 2011-2015 ARM Limited
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
|
@ -0,0 +1,69 @@
|
|||
"""
|
||||
mbed SDK
|
||||
Copyright (c) 2011-2015 ARM Limited
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
Author: Przemyslaw Wirkus <Przemyslaw.Wirkus@arm.com>
|
||||
|
||||
"""
|
||||
|
||||
import sys
|
||||
|
||||
try:
|
||||
from colorama import Fore
|
||||
except:
|
||||
pass
|
||||
|
||||
COLORAMA = 'colorama' in sys.modules
|
||||
|
||||
|
||||
class IOperTestCaseBase():
|
||||
""" Interoperability test case base class
|
||||
@return list of tuple (severity, Description)
|
||||
Example: (result.append((IOperTestSeverity.INFO, ""))
|
||||
"""
|
||||
|
||||
def __init__(self, scope=None):
|
||||
self.PASS = 'PASS'
|
||||
self.INFO = 'INFO'
|
||||
self.ERROR = 'ERROR'
|
||||
self.WARN = 'WARN'
|
||||
|
||||
self.scope = scope # Default test scope (basic, pedantic, mbed-enabled etc...)
|
||||
|
||||
def test(self, param=None):
|
||||
result = []
|
||||
return result
|
||||
|
||||
def RED(self, text):
|
||||
return self.color_text(text, color=Fore.RED, delim=Fore.RESET) if COLORAMA else text
|
||||
|
||||
def GREEN(self, text):
|
||||
return self.color_text(text, color=Fore.GREEN, delim=Fore.RESET) if COLORAMA else text
|
||||
|
||||
def YELLOW(self, text):
|
||||
return self.color_text(text, color=Fore.YELLOW, delim=Fore.RESET) if COLORAMA else text
|
||||
|
||||
def color_text(self, text, color='', delim=''):
|
||||
return color + text + color + delim
|
||||
|
||||
def COLOR(self, severity, text):
|
||||
colors = {
|
||||
self.PASS : self.GREEN,
|
||||
self.ERROR : self.RED,
|
||||
self.WARN : self.YELLOW
|
||||
}
|
||||
if severity in colors:
|
||||
return colors[severity](text)
|
||||
return text
|
|
@ -0,0 +1,125 @@
|
|||
#!/usr/bin/env python2
|
||||
"""
|
||||
mbed SDK
|
||||
Copyright (c) 2011-2015 ARM Limited
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
Author: Przemyslaw Wirkus <Przemyslaw.Wirkus@arm.com>
|
||||
|
||||
"""
|
||||
|
||||
import sys
|
||||
import mbed_lstools
|
||||
from prettytable import PrettyTable
|
||||
|
||||
try:
|
||||
from colorama import init
|
||||
except:
|
||||
pass
|
||||
|
||||
COLORAMA = 'colorama' in sys.modules
|
||||
|
||||
from ioper_base import IOperTestCaseBase
|
||||
from ioper_test_fs import IOperTest_FileStructure_Basic
|
||||
from ioper_test_fs import IOperTest_FileStructure_MbedEnabled
|
||||
from ioper_test_target_id import IOperTest_TargetID_Basic
|
||||
from ioper_test_target_id import IOperTest_TargetID_MbedEnabled
|
||||
|
||||
|
||||
TEST_LIST = [IOperTest_TargetID_Basic('basic'),
|
||||
IOperTest_TargetID_MbedEnabled('mbed-enabled'),
|
||||
IOperTest_FileStructure_Basic('basic'),
|
||||
IOperTest_FileStructure_MbedEnabled('mbed-enabled'),
|
||||
IOperTestCaseBase('all'), # Dummy used to add 'all' option
|
||||
]
|
||||
|
||||
|
||||
class IOperTestRunner():
|
||||
""" Calls all i/face interoperability tests
|
||||
"""
|
||||
|
||||
def __init__(self, scope=None):
|
||||
""" Test scope:
|
||||
'pedantic' - all
|
||||
'mbed-enabled' - let's try to check if this device is mbed-enabled
|
||||
'basic' - just simple, passive tests (no device flashing)
|
||||
"""
|
||||
self.requested_scope = scope # Test scope given by user
|
||||
self.raw_test_results = {} # Raw test results, can be used by exporters: { Platform: [test results]}
|
||||
|
||||
# Test scope definitions
|
||||
self.SCOPE_BASIC = 'basic' # Basic tests, sanity checks
|
||||
self.SCOPE_MBED_ENABLED = 'mbed-enabled' # Let's try to check if this device is mbed-enabled
|
||||
self.SCOPE_PEDANTIC = 'pedantic' # Extensive tests
|
||||
self.SCOPE_ALL = 'all' # All tests, equal to highest scope level
|
||||
|
||||
# This structure will help us sort test scopes so we can include them
|
||||
# e.g. pedantic also includes basic and mbed-enabled tests
|
||||
self.scopes = {self.SCOPE_BASIC : 0,
|
||||
self.SCOPE_MBED_ENABLED : 1,
|
||||
self.SCOPE_PEDANTIC : 2,
|
||||
self.SCOPE_ALL : 99,
|
||||
}
|
||||
|
||||
if COLORAMA:
|
||||
init() # colorama.init()
|
||||
|
||||
def run(self):
|
||||
""" Run tests, calculate overall score and print test results
|
||||
"""
|
||||
mbeds = mbed_lstools.create()
|
||||
muts_list = mbeds.list_mbeds()
|
||||
test_base = IOperTestCaseBase()
|
||||
|
||||
self.raw_test_results = {}
|
||||
for i, mut in enumerate(muts_list):
|
||||
result = []
|
||||
self.raw_test_results[mut['platform_name']] = []
|
||||
|
||||
print "MBEDLS: Detected %s, port: %s, mounted: %s"% (mut['platform_name'],
|
||||
mut['serial_port'],
|
||||
mut['mount_point'])
|
||||
print "Running interoperability test suite, scope '%s'" % (self.requested_scope)
|
||||
for test_case in TEST_LIST:
|
||||
if self.scopes[self.requested_scope] >= self.scopes[test_case.scope]:
|
||||
res = test_case.test(param=mut)
|
||||
result.extend(res)
|
||||
self.raw_test_results[mut['platform_name']].extend(res)
|
||||
|
||||
columns = ['Platform', 'Test Case', 'Result', 'Scope', 'Description']
|
||||
pt = PrettyTable(columns)
|
||||
for col in columns:
|
||||
pt.align[col] = 'l'
|
||||
|
||||
for tr in result:
|
||||
severity, tr_name, tr_scope, text = tr
|
||||
tr = (test_base.COLOR(severity, mut['platform_name']),
|
||||
test_base.COLOR(severity, tr_name),
|
||||
test_base.COLOR(severity, severity),
|
||||
test_base.COLOR(severity, tr_scope),
|
||||
test_base.COLOR(severity, text))
|
||||
pt.add_row(list(tr))
|
||||
print pt.get_string(border=True, sortby='Result')
|
||||
if i + 1 < len(muts_list):
|
||||
print
|
||||
return self.raw_test_results
|
||||
|
||||
def get_available_oper_test_scopes():
|
||||
""" Get list of available test scopes
|
||||
"""
|
||||
scopes = set()
|
||||
for oper_test in TEST_LIST:
|
||||
if oper_test.scope is not None:
|
||||
scopes.add(oper_test.scope)
|
||||
return list(scopes)
|
|
@ -0,0 +1,69 @@
|
|||
"""
|
||||
mbed SDK
|
||||
Copyright (c) 2011-2015 ARM Limited
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
Author: Przemyslaw Wirkus <Przemyslaw.Wirkus@arm.com>
|
||||
|
||||
"""
|
||||
|
||||
import os.path
|
||||
from ioper_base import IOperTestCaseBase
|
||||
|
||||
|
||||
class IOperTest_FileStructure(IOperTestCaseBase):
|
||||
|
||||
def __init__(self, scope=None):
|
||||
IOperTestCaseBase.__init__(self, scope)
|
||||
|
||||
def if_file_exist(self, fname, fail_severity=None):
|
||||
file_path = os.path.join(self.param['mount_point'], fname)
|
||||
exist = os.path.isfile(file_path)
|
||||
tr_name = "FILE_EXIST(%s)" % fname.upper()
|
||||
if exist:
|
||||
self.result.append((self.PASS, tr_name, self.scope, "File '%s' exists" % file_path))
|
||||
else:
|
||||
self.result.append((fail_severity if fail_severity else self.ERROR, tr_name, self.scope, "File '%s' not found" % file_path))
|
||||
|
||||
def test(self, param=None):
|
||||
self.result = []
|
||||
if param:
|
||||
pass
|
||||
return self.result
|
||||
|
||||
|
||||
class IOperTest_FileStructure_Basic(IOperTest_FileStructure):
|
||||
def __init__(self, scope=None):
|
||||
IOperTest_FileStructure.__init__(self, scope)
|
||||
|
||||
def test(self, param=None):
|
||||
self.param = param
|
||||
self.result = []
|
||||
if param:
|
||||
self.if_file_exist('mbed.htm', self.ERROR)
|
||||
return self.result
|
||||
|
||||
|
||||
class IOperTest_FileStructure_MbedEnabled(IOperTest_FileStructure):
|
||||
def __init__(self, scope=None):
|
||||
IOperTest_FileStructure.__init__(self, scope)
|
||||
|
||||
def test(self, param=None):
|
||||
self.param = param
|
||||
self.result = []
|
||||
if param:
|
||||
self.if_file_exist('mbed.htm', self.ERROR)
|
||||
self.if_file_exist('DETAILS.TXT', self.ERROR)
|
||||
self.if_file_exist('FAIL.TXT', self.INFO)
|
||||
return self.result
|
|
@ -0,0 +1,111 @@
|
|||
"""
|
||||
mbed SDK
|
||||
Copyright (c) 2011-2015 ARM Limited
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
Author: Przemyslaw Wirkus <Przemyslaw.Wirkus@arm.com>
|
||||
|
||||
"""
|
||||
|
||||
from ioper_base import IOperTestCaseBase
|
||||
|
||||
|
||||
class IOperTest_TargetID(IOperTestCaseBase):
|
||||
""" tests related to target_id value
|
||||
"""
|
||||
|
||||
def __init__(self, scope=None):
|
||||
IOperTestCaseBase.__init__(self, scope)
|
||||
self.TARGET_ID_LEN = 24
|
||||
|
||||
def test_target_id_format(self, target_id, target_id_name):
|
||||
# Expected length == 24, eg. "02400203D94B0E7724B7F3CF"
|
||||
result = []
|
||||
target_id_len = len(target_id) if target_id else 0
|
||||
if target_id_len == self.TARGET_ID_LEN:
|
||||
result.append((self.PASS, "TARGET_ID_LEN", self.scope, "%s '%s' is %d chars long " % (target_id_name, target_id, target_id_len)))
|
||||
result.append((self.INFO, "FW_VER_STR", self.scope, "%s Version String is %s.%s.%s " % (target_id_name,
|
||||
target_id[0:4],
|
||||
target_id[4:8],
|
||||
target_id[8:24],
|
||||
)))
|
||||
else:
|
||||
result.append((self.ERROR, "TARGET_ID_LEN", self.scope, "%s '%s' is %d chars long. Expected %d chars" % (target_id_name, target_id, target_id_len, self.TARGET_ID_LEN)))
|
||||
return result
|
||||
|
||||
def test_decode_target_id(self, target_id, target_id_name):
|
||||
result = []
|
||||
target_id_len = len(target_id) if target_id else 0
|
||||
if target_id_len >= 4:
|
||||
result.append((self.INFO, "FW_VEN_CODE", self.scope, "%s Vendor Code is '%s'" % (target_id_name, target_id[0:2])))
|
||||
result.append((self.INFO, "FW_PLAT_CODE", self.scope, "%s Platform Code is '%s'" % (target_id_name, target_id[2:4])))
|
||||
result.append((self.INFO, "FW_VER", self.scope, "%s Firmware Version is '%s'" % (target_id_name, target_id[4:8])))
|
||||
result.append((self.INFO, "FW_HASH_SEC", self.scope, "%s Hash of secret is '%s'" % (target_id_name, target_id[8:24])))
|
||||
return result
|
||||
|
||||
def test(self, param=None):
|
||||
result = []
|
||||
if param:
|
||||
pass
|
||||
return result
|
||||
|
||||
|
||||
class IOperTest_TargetID_Basic(IOperTest_TargetID):
|
||||
""" Basic interoperability tests checking TargetID compliance
|
||||
"""
|
||||
|
||||
def __init__(self, scope=None):
|
||||
IOperTest_TargetID.__init__(self, scope)
|
||||
|
||||
def test(self, param=None):
|
||||
result = []
|
||||
|
||||
if param:
|
||||
result.append((self.PASS, "TARGET_ID", self.scope, "TargetID '%s' found" % param['target_id']))
|
||||
|
||||
# Check if target name can be decoded with mbed-ls
|
||||
if param['platform_name']:
|
||||
result.append((self.PASS, "TARGET_ID_DECODE", self.scope, "TargetID '%s' decoded as '%s'" % (param['target_id'][0:4], param['platform_name'])))
|
||||
else:
|
||||
result.append((self.ERROR, "TARGET_ID_DECODE", self.scope, "TargetID '%s'... not decoded" % (param['target_id'] if param['target_id'] else '')))
|
||||
|
||||
# Test for USBID and mbed.htm consistency
|
||||
if param['target_id_mbed_htm'] == param['target_id_usb_id']:
|
||||
result.append((self.PASS, "TARGET_ID_MATCH", self.scope, "TargetID (USBID) and TargetID (mbed.htm) match"))
|
||||
else:
|
||||
text = "TargetID (USBID) and TargetID (mbed.htm) don't match: '%s' != '%s'" % (param['target_id_usb_id'], param['target_id_mbed_htm'])
|
||||
result.append((self.WARN, "TARGET_ID_MATCH", self.scope, text))
|
||||
else:
|
||||
result.append((self.ERROR, "TARGET_ID", self.scope, "TargetID not found"))
|
||||
return result
|
||||
|
||||
class IOperTest_TargetID_MbedEnabled(IOperTest_TargetID):
|
||||
""" Basic interoperability tests checking TargetID compliance
|
||||
"""
|
||||
|
||||
def __init__(self, scope=None):
|
||||
IOperTest_TargetID.__init__(self, scope)
|
||||
|
||||
def test(self, param=None):
|
||||
result = []
|
||||
|
||||
if param:
|
||||
# Target ID tests:
|
||||
result += self.test_target_id_format(param['target_id_usb_id'], "TargetId (USBID)")
|
||||
result += self.test_target_id_format(param['target_id_mbed_htm'], "TargetId (mbed.htm)")
|
||||
|
||||
# Some extra info about TargetID itself
|
||||
result += self.test_decode_target_id(param['target_id_usb_id'], "TargetId (USBID)")
|
||||
result += self.test_decode_target_id(param['target_id_mbed_htm'], "TargetId (mbed.htm)")
|
||||
return result
|
|
@ -75,6 +75,11 @@ from workspace_tools.test_api import get_autodetected_MUTS
|
|||
from workspace_tools.test_api import get_autodetected_TEST_SPEC
|
||||
from workspace_tools.test_api import get_module_avail
|
||||
|
||||
from workspace_tools.compliance.ioper_runner import IOperTestRunner
|
||||
from workspace_tools.compliance.ioper_runner import get_available_oper_test_scopes
|
||||
from workspace_tools.test_exporters import ReportExporter, ResultExporterType
|
||||
|
||||
|
||||
# Importing extra modules which can be not installed but if available they can extend test suite functionality
|
||||
try:
|
||||
import mbed_lstools
|
||||
|
@ -182,15 +187,32 @@ if __name__ == '__main__':
|
|||
exit(-1)
|
||||
|
||||
if opts.verbose_test_configuration_only:
|
||||
print "MUTs configuration in %s:"% ('auto-detected' if opts.auto_detect else opts.muts_spec_filename)
|
||||
print "MUTs configuration in %s:" % ('auto-detected' if opts.auto_detect else opts.muts_spec_filename)
|
||||
if MUTs:
|
||||
print print_muts_configuration_from_json(MUTs, platform_filter=opts.general_filter_regex)
|
||||
print
|
||||
print "Test specification in %s:"% ('auto-detected' if opts.auto_detect else opts.test_spec_filename)
|
||||
print "Test specification in %s:" % ('auto-detected' if opts.auto_detect else opts.test_spec_filename)
|
||||
if test_spec:
|
||||
print print_test_configuration_from_json(test_spec)
|
||||
exit(0)
|
||||
|
||||
if opts.operability_checks:
|
||||
# Check if test scope is valid and run tests
|
||||
test_scope = get_available_oper_test_scopes()
|
||||
if opts.operability_checks in test_scope:
|
||||
tests = IOperTestRunner(scope=opts.operability_checks)
|
||||
test_results = tests.run()
|
||||
|
||||
# Export results in form of JUnit XML report to separate file
|
||||
if opts.report_junit_file_name:
|
||||
report_exporter = ReportExporter(ResultExporterType.JUNIT_OPER)
|
||||
report_exporter.report_to_file(test_results, opts.report_junit_file_name)
|
||||
else:
|
||||
print "Unknown interoperability test scope name: '%s'" % (opts.operability_checks)
|
||||
print "Available test scopes: %s" % (','.join(["'%s'" % n for n in test_scope]))
|
||||
|
||||
exit(0)
|
||||
|
||||
# Verbose test specification and MUTs configuration
|
||||
if MUTs and opts.verbose:
|
||||
print print_muts_configuration_from_json(MUTs)
|
||||
|
|
|
@ -53,6 +53,7 @@ from workspace_tools.build_api import print_build_results
|
|||
from workspace_tools.libraries import LIBRARIES, LIBRARY_MAP
|
||||
from workspace_tools.toolchains import TOOLCHAIN_BIN_PATH
|
||||
from workspace_tools.test_exporters import ReportExporter, ResultExporterType
|
||||
from workspace_tools.compliance.ioper_runner import get_available_oper_test_scopes
|
||||
|
||||
|
||||
import workspace_tools.host_tests.host_tests_plugins as host_tests_plugins
|
||||
|
@ -1740,7 +1741,12 @@ def get_default_test_options_parser():
|
|||
|
||||
parser.add_option('', '--tc',
|
||||
dest='toolchains_filter',
|
||||
help="Toolchain filter for --auto option. Use toolcahins names separated by comma, 'default' or 'all' to select toolchains")
|
||||
help="Toolchain filter for --auto option. Use toolchains names separated by comma, 'default' or 'all' to select toolchains")
|
||||
|
||||
test_scopes = ','.join(["'%s'" % n for n in get_available_oper_test_scopes()])
|
||||
parser.add_option('', '--oper',
|
||||
dest='operability_checks',
|
||||
help='Perform interoperability tests between host and connected mbed devices. Available test scopes are: %s' % test_scopes)
|
||||
|
||||
parser.add_option('', '--clean',
|
||||
dest='clean',
|
||||
|
@ -1758,15 +1764,15 @@ def get_default_test_options_parser():
|
|||
dest='test_only_common',
|
||||
default=False,
|
||||
action="store_true",
|
||||
help='Test only board internals. Skip perpherials tests and perform common tests.')
|
||||
help='Test only board internals. Skip perpherials tests and perform common tests')
|
||||
|
||||
parser.add_option('-n', '--test-by-names',
|
||||
dest='test_by_names',
|
||||
help='Runs only test enumerated it this switch. Use comma to separate test case names.')
|
||||
help='Runs only test enumerated it this switch. Use comma to separate test case names')
|
||||
|
||||
parser.add_option('-p', '--peripheral-by-names',
|
||||
dest='peripheral_by_names',
|
||||
help='Forces discovery of particular peripherals. Use comma to separate peripheral names.')
|
||||
help='Forces discovery of particular peripherals. Use comma to separate peripheral names')
|
||||
|
||||
copy_methods = host_tests_plugins.get_plugin_caps('CopyMethod')
|
||||
copy_methods_str = "Plugin support: " + ', '.join(copy_methods)
|
||||
|
@ -1861,11 +1867,11 @@ def get_default_test_options_parser():
|
|||
dest='waterfall_test',
|
||||
default=False,
|
||||
action="store_true",
|
||||
help='Used with --loops or --global-loops options. Tests until OK result occurs and assumes test passed.')
|
||||
help='Used with --loops or --global-loops options. Tests until OK result occurs and assumes test passed')
|
||||
|
||||
parser.add_option('-N', '--firmware-name',
|
||||
dest='firmware_global_name',
|
||||
help='Set global name for all produced projects. Note, proper file extension will be added by buid scripts.')
|
||||
help='Set global name for all produced projects. Note, proper file extension will be added by buid scripts')
|
||||
|
||||
parser.add_option('-u', '--shuffle',
|
||||
dest='shuffle_test_order',
|
||||
|
|
|
@ -22,6 +22,7 @@ from workspace_tools.utils import construct_enum
|
|||
|
||||
ResultExporterType = construct_enum(HTML='Html_Exporter',
|
||||
JUNIT='JUnit_Exporter',
|
||||
JUNIT_OPER='JUnit_Exporter_Interoperability',
|
||||
BUILD='Build_Exporter')
|
||||
|
||||
|
||||
|
@ -76,14 +77,20 @@ class ReportExporter():
|
|||
# HTML exporter
|
||||
return self.exporter_html(test_summary_ext, test_suite_properties)
|
||||
elif self.result_exporter_type == ResultExporterType.JUNIT:
|
||||
# JUNIT exporter
|
||||
# JUNIT exporter for results from test suite
|
||||
return self.exporter_junit(test_summary_ext, test_suite_properties)
|
||||
elif self.result_exporter_type == ResultExporterType.JUNIT_OPER:
|
||||
# JUNIT exporter for interoperability test
|
||||
return self.exporter_junit_ioper(test_summary_ext, test_suite_properties)
|
||||
return None
|
||||
|
||||
def report_to_file(self, test_summary_ext, file_name, test_suite_properties=None):
|
||||
""" Stores report to specified file
|
||||
"""
|
||||
report = self.report(test_summary_ext, test_suite_properties=test_suite_properties)
|
||||
self.write_to_file(report, file_name)
|
||||
|
||||
def write_to_file(self, report, file_name):
|
||||
if report is not None:
|
||||
with open(file_name, 'w') as f:
|
||||
f.write(report)
|
||||
|
@ -204,6 +211,34 @@ class ReportExporter():
|
|||
result += '</body></html>'
|
||||
return result
|
||||
|
||||
def exporter_junit_ioper(self, test_result_ext, test_suite_properties=None):
|
||||
from junit_xml import TestSuite, TestCase
|
||||
test_suites = []
|
||||
test_cases = []
|
||||
|
||||
for platform in sorted(test_result_ext.keys()):
|
||||
# {platform : ['Platform', 'Result', 'Scope', 'Description'])
|
||||
test_cases = []
|
||||
for tr_result in test_result_ext[platform]:
|
||||
result, name, scope, description = tr_result
|
||||
|
||||
classname = 'test.ioper.%s.%s.%s' % (platform, name, scope)
|
||||
elapsed_sec = 0
|
||||
_stdout = description
|
||||
_stderr = ''
|
||||
# Test case
|
||||
tc = TestCase(name, classname, elapsed_sec, _stdout, _stderr)
|
||||
# Test case extra failure / error info
|
||||
if result == 'FAIL':
|
||||
tc.add_failure_info(description, _stdout)
|
||||
elif result == 'ERROR':
|
||||
tc.add_error_info(description, _stdout)
|
||||
|
||||
test_cases.append(tc)
|
||||
ts = TestSuite("test.suite.ioper.%s" % (platform), test_cases)
|
||||
test_suites.append(ts)
|
||||
return TestSuite.to_xml_string(test_suites)
|
||||
|
||||
def exporter_junit(self, test_result_ext, test_suite_properties=None):
|
||||
""" Export test results in JUnit XML compliant format
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue