[Piglit] [PATCH 3/6] dmesg: setup dmesg to be able to mark a test warn or fail
Dylan Baker
baker.dylan.c at gmail.com
Tue Nov 12 07:54:01 PST 2013
This gives the dmesg class lists of statuses that will make a test a
warn or a fail, it includes a few basic checks, namely i915 errors and
that tests have not segfaulted.
Signed-off-by: Dylan Baker <baker.dylan.c at gmail.com>
---
framework/dmesg.py | 36 ++++++++++++++++++++++++++++++++----
framework/exectest.py | 22 +++++++++++++++-------
2 files changed, 47 insertions(+), 11 deletions(-)
diff --git a/framework/dmesg.py b/framework/dmesg.py
index 9a23c14..edbea88 100644
--- a/framework/dmesg.py
+++ b/framework/dmesg.py
@@ -22,6 +22,7 @@
""" Module implementing classes for reading posix dmesg """
import os
+import re
import subprocess
from threads import synchronized_self
@@ -29,8 +30,10 @@ __all__ = ['Dmesg']
# plain text list of statuses to be considered either a warn or a fail, any
# statuses not on this list will simply be ignored.
-WARN_STATUSES = []
-FAIL_STATUSES = []
+WARN_STATUSES = ['segfault']
+FAIL_STATUSES = ['\[drm:.*\] \*ERROR\*',
+ '\[drm\] stuck on [a-zA-Z]* ring',
+ '\[drm\] GPU crash dump saved']
class PosixDmesg(object):
@@ -45,6 +48,9 @@ class PosixDmesg(object):
only be considered authoratative when running non-concurrently.
"""
+ _warns = [re.compile(r) for r in WARN_STATUSES]
+ _fails = [re.compile(r) for r in FAIL_STATUSES]
+
def __init__(self):
""" Create a dmesg instance """
self.dmesg = []
@@ -57,10 +63,32 @@ class PosixDmesg(object):
@synchronized_self
def update_dmesg(self):
- """ Call dmesg and look for changes. """
+ """ Call dmesg and look for changes
+
+ This class calls a helper that checks dmesg for changes, and then
+ processes those changes looking for warns and fails according to the
+ WARN_STATUSES and FAIL_STATUSES variables.
+
+ If there are no warns or fails it will return None. Otherwise it will
+ return a tuple containing a list of warns and a list of fails
+ respectively
+
+ """
+ def is_error(type, error):
+ """ Filter statuses that are warns or fails """
+ for pattern in type:
+ if pattern.search(error):
+ return True
+ return False
+
self._call_dmesg()
+ warns = [s for s in self._new_messages if is_error(self._warns, s)]
+ fails = [s for s in self._new_messages if is_error(self._fails, s)]
- return self._new_messages
+ if warns or fails:
+ return (warns, fails)
+ else:
+ return None
def _call_dmesg(self):
""" Call dmesg using subproces.check_output
diff --git a/framework/exectest.py b/framework/exectest.py
index a6c7719..827840b 100644
--- a/framework/exectest.py
+++ b/framework/exectest.py
@@ -86,7 +86,7 @@ class ExecTest(Test):
else:
(out, err, returncode) = \
self.get_command_result(command, fullenv)
- dmesg_diff = dmesg.update_dmesg()
+ dmesg_status = dmesg.update_dmesg()
# https://bugzilla.gnome.org/show_bug.cgi?id=680214 is
# affecting many developers. If we catch it
@@ -121,7 +121,8 @@ class ExecTest(Test):
results['result'] = 'skip'
else:
results['result'] = 'fail'
- out = self.interpretResult(out, returncode, results, dmesg_diff)
+ out = self.interpretResult(out, returncode, results,
+ dmesg_status)
crash_codes = [
# Unix: terminated by a signal
@@ -165,7 +166,10 @@ class ExecTest(Test):
err, out)
results['returncode'] = returncode
results['command'] = ' '.join(self.command)
- results['dmesg'] = dmesg_diff
+ if dmesg_status:
+ results['dmesg'] = {}
+ results['dmesg']['warns'] = dmesg_status[0]
+ results['dmesg']['fails'] = dmesg_status[1]
self.handleErr(results, err)
@@ -227,10 +231,14 @@ class PlainExecTest(ExecTest):
outpiglit = map(lambda s: s[7:],
filter(lambda s: s.startswith('PIGLIT:'), outlines))
- if dmesg:
- outpiglit = map(lambda s: s.replace("'pass'", "'dmesg-warn'"), outpiglit)
- outpiglit = map(lambda s: s.replace("'warn'", "'dmesg-warn'"), outpiglit)
- outpiglit = map(lambda s: s.replace("'fail'", "'dmesg-fail'"), outpiglit)
+ try:
+ if dmesg[1]:
+ outpiglit = map(lambda s: s.replace("pass", "fail"), outpiglit)
+ outpiglit = map(lambda s: s.replace("warn", "fail"), outpiglit)
+ elif dmesg[0]:
+ outpiglit = map(lambda s: s.replace("pass", "warn"), outpiglit)
+ except TypeError:
+ pass
if len(outpiglit) > 0:
try:
--
1.8.1.5
More information about the Piglit
mailing list