aboutsummaryrefslogtreecommitdiff
path: root/automation/clients/report/dejagnu/manifest.py
diff options
context:
space:
mode:
authorLuis Lozano <llozano@chromium.org>2013-03-15 14:44:13 -0700
committerChromeBot <chrome-bot@google.com>2013-03-15 15:51:37 -0700
commitf81680c018729fd4499e1e200d04b48c4b90127c (patch)
tree940608da8374604b82edfdb2d7df55d065f05d4c /automation/clients/report/dejagnu/manifest.py
parent2296ee0b914aba5bba07becab4ff68884ce9b8a5 (diff)
downloadtoolchain-utils-f81680c018729fd4499e1e200d04b48c4b90127c.tar.gz
Cleaned up directory after copy of tools from perforce directory
Got rid of stale copies of some tools like "crosperf" and moved all files under v14 directory (that came from perforce) into the top directory. BUG=None TEST=None Change-Id: I408d17a36ceb00e74db71403d2351fd466a14f8e Reviewed-on: https://gerrit-int.chromium.org/33887 Tested-by: Luis Lozano <llozano@chromium.org> Reviewed-by: Yunlian Jiang <yunlian@google.com> Commit-Queue: Luis Lozano <llozano@chromium.org>
Diffstat (limited to 'automation/clients/report/dejagnu/manifest.py')
-rw-r--r--automation/clients/report/dejagnu/manifest.py104
1 files changed, 104 insertions, 0 deletions
diff --git a/automation/clients/report/dejagnu/manifest.py b/automation/clients/report/dejagnu/manifest.py
new file mode 100644
index 00000000..75d907cd
--- /dev/null
+++ b/automation/clients/report/dejagnu/manifest.py
@@ -0,0 +1,104 @@
+# /usr/bin/python2.6
+#
+# Copyright 2011 Google Inc. All Rights Reserved.
+# Author: kbaclawski@google.com (Krystian Baclawski)
+#
+
+__author__ = 'kbaclawski@google.com (Krystian Baclawski)'
+
+from collections import namedtuple
+from cStringIO import StringIO
+import logging
+
+from summary import DejaGnuTestResult
+
+
+class Manifest(namedtuple('Manifest', 'tool board results')):
+ """Stores a list of unsuccessful tests.
+
+ Any line that starts with '#@' marker carries auxiliary data in form of a
+ key-value pair, for example:
+
+ #@ tool: *
+ #@ board: unix
+
+ So far tool and board parameters are recognized. Their value can contain
+ arbitrary glob expression. Based on aforementioned parameters given manifest
+ will be applied for all test results, but only in selected test runs. Note
+ that all parameters are optional. Their default value is '*' (i.e. for all
+ tools/boards).
+
+ The meaning of lines above is as follows: corresponding test results to follow
+ should only be suppressed if test run was performed on "unix" board.
+
+ The summary line used to build the test result should have this format:
+
+ attrlist | UNRESOLVED: gcc.dg/unroll_1.c (test for excess errors)
+ ^^^^^^^^ ^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^
+ optional result name variant
+ attributes
+ """
+ SUPPRESSIBLE_RESULTS = ['FAIL', 'UNRESOLVED', 'XPASS', 'ERROR']
+
+ @classmethod
+ def FromDejaGnuTestRun(cls, test_run):
+ results = [result for result in test_run.results
+ if result.result in cls.SUPPRESSIBLE_RESULTS]
+
+ return cls(test_run.tool, test_run.board, results)
+
+ @classmethod
+ def FromFile(cls, filename):
+ """Creates manifest instance from a file in format described above."""
+ params = {}
+ results = []
+
+ with open(filename, 'r') as manifest_file:
+ for line in manifest_file:
+ if line.startswith('#@'):
+ # parse a line with a parameter
+ try:
+ key, value = line[2:].split(':', 1)
+ except ValueError:
+ logging.warning('Malformed parameter line: "%s".', line)
+ else:
+ params[key.strip()] = value.strip()
+ else:
+ # remove comment
+ try:
+ line, _ = line.split('#', 1)
+ except ValueError:
+ pass
+
+ line = line.strip()
+
+ if line:
+ # parse a line with a test result
+ result = DejaGnuTestResult.FromLine(line)
+
+ if result:
+ results.append(result)
+ else:
+ logging.warning('Malformed test result line: "%s".', line)
+
+ tool = params.get('tool', '*')
+ board = params.get('board', '*')
+
+ return cls(tool, board, results)
+
+ def Generate(self):
+ """Dumps manifest to string."""
+ text = StringIO()
+
+ for name in ['tool', 'board']:
+ text.write('#@ {0}: {1}\n'.format(name, getattr(self, name)))
+
+ text.write('\n')
+
+ for result in sorted(self.results, key=lambda r: r.result):
+ text.write('{0}\n'.format(result))
+
+ return text.getvalue()
+
+ def __iter__(self):
+ return iter(self.results)