[Piglit] [PATCH] framework: keep track of running stats and display them
Ilia Mirkin
imirkin at alum.mit.edu
Fri Feb 14 23:28:11 PST 2014
This will display a line that looks like:
[00076/11064] fail: 1, pass: 55, skip: 19 Running Test(s): 00075
Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
---
framework/core.py | 11 +++++++----
framework/log.py | 19 +++++++++++++++----
2 files changed, 22 insertions(+), 8 deletions(-)
diff --git a/framework/core.py b/framework/core.py
index ac25917..4bcaa82 100644
--- a/framework/core.py
+++ b/framework/core.py
@@ -435,6 +435,7 @@ class Test(object):
'''
log_current = log.get_current()
+ counts = {}
# Run the test
if env.execute:
try:
@@ -462,15 +463,17 @@ class Test(object):
result['traceback'] = \
"".join(traceback.format_tb(sys.exc_info()[2]))
- if 'subtest' in result and len(result['subtest'].keys()) > 1:
- for test in result['subtest'].keys():
- result['result'] = result['subtest'][test]
+ if 'subtest' in result and len(result['subtest']) > 1:
+ for test in result['subtest']:
+ res = result['result'] = result['subtest'][test]
+ counts[res] = counts.get(res, 0) + 1
json_writer.write_dict_item(os.path.join(path, test), result)
else:
+ counts[result['result']] = 1
json_writer.write_dict_item(path, result)
else:
log.log()
- log.mark_complete(log_current)
+ log.mark_complete(log_current, counts)
class Group(dict):
diff --git a/framework/log.py b/framework/log.py
index 01c3a32..ba045da 100644
--- a/framework/log.py
+++ b/framework/log.py
@@ -37,22 +37,30 @@ class Log(object):
self.__running = []
self.__generator = (x for x in xrange(self.__total))
self.__pad = len(str(self.__total))
+ self.__summary = {}
+
+ def _summary(self):
+ return ", ".join("{0}: {1}".format(k, self.__summary[k])
+ for k in sorted(self.__summary))
def _running(self):
return "Running Test(s): {}".format(
" ".join([str(x).zfill(self.__pad) for x in self.__running]))
def _percent(self):
- return "[{0}/{1}]".format(str(self.__complete).zfill(self.__pad),
- str(self.__total).zfill(self.__pad))
+ return "[{0}/{1}] {2}".format(
+ str(self.__complete).zfill(self.__pad),
+ str(self.__total).zfill(self.__pad),
+ self._summary())
@synchronized_self
- def mark_complete(self, value):
+ def mark_complete(self, value, counts):
""" Used to mark a test as complete in the log
Arguments:
value -- the test number to mark complete
-
+ counts -- a map from result to count of tests with that result
+
"""
# Mark running complete
assert value in self.__running
@@ -61,6 +69,9 @@ class Log(object):
# increment the number of completed tests
self.__complete += 1
+ for k, v in counts.iteritems():
+ self.__summary[k] = self.__summary.get(k, 0) + v
+
@synchronized_self
def log(self):
""" Print to the screen
--
1.8.3.2
More information about the Piglit
mailing list