[Piglit] [PATCH 1/2] framework/dmesg.py: add a filtering mechanism

Thomas Wood thomas.wood at intel.com
Wed Apr 30 09:12:13 PDT 2014


Only update the test status if at least one of the lines in the dmesg
output matches the given regular expression.

Signed-off-by: Thomas Wood <thomas.wood at intel.com>
---
 framework/dmesg.py | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/framework/dmesg.py b/framework/dmesg.py
index 3af8496..78b8d46 100644
--- a/framework/dmesg.py
+++ b/framework/dmesg.py
@@ -53,6 +53,7 @@ class LinuxDmesg(object):
         """ Create a dmesg instance """
         self._last_message = None
         self._new_messages = []
+        self.regex = None;
 
         # Populate self.dmesg initially, otherwise the first test will always
         # be full of dmesg crud.
@@ -101,6 +102,16 @@ class LinuxDmesg(object):
         # if update_dmesg() found new entries replace the results of the test
         # and subtests
         if self._new_messages:
+
+            if (self.regex is not None):
+                found = False
+                for line in self._new_messages:
+                    if self.regex.search(line) is not None:
+                        found = True
+                        break
+                if not found:
+                    return result
+
             result['result'] = replace(result['result'])
 
             # Replace any subtests
-- 
1.9.0



More information about the Piglit mailing list