summaryrefslogtreecommitdiff
path: root/cts
diff options
context:
space:
mode:
authorChris Chen <twothreecc@google.com>2016-07-20 17:34:11 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-08-08 13:53:26 -0700
commit49dbc8a8aae9cc929de5a5b488b2e60bf5b7bf93 (patch)
treed35cbb193e7d4828f53f50d6589d2a5f285ca5d7 /cts
parentc2a841a489eb2a9a2f3efbc73664681b0f7839e8 (diff)
downloadchrome-ec-49dbc8a8aae9cc929de5a5b488b2e60bf5b7bf93.tar.gz
cts: Added html output to cts
When you run a test suite, cts will now save your results for the suite/dut combo as a basic html page BRANCH=None BUG=None TEST=Manual - Connect dut, th - Build/flash desired test suite - Run './cts -r' to run tests - Open /tmp/cts_results/<board_name>/<test_suite>.html - You should see a table with test names/results Change-Id: Id3de3bd7833be1bc5dde437c516db411aac47579 Reviewed-on: https://chromium-review.googlesource.com/362091 Commit-Ready: Chris Chen <twothreecc@google.com> Tested-by: Chris Chen <twothreecc@google.com> Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'cts')
-rwxr-xr-xcts/cts.py41
1 files changed, 39 insertions, 2 deletions
diff --git a/cts/cts.py b/cts/cts.py
index aa1203ebe4..1148b65349 100755
--- a/cts/cts.py
+++ b/cts/cts.py
@@ -14,10 +14,13 @@ import subprocess as sp
import time
from copy import deepcopy
from abc import ABCMeta, abstractmethod
+import xml.etree.ElementTree as et
# For most tests, error codes should never conflict
CTS_CONFLICTING_CODE = -1
CTS_SUCCESS_CODE = 0
+CTS_COLOR_RED = '#fb7d7d'
+CTS_COLOR_GREEN = '#7dfb9f'
TH_BOARD = 'stm32l476g-eval'
OCD_SCRIPT_DIR = '/usr/local/share/openocd/scripts'
MAX_SUITE_TIME_SEC = 3
@@ -495,6 +498,35 @@ class Cts(object):
return pretty_results
+ def resultsAsHtml(self):
+ res = self._resultsAsString()
+ root = et.Element('html')
+ head = et.SubElement(root, 'head')
+ style = et.SubElement(head, 'style')
+ style.text = ('table, td, th {border: 1px solid black;}'
+ 'body {font-family: \"Lucida Console\", Monaco, monospace')
+ body = et.SubElement(root, 'body')
+ table = et.SubElement(body, 'table')
+ table.set('align', 'center')
+ title_row = et.SubElement(table, 'tr')
+ test_name_title = et.SubElement(title_row, 'th')
+ test_name_title.text = 'Test Name'
+ test_results_title = et.SubElement(title_row, 'th')
+ test_results_title.text = 'Test Result'
+
+ for name, result in res.items():
+ row = et.SubElement(table, 'tr')
+ name_e = et.SubElement(row, 'td')
+ name_e.text = name
+ result_e = et.SubElement(row, 'td')
+ result_e.text = result
+ if result == self.return_codes[CTS_SUCCESS_CODE]:
+ result_e.set('bgcolor', CTS_COLOR_GREEN)
+ else:
+ result_e.set('bgcolor', CTS_COLOR_RED)
+
+ return et.tostring(root, method='html')
+
def resetAndRecord(self):
"""Resets boards, records test results in results dir"""
self.updateSerials()
@@ -516,13 +548,18 @@ class Cts(object):
self._parseOutput(dut_results, th_results)
pretty_results = self.prettyResults()
+ html_results = self.resultsAsHtml()
- dest = os.path.join(self.results_dir, self.dut.board, self.module + '.txt')
+ dest = os.path.join(
+ self.results_dir,
+ self.dut.board,
+ self.module + '.html'
+ )
if not os.path.exists(os.path.dirname(dest)):
os.makedirs(os.path.dirname(dest))
with open(dest, 'w') as fl:
- fl.write(pretty_results)
+ fl.write(html_results)
print pretty_results