summaryrefslogtreecommitdiff
path: root/tko
diff options
context:
space:
mode:
authorjadmanski <jadmanski@592f7852-d20e-0410-864c-8624ca9c26a4>2009-07-01 16:23:09 +0000
committerjadmanski <jadmanski@592f7852-d20e-0410-864c-8624ca9c26a4>2009-07-01 16:23:09 +0000
commit7654662a841d9593b4b753474f4850134700e176 (patch)
treed0b6606abbb44c2b9d69b0f5dc086f25f15e32c9 /tko
parentd11e31a25cecdafae2a7e0459e2a96f826a80b01 (diff)
Make some changes to the parser so that when multiple reasons are
logged not only are duplicates discarded, but also reason strings which are subsets of one another. So for example if a test logs X and then X,Y and then X,Y,Z then the final reason will only include X,Y,Z. Risk: Low Visibility: Should reduce the amount of duplication in final reasons for multi-reason failures. Signed-off-by: John Admanski <jadmanski@google.com> git-svn-id: svn://test.kernel.org/autotest/trunk@3346 592f7852-d20e-0410-864c-8624ca9c26a4
Diffstat (limited to 'tko')
-rw-r--r--tko/parsers/version_1.py2
-rw-r--r--tko/utils.py19
-rw-r--r--tko/utils_unittest.py27
3 files changed, 48 insertions, 0 deletions
diff --git a/tko/parsers/version_1.py b/tko/parsers/version_1.py
index fb82a99d..ab3a62c4 100644
--- a/tko/parsers/version_1.py
+++ b/tko/parsers/version_1.py
@@ -292,6 +292,8 @@ class parser(base.parser):
# update the status of a currently running test
if running_test:
running_reasons.add(line.reason)
+ running_reasons = tko_utils.drop_redundant_messages(
+ running_reasons)
sorted_reasons = sorted(running_reasons)
running_test.reason = ", ".join(sorted_reasons)
current_reason = running_test.reason
diff --git a/tko/utils.py b/tko/utils.py
index 8fc3711f..1bd1bf46 100644
--- a/tko/utils.py
+++ b/tko/utils.py
@@ -30,3 +30,22 @@ def find_toplevel_job_dir(start_dir):
return None
job_dir = os.path.dirname(job_dir)
return job_dir
+
+
+def drop_redundant_messages(messages):
+ """ Given a set of message strings discard any 'redundant' messages which
+ are simple a substring of the existing ones.
+
+ @param messages - a set of message strings
+
+ @return - a subset of messages with unnecessary strings dropped
+ """
+ sorted_messages = sorted(messages, key=len, reverse=True)
+ filtered_messages = set()
+ for message in sorted_messages:
+ for filtered_message in filtered_messages:
+ if message in filtered_message:
+ break
+ else:
+ filtered_messages.add(message)
+ return filtered_messages
diff --git a/tko/utils_unittest.py b/tko/utils_unittest.py
index 2a04191d..7d184079 100644
--- a/tko/utils_unittest.py
+++ b/tko/utils_unittest.py
@@ -98,6 +98,33 @@ class find_toplevel_job_dir_test(unittest.TestCase):
self.assertEqual(utils.find_toplevel_job_dir(jobdir), None)
+class drop_redundant_messages(unittest.TestCase):
+ def test_empty_set(self):
+ self.assertEqual(utils.drop_redundant_messages(set()), set())
+
+
+ def test_singleton(self):
+ self.assertEqual(utils.drop_redundant_messages(set(["abc"])),
+ set(["abc"]))
+
+
+ def test_distinct_messages(self):
+ self.assertEqual(utils.drop_redundant_messages(set(["abc", "def"])),
+ set(["abc", "def"]))
+
+
+ def test_one_unique_message(self):
+ self.assertEqual(
+ utils.drop_redundant_messages(set(["abc", "abcd", "abcde"])),
+ set(["abcde"]))
+
+
+ def test_some_unique_some_not(self):
+ self.assertEqual(
+ utils.drop_redundant_messages(set(["abc", "def", "abcdef",
+ "defghi", "cd"])),
+ set(["abcdef", "defghi"]))
+
if __name__ == "__main__":
unittest.main()