mbed-os

Fork of mbed-os by erkin yucel

Committer:
xuaner
Date:
Thu Jul 20 14:26:57 2017 +0000
Revision:
1:3deb71413561
Parent:
0:f269e3021894
mbed_os

Who changed what in which revision?

UserRevisionLine numberNew contents of line
elessair 0:f269e3021894 1 """
elessair 0:f269e3021894 2 mbed SDK
elessair 0:f269e3021894 3 Copyright (c) 2011-2014 ARM Limited
elessair 0:f269e3021894 4
elessair 0:f269e3021894 5 Licensed under the Apache License, Version 2.0 (the "License");
elessair 0:f269e3021894 6 you may not use this file except in compliance with the License.
elessair 0:f269e3021894 7 You may obtain a copy of the License at
elessair 0:f269e3021894 8
elessair 0:f269e3021894 9 http://www.apache.org/licenses/LICENSE-2.0
elessair 0:f269e3021894 10
elessair 0:f269e3021894 11 Unless required by applicable law or agreed to in writing, software
elessair 0:f269e3021894 12 distributed under the License is distributed on an "AS IS" BASIS,
elessair 0:f269e3021894 13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
elessair 0:f269e3021894 14 See the License for the specific language governing permissions and
elessair 0:f269e3021894 15 limitations under the License.
elessair 0:f269e3021894 16
elessair 0:f269e3021894 17 Author: Przemyslaw Wirkus <Przemyslaw.wirkus@arm.com>
elessair 0:f269e3021894 18 """
elessair 0:f269e3021894 19
elessair 0:f269e3021894 20 from tools.utils import construct_enum, mkdir
elessair 0:f269e3021894 21 from prettytable import PrettyTable
elessair 0:f269e3021894 22 import os
elessair 0:f269e3021894 23
elessair 0:f269e3021894 24 ResultExporterType = construct_enum(HTML='Html_Exporter',
elessair 0:f269e3021894 25 JUNIT='JUnit_Exporter',
elessair 0:f269e3021894 26 JUNIT_OPER='JUnit_Exporter_Interoperability',
elessair 0:f269e3021894 27 BUILD='Build_Exporter',
elessair 0:f269e3021894 28 TEXT='Text_Exporter',
elessair 0:f269e3021894 29 PRINT='Print_Exporter')
elessair 0:f269e3021894 30
elessair 0:f269e3021894 31
elessair 0:f269e3021894 32 class ReportExporter():
elessair 0:f269e3021894 33 """ Class exports extended test result Python data structure to
elessair 0:f269e3021894 34 different formats like HTML, JUnit XML.
elessair 0:f269e3021894 35
elessair 0:f269e3021894 36 Parameter 'test_result_ext' format:
elessair 0:f269e3021894 37
elessair 0:f269e3021894 38 u'uARM': { u'LPC1768': { 'MBED_2': { 0: { 'copy_method': 'shutils.copy()',
elessair 0:f269e3021894 39 'duration': 20,
elessair 0:f269e3021894 40 'elapsed_time': 1.7929999828338623,
elessair 0:f269e3021894 41 'output': 'Host test instrumentation on ...\r\n',
elessair 0:f269e3021894 42 'result': 'OK',
elessair 0:f269e3021894 43 'target_name': u'LPC1768',
elessair 0:f269e3021894 44 'description': 'stdio',
elessair 0:f269e3021894 45 'id': u'MBED_2',
elessair 0:f269e3021894 46 'toolchain_name': u'uARM'}},
elessair 0:f269e3021894 47 """
elessair 0:f269e3021894 48 CSS_STYLE = """<style>
elessair 0:f269e3021894 49 .name{
elessair 0:f269e3021894 50 border: 1px solid;
elessair 0:f269e3021894 51 border-radius: 25px;
elessair 0:f269e3021894 52 width: 100px;
elessair 0:f269e3021894 53 }
elessair 0:f269e3021894 54 .tooltip{
elessair 0:f269e3021894 55 position:absolute;
elessair 0:f269e3021894 56 background-color: #F5DA81;
elessair 0:f269e3021894 57 display:none;
elessair 0:f269e3021894 58 }
elessair 0:f269e3021894 59 </style>
elessair 0:f269e3021894 60 """
elessair 0:f269e3021894 61
elessair 0:f269e3021894 62 JAVASCRIPT = """
elessair 0:f269e3021894 63 <script type="text/javascript">
elessair 0:f269e3021894 64 function show (elem) {
elessair 0:f269e3021894 65 elem.style.display = "block";
elessair 0:f269e3021894 66 }
elessair 0:f269e3021894 67 function hide (elem) {
elessair 0:f269e3021894 68 elem.style.display = "";
elessair 0:f269e3021894 69 }
elessair 0:f269e3021894 70 </script>
elessair 0:f269e3021894 71 """
elessair 0:f269e3021894 72
elessair 0:f269e3021894 73 def __init__(self, result_exporter_type, package="test"):
elessair 0:f269e3021894 74 self.result_exporter_type = result_exporter_type
elessair 0:f269e3021894 75 self.package = package
elessair 0:f269e3021894 76
elessair 0:f269e3021894 77 def report(self, test_summary_ext, test_suite_properties=None,
elessair 0:f269e3021894 78 print_log_for_failures=True):
elessair 0:f269e3021894 79 """ Invokes report depending on exporter_type set in constructor
elessair 0:f269e3021894 80 """
elessair 0:f269e3021894 81 if self.result_exporter_type == ResultExporterType.HTML:
elessair 0:f269e3021894 82 # HTML exporter
elessair 0:f269e3021894 83 return self.exporter_html(test_summary_ext, test_suite_properties)
elessair 0:f269e3021894 84 elif self.result_exporter_type == ResultExporterType.JUNIT:
elessair 0:f269e3021894 85 # JUNIT exporter for results from test suite
elessair 0:f269e3021894 86 return self.exporter_junit(test_summary_ext, test_suite_properties)
elessair 0:f269e3021894 87 elif self.result_exporter_type == ResultExporterType.JUNIT_OPER:
elessair 0:f269e3021894 88 # JUNIT exporter for interoperability test
elessair 0:f269e3021894 89 return self.exporter_junit_ioper(test_summary_ext, test_suite_properties)
elessair 0:f269e3021894 90 elif self.result_exporter_type == ResultExporterType.PRINT:
elessair 0:f269e3021894 91 # JUNIT exporter for interoperability test
elessair 0:f269e3021894 92 return self.exporter_print(test_summary_ext, print_log_for_failures=print_log_for_failures)
elessair 0:f269e3021894 93 elif self.result_exporter_type == ResultExporterType.TEXT:
elessair 0:f269e3021894 94 return self.exporter_text(test_summary_ext)
elessair 0:f269e3021894 95 return None
elessair 0:f269e3021894 96
elessair 0:f269e3021894 97 def report_to_file(self, test_summary_ext, file_name, test_suite_properties=None):
elessair 0:f269e3021894 98 """ Stores report to specified file
elessair 0:f269e3021894 99 """
elessair 0:f269e3021894 100 report = self.report(test_summary_ext, test_suite_properties=test_suite_properties)
elessair 0:f269e3021894 101 self.write_to_file(report, file_name)
elessair 0:f269e3021894 102
elessair 0:f269e3021894 103 def write_to_file(self, report, file_name):
elessair 0:f269e3021894 104 if report is not None:
elessair 0:f269e3021894 105 dirname = os.path.dirname(file_name)
elessair 0:f269e3021894 106 if dirname:
elessair 0:f269e3021894 107 mkdir(dirname)
elessair 0:f269e3021894 108 with open(file_name, 'w') as f:
elessair 0:f269e3021894 109 f.write(report)
elessair 0:f269e3021894 110
elessair 0:f269e3021894 111 def get_tooltip_name(self, toolchain, target, test_id, loop_no):
elessair 0:f269e3021894 112 """ Generate simple unique tool-tip name which can be used.
elessair 0:f269e3021894 113 For example as HTML <div> section id attribute.
elessair 0:f269e3021894 114 """
elessair 0:f269e3021894 115 return "target_test_%s_%s_%s_%s"% (toolchain.lower(), target.lower(), test_id.lower(), loop_no)
elessair 0:f269e3021894 116
elessair 0:f269e3021894 117 def get_result_div_sections(self, test, test_no):
elessair 0:f269e3021894 118 """ Generates separate <DIV> sections which contains test results output.
elessair 0:f269e3021894 119 """
elessair 0:f269e3021894 120
elessair 0:f269e3021894 121 RESULT_COLORS = {'OK': 'LimeGreen',
elessair 0:f269e3021894 122 'FAIL': 'Orange',
elessair 0:f269e3021894 123 'ERROR': 'LightCoral',
elessair 0:f269e3021894 124 'OTHER': 'LightGray',
elessair 0:f269e3021894 125 }
elessair 0:f269e3021894 126
elessair 0:f269e3021894 127 tooltip_name = self.get_tooltip_name(test['toolchain_name'], test['target_name'], test['id'], test_no)
elessair 0:f269e3021894 128 background_color = RESULT_COLORS[test['result'] if test['result'] in RESULT_COLORS else 'OTHER']
elessair 0:f269e3021894 129 result_div_style = "background-color: %s"% background_color
elessair 0:f269e3021894 130
elessair 0:f269e3021894 131 result = """<div class="name" style="%s" onmouseover="show(%s)" onmouseout="hide(%s)">
elessair 0:f269e3021894 132 <center>%s</center>
elessair 0:f269e3021894 133 <div class = "tooltip" id= "%s">
elessair 0:f269e3021894 134 <b>%s</b><br />
elessair 0:f269e3021894 135 <hr />
elessair 0:f269e3021894 136 <b>%s</b> in <b>%.2f sec</b><br />
elessair 0:f269e3021894 137 <hr />
elessair 0:f269e3021894 138 <small>
elessair 0:f269e3021894 139 %s
elessair 0:f269e3021894 140 </small>
elessair 0:f269e3021894 141 </div>
elessair 0:f269e3021894 142 </div>
elessair 0:f269e3021894 143 """% (result_div_style,
elessair 0:f269e3021894 144 tooltip_name,
elessair 0:f269e3021894 145 tooltip_name,
elessair 0:f269e3021894 146 test['result'],
elessair 0:f269e3021894 147 tooltip_name,
elessair 0:f269e3021894 148 test['target_name_unique'],
elessair 0:f269e3021894 149 test['description'],
elessair 0:f269e3021894 150 test['elapsed_time'],
elessair 0:f269e3021894 151 test['output'].replace('\n', '<br />'))
elessair 0:f269e3021894 152 return result
elessair 0:f269e3021894 153
elessair 0:f269e3021894 154 def get_result_tree(self, test_results):
elessair 0:f269e3021894 155 """ If test was run in a loop (we got few results from the same test)
elessair 0:f269e3021894 156 we will show it in a column to see all results.
elessair 0:f269e3021894 157 This function produces HTML table with corresponding results.
elessair 0:f269e3021894 158 """
elessair 0:f269e3021894 159 result = ''
elessair 0:f269e3021894 160 for i, test_result in enumerate(test_results):
elessair 0:f269e3021894 161 result += '<table>'
elessair 0:f269e3021894 162 test_ids = sorted(test_result.keys())
elessair 0:f269e3021894 163 for test_no in test_ids:
elessair 0:f269e3021894 164 test = test_result[test_no]
elessair 0:f269e3021894 165 result += """<tr>
elessair 0:f269e3021894 166 <td valign="top">%s</td>
elessair 0:f269e3021894 167 </tr>"""% self.get_result_div_sections(test, "%d_%d" % (test_no, i))
elessair 0:f269e3021894 168 result += '</table>'
elessair 0:f269e3021894 169 return result
elessair 0:f269e3021894 170
elessair 0:f269e3021894 171 def get_all_unique_test_ids(self, test_result_ext):
elessair 0:f269e3021894 172 """ Gets all unique test ids from all ran tests.
elessair 0:f269e3021894 173 We need this to create complete list of all test ran.
elessair 0:f269e3021894 174 """
elessair 0:f269e3021894 175 result = []
elessair 0:f269e3021894 176 targets = test_result_ext.keys()
elessair 0:f269e3021894 177 for target in targets:
elessair 0:f269e3021894 178 toolchains = test_result_ext[target].keys()
elessair 0:f269e3021894 179 for toolchain in toolchains:
elessair 0:f269e3021894 180 tests = test_result_ext[target][toolchain].keys()
elessair 0:f269e3021894 181 result.extend(tests)
elessair 0:f269e3021894 182 return sorted(list(set(result)))
elessair 0:f269e3021894 183
elessair 0:f269e3021894 184 #
elessair 0:f269e3021894 185 # Exporters functions
elessair 0:f269e3021894 186 #
elessair 0:f269e3021894 187
elessair 0:f269e3021894 188 def exporter_html(self, test_result_ext, test_suite_properties=None):
elessair 0:f269e3021894 189 """ Export test results in proprietary HTML format.
elessair 0:f269e3021894 190 """
elessair 0:f269e3021894 191 result = """<html>
elessair 0:f269e3021894 192 <head>
elessair 0:f269e3021894 193 <title>mbed SDK test suite test result report</title>
elessair 0:f269e3021894 194 %s
elessair 0:f269e3021894 195 %s
elessair 0:f269e3021894 196 </head>
elessair 0:f269e3021894 197 <body>
elessair 0:f269e3021894 198 """% (self.CSS_STYLE, self.JAVASCRIPT)
elessair 0:f269e3021894 199
elessair 0:f269e3021894 200 unique_test_ids = self.get_all_unique_test_ids(test_result_ext)
elessair 0:f269e3021894 201 targets = sorted(test_result_ext.keys())
elessair 0:f269e3021894 202 result += '<table>'
elessair 0:f269e3021894 203 for target in targets:
elessair 0:f269e3021894 204 toolchains = sorted(test_result_ext[target].keys())
elessair 0:f269e3021894 205 for toolchain in toolchains:
elessair 0:f269e3021894 206 result += '<tr>'
elessair 0:f269e3021894 207 result += '<td></td>'
elessair 0:f269e3021894 208 result += '<td></td>'
elessair 0:f269e3021894 209
elessair 0:f269e3021894 210 tests = sorted(test_result_ext[target][toolchain].keys())
elessair 0:f269e3021894 211 for test in unique_test_ids:
elessair 0:f269e3021894 212 result += """<td align="center">%s</td>"""% test
elessair 0:f269e3021894 213 result += """</tr>
elessair 0:f269e3021894 214 <tr>
elessair 0:f269e3021894 215 <td valign="center">%s</td>
elessair 0:f269e3021894 216 <td valign="center"><b>%s</b></td>
elessair 0:f269e3021894 217 """% (toolchain, target)
elessair 0:f269e3021894 218
elessair 0:f269e3021894 219 for test in unique_test_ids:
elessair 0:f269e3021894 220 test_result = self.get_result_tree(test_result_ext[target][toolchain][test]) if test in tests else ''
elessair 0:f269e3021894 221 result += '<td>%s</td>'% (test_result)
elessair 0:f269e3021894 222
elessair 0:f269e3021894 223 result += '</tr>'
elessair 0:f269e3021894 224 result += '</table>'
elessair 0:f269e3021894 225 result += '</body></html>'
elessair 0:f269e3021894 226 return result
elessair 0:f269e3021894 227
elessair 0:f269e3021894 228 def exporter_junit_ioper(self, test_result_ext, test_suite_properties=None):
elessair 0:f269e3021894 229 from junit_xml import TestSuite, TestCase
elessair 0:f269e3021894 230 test_suites = []
elessair 0:f269e3021894 231 test_cases = []
elessair 0:f269e3021894 232
elessair 0:f269e3021894 233 for platform in sorted(test_result_ext.keys()):
elessair 0:f269e3021894 234 # {platform : ['Platform', 'Result', 'Scope', 'Description'])
elessair 0:f269e3021894 235 test_cases = []
elessair 0:f269e3021894 236 for tr_result in test_result_ext[platform]:
elessair 0:f269e3021894 237 result, name, scope, description = tr_result
elessair 0:f269e3021894 238
elessair 0:f269e3021894 239 classname = 'test.ioper.%s.%s.%s' % (platform, name, scope)
elessair 0:f269e3021894 240 elapsed_sec = 0
elessair 0:f269e3021894 241 _stdout = description
elessair 0:f269e3021894 242 _stderr = ''
elessair 0:f269e3021894 243 # Test case
elessair 0:f269e3021894 244 tc = TestCase(name, classname, elapsed_sec, _stdout, _stderr)
elessair 0:f269e3021894 245 # Test case extra failure / error info
elessair 0:f269e3021894 246 if result == 'FAIL':
elessair 0:f269e3021894 247 tc.add_failure_info(description, _stdout)
elessair 0:f269e3021894 248 elif result == 'ERROR':
elessair 0:f269e3021894 249 tc.add_error_info(description, _stdout)
elessair 0:f269e3021894 250 elif result == 'SKIP' or result == 'NOT_SUPPORTED':
elessair 0:f269e3021894 251 tc.add_skipped_info(description, _stdout)
elessair 0:f269e3021894 252
elessair 0:f269e3021894 253 test_cases.append(tc)
elessair 0:f269e3021894 254 ts = TestSuite("test.suite.ioper.%s" % (platform), test_cases)
elessair 0:f269e3021894 255 test_suites.append(ts)
elessair 0:f269e3021894 256 return TestSuite.to_xml_string(test_suites)
elessair 0:f269e3021894 257
elessair 0:f269e3021894 258 def exporter_junit(self, test_result_ext, test_suite_properties=None):
elessair 0:f269e3021894 259 """ Export test results in JUnit XML compliant format
elessair 0:f269e3021894 260 """
elessair 0:f269e3021894 261 from junit_xml import TestSuite, TestCase
elessair 0:f269e3021894 262 test_suites = []
elessair 0:f269e3021894 263 test_cases = []
elessair 0:f269e3021894 264
elessair 0:f269e3021894 265 targets = sorted(test_result_ext.keys())
elessair 0:f269e3021894 266 for target in targets:
elessair 0:f269e3021894 267 toolchains = sorted(test_result_ext[target].keys())
elessair 0:f269e3021894 268 for toolchain in toolchains:
elessair 0:f269e3021894 269 test_cases = []
elessair 0:f269e3021894 270 tests = sorted(test_result_ext[target][toolchain].keys())
elessair 0:f269e3021894 271 for test in tests:
elessair 0:f269e3021894 272 test_results = test_result_ext[target][toolchain][test]
elessair 0:f269e3021894 273 for test_res in test_results:
elessair 0:f269e3021894 274 test_ids = sorted(test_res.keys())
elessair 0:f269e3021894 275 for test_no in test_ids:
elessair 0:f269e3021894 276 test_result = test_res[test_no]
elessair 0:f269e3021894 277 name = test_result['description']
elessair 0:f269e3021894 278 classname = '%s.%s.%s.%s'% (self.package, target, toolchain, test_result['id'])
elessair 0:f269e3021894 279 elapsed_sec = test_result['elapsed_time']
elessair 0:f269e3021894 280 _stdout = test_result['output']
elessair 0:f269e3021894 281
elessair 0:f269e3021894 282 if 'target_name_unique' in test_result:
elessair 0:f269e3021894 283 _stderr = test_result['target_name_unique']
elessair 0:f269e3021894 284 else:
elessair 0:f269e3021894 285 _stderr = test_result['target_name']
elessair 0:f269e3021894 286
elessair 0:f269e3021894 287 # Test case
elessair 0:f269e3021894 288 tc = TestCase(name, classname, elapsed_sec, _stdout, _stderr)
elessair 0:f269e3021894 289
elessair 0:f269e3021894 290 # Test case extra failure / error info
elessair 0:f269e3021894 291 message = test_result['result']
elessair 0:f269e3021894 292 if test_result['result'] == 'FAIL':
elessair 0:f269e3021894 293 tc.add_failure_info(message, _stdout)
elessair 0:f269e3021894 294 elif test_result['result'] == 'SKIP' or test_result["result"] == 'NOT_SUPPORTED':
elessair 0:f269e3021894 295 tc.add_skipped_info(message, _stdout)
elessair 0:f269e3021894 296 elif test_result['result'] != 'OK':
elessair 0:f269e3021894 297 tc.add_error_info(message, _stdout)
elessair 0:f269e3021894 298
elessair 0:f269e3021894 299 test_cases.append(tc)
elessair 0:f269e3021894 300
elessair 0:f269e3021894 301 ts = TestSuite("test.suite.%s.%s"% (target, toolchain), test_cases, properties=test_suite_properties[target][toolchain])
elessair 0:f269e3021894 302 test_suites.append(ts)
elessair 0:f269e3021894 303 return TestSuite.to_xml_string(test_suites)
elessair 0:f269e3021894 304
elessair 0:f269e3021894 305 def exporter_print_helper(self, array, print_log=False):
elessair 0:f269e3021894 306 for item in array:
elessair 0:f269e3021894 307 print " * %s::%s::%s" % (item["target_name"], item["toolchain_name"], item["id"])
elessair 0:f269e3021894 308 if print_log:
elessair 0:f269e3021894 309 log_lines = item["output"].split("\n")
elessair 0:f269e3021894 310 for log_line in log_lines:
elessair 0:f269e3021894 311 print " %s" % log_line
elessair 0:f269e3021894 312
elessair 0:f269e3021894 313 def exporter_print(self, test_result_ext, print_log_for_failures=False):
elessair 0:f269e3021894 314 """ Export test results in print format.
elessair 0:f269e3021894 315 """
elessair 0:f269e3021894 316 failures = []
elessair 0:f269e3021894 317 skips = []
elessair 0:f269e3021894 318 successes = []
elessair 0:f269e3021894 319
elessair 0:f269e3021894 320 unique_test_ids = self.get_all_unique_test_ids(test_result_ext)
elessair 0:f269e3021894 321 targets = sorted(test_result_ext.keys())
elessair 0:f269e3021894 322
elessair 0:f269e3021894 323 for target in targets:
elessair 0:f269e3021894 324 toolchains = sorted(test_result_ext[target].keys())
elessair 0:f269e3021894 325 for toolchain in toolchains:
elessair 0:f269e3021894 326 tests = sorted(test_result_ext[target][toolchain].keys())
elessair 0:f269e3021894 327 for test in tests:
elessair 0:f269e3021894 328 test_runs = test_result_ext[target][toolchain][test]
elessair 0:f269e3021894 329 for test_runner in test_runs:
elessair 0:f269e3021894 330 #test_run = test_result_ext[target][toolchain][test][test_run_number][0]
elessair 0:f269e3021894 331 test_run = test_runner[0]
elessair 0:f269e3021894 332
elessair 0:f269e3021894 333 if "result" in test_run:
elessair 0:f269e3021894 334 if test_run["result"] == "FAIL":
elessair 0:f269e3021894 335 failures.append(test_run)
elessair 0:f269e3021894 336 elif test_run["result"] == "SKIP" or test_run["result"] == "NOT_SUPPORTED":
elessair 0:f269e3021894 337 skips.append(test_run)
elessair 0:f269e3021894 338 elif test_run["result"] == "OK":
elessair 0:f269e3021894 339 successes.append(test_run)
elessair 0:f269e3021894 340 else:
elessair 0:f269e3021894 341 raise Exception("Unhandled result type: %s" % (test_run["result"]))
elessair 0:f269e3021894 342 else:
elessair 0:f269e3021894 343 raise Exception("'test_run' did not have a 'result' value")
elessair 0:f269e3021894 344
elessair 0:f269e3021894 345 if successes:
elessair 0:f269e3021894 346 print "\n\nBuild successes:"
elessair 0:f269e3021894 347 self.exporter_print_helper(successes)
elessair 0:f269e3021894 348
elessair 0:f269e3021894 349 if skips:
elessair 0:f269e3021894 350 print "\n\nBuild skips:"
elessair 0:f269e3021894 351 self.exporter_print_helper(skips)
elessair 0:f269e3021894 352
elessair 0:f269e3021894 353 if failures:
elessair 0:f269e3021894 354 print "\n\nBuild failures:"
elessair 0:f269e3021894 355 self.exporter_print_helper(failures, print_log=print_log_for_failures)
elessair 0:f269e3021894 356 return False
elessair 0:f269e3021894 357 else:
elessair 0:f269e3021894 358 return True
elessair 0:f269e3021894 359
elessair 0:f269e3021894 360 def exporter_text(self, test_result_ext):
elessair 0:f269e3021894 361 """ Prints well-formed summary with results (SQL table like)
elessair 0:f269e3021894 362 table shows target x test results matrix across
elessair 0:f269e3021894 363 """
elessair 0:f269e3021894 364 success_code = 0 # Success code that can be leter returned to
elessair 0:f269e3021894 365 # Pretty table package is used to print results
elessair 0:f269e3021894 366 pt = PrettyTable(["Result", "Target", "Toolchain", "Test ID", "Test Description",
elessair 0:f269e3021894 367 "Elapsed Time", "Timeout"])
elessair 0:f269e3021894 368 pt.align["Result"] = "l" # Left align
elessair 0:f269e3021894 369 pt.align["Target"] = "l" # Left align
elessair 0:f269e3021894 370 pt.align["Toolchain"] = "l" # Left align
elessair 0:f269e3021894 371 pt.align["Test ID"] = "l" # Left align
elessair 0:f269e3021894 372 pt.align["Test Description"] = "l" # Left align
elessair 0:f269e3021894 373 pt.padding_width = 1 # One space between column edges and contents (default)
elessair 0:f269e3021894 374
elessair 0:f269e3021894 375 result_dict = {"OK" : 0,
elessair 0:f269e3021894 376 "FAIL" : 0,
elessair 0:f269e3021894 377 "ERROR" : 0,
elessair 0:f269e3021894 378 "UNDEF" : 0,
elessair 0:f269e3021894 379 "IOERR_COPY" : 0,
elessair 0:f269e3021894 380 "IOERR_DISK" : 0,
elessair 0:f269e3021894 381 "IOERR_SERIAL" : 0,
elessair 0:f269e3021894 382 "TIMEOUT" : 0,
elessair 0:f269e3021894 383 "NO_IMAGE" : 0,
elessair 0:f269e3021894 384 "MBED_ASSERT" : 0,
elessair 0:f269e3021894 385 "BUILD_FAILED" : 0,
elessair 0:f269e3021894 386 "NOT_SUPPORTED" : 0
elessair 0:f269e3021894 387 }
elessair 0:f269e3021894 388 unique_test_ids = self.get_all_unique_test_ids(test_result_ext)
elessair 0:f269e3021894 389 targets = sorted(test_result_ext.keys())
elessair 0:f269e3021894 390 for target in targets:
elessair 0:f269e3021894 391 toolchains = sorted(test_result_ext[target].keys())
elessair 0:f269e3021894 392 for toolchain in toolchains:
elessair 0:f269e3021894 393 test_cases = []
elessair 0:f269e3021894 394 tests = sorted(test_result_ext[target][toolchain].keys())
elessair 0:f269e3021894 395 for test in tests:
elessair 0:f269e3021894 396 test_results = test_result_ext[target][toolchain][test]
elessair 0:f269e3021894 397 for test_res in test_results:
elessair 0:f269e3021894 398 test_ids = sorted(test_res.keys())
elessair 0:f269e3021894 399 for test_no in test_ids:
elessair 0:f269e3021894 400 test_result = test_res[test_no]
elessair 0:f269e3021894 401 result_dict[test_result['result']] += 1
elessair 0:f269e3021894 402 pt.add_row([test_result['result'],
elessair 0:f269e3021894 403 test_result['target_name'],
elessair 0:f269e3021894 404 test_result['toolchain_name'],
elessair 0:f269e3021894 405 test_result['id'],
elessair 0:f269e3021894 406 test_result['description'],
elessair 0:f269e3021894 407 test_result['elapsed_time'],
elessair 0:f269e3021894 408 test_result['duration']])
elessair 0:f269e3021894 409 result = pt.get_string()
elessair 0:f269e3021894 410 result += "\n"
elessair 0:f269e3021894 411
elessair 0:f269e3021894 412 # Print result count
elessair 0:f269e3021894 413 result += "Result: " + ' / '.join(['%s %s' % (value, key) for (key, value) in {k: v for k, v in result_dict.items() if v != 0}.iteritems()])
elessair 0:f269e3021894 414 return result