[Piglit] [PATCH 2/6] dmesg: Use the dmesg class instead of the dmesg functions
Dylan Baker
baker.dylan.c at gmail.com
Tue Nov 12 07:54:00 PST 2013
This requires some minor changes, since the dmesg class returns either
None or [] (which are both falsy instances) instead of '' when not
giving a dmesg warning.
The biggest change in this patch is that the --dmesg option is removed.
This is possible since the dmesg module implements a dummy class for
non-posix systems.
Signed-off-by: Dylan Baker <baker.dylan.c at gmail.com>
---
framework/core.py | 3 +--
framework/exectest.py | 38 ++++----------------------------------
framework/gleantest.py | 4 ++--
piglit-run.py | 7 +------
tests/es3conform.tests | 4 ++--
tests/igt.tests | 4 ++--
tests/oglconform.tests | 4 ++--
7 files changed, 14 insertions(+), 50 deletions(-)
diff --git a/framework/core.py b/framework/core.py
index 2d5d0dc..b856f6f 100644
--- a/framework/core.py
+++ b/framework/core.py
@@ -388,14 +388,13 @@ class TestrunResult:
class Environment:
def __init__(self, concurrent=True, execute=True, include_filter=[],
- exclude_filter=[], valgrind=False, dmesg=False):
+ exclude_filter=[], valgrind=False):
self.concurrent = concurrent
self.execute = execute
self.filter = []
self.exclude_filter = []
self.exclude_tests = set()
self.valgrind = valgrind
- self.dmesg = dmesg
"""
The filter lists that are read in should be a list of string objects,
diff --git a/framework/exectest.py b/framework/exectest.py
index bfb33da..a6c7719 100644
--- a/framework/exectest.py
+++ b/framework/exectest.py
@@ -28,6 +28,7 @@ import types
import re
from core import Test, testBinDir, TestResult
+from dmesg import Dmesg
# Platform global variables
@@ -36,34 +37,7 @@ if 'PIGLIT_PLATFORM' in os.environ:
else:
PIGLIT_PLATFORM = ''
-
-def read_dmesg():
- proc = subprocess.Popen('dmesg', stdout=subprocess.PIPE)
- return proc.communicate()[0].rstrip('\n')
-
-def get_dmesg_diff(old, new):
- # Note that dmesg is a ring buffer, i.e. lines at the beginning may
- # be removed when new lines are added.
-
- # Get the last dmesg timestamp from the old dmesg as string.
- last = old.split('\n')[-1]
- ts = last[:last.find(']')+1]
- if ts == '':
- return ''
-
- # Find the last occurence of the timestamp.
- pos = new.find(ts)
- if pos == -1:
- return new # dmesg was completely overwritten by new messages
-
- while pos != -1:
- start = pos
- pos = new.find(ts, pos+len(ts))
-
- # Find the next line and return the rest of the string.
- nl = new.find('\n', start+len(ts))
- return new[nl+1:] if nl != -1 else ''
-
+dmesg = Dmesg()
# ExecTest: A shared base class for tests that simply runs an executable.
class ExecTest(Test):
@@ -104,19 +78,15 @@ class ExecTest(Test):
'--tool=memcheck']
i = 0
- dmesg_diff = ''
while True:
if self.skip_test:
out = "PIGLIT: {'result': 'skip'}\n"
err = ""
returncode = None
else:
- if env.dmesg:
- old_dmesg = read_dmesg()
(out, err, returncode) = \
self.get_command_result(command, fullenv)
- if env.dmesg:
- dmesg_diff = get_dmesg_diff(old_dmesg, read_dmesg())
+ dmesg_diff = dmesg.update_dmesg()
# https://bugzilla.gnome.org/show_bug.cgi?id=680214 is
# affecting many developers. If we catch it
@@ -257,7 +227,7 @@ class PlainExecTest(ExecTest):
outpiglit = map(lambda s: s[7:],
filter(lambda s: s.startswith('PIGLIT:'), outlines))
- if dmesg != '':
+ 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)
diff --git a/framework/gleantest.py b/framework/gleantest.py
index 88432e0..56968f5 100644
--- a/framework/gleantest.py
+++ b/framework/gleantest.py
@@ -43,7 +43,7 @@ class GleanTest(ExecTest):
if "{'result': 'skip'}" in out:
results['result'] = 'skip'
elif out.find('FAIL') >= 0:
- results['result'] = 'dmesg-fail' if dmesg != '' else 'fail'
+ results['result'] = 'dmesg-fail' if dmesg else 'fail'
else:
- results['result'] = 'dmesg-warn' if dmesg != '' else 'pass'
+ results['result'] = 'dmesg-warn' if dmesg else 'pass'
return out
diff --git a/piglit-run.py b/piglit-run.py
index 1d63cd4..0ba47ad 100755
--- a/piglit-run.py
+++ b/piglit-run.py
@@ -73,10 +73,6 @@ def main():
parser.add_argument("--valgrind",
action="store_true",
help="Run tests in valgrind's memcheck")
- parser.add_argument("--dmesg",
- action="store_true",
- help="Capture a difference in dmesg before and "
- "after each test")
parser.add_argument("testProfile",
metavar="<Path to test profile>",
help="Path to testfile to run")
@@ -113,8 +109,7 @@ def main():
exclude_filter=args.exclude_tests,
include_filter=args.include_tests,
execute=args.execute,
- valgrind=args.valgrind,
- dmesg=args.dmesg)
+ valgrind=args.valgrind)
# Change working directory to the root of the piglit directory
piglit_dir = path.dirname(path.realpath(sys.argv[0]))
diff --git a/tests/es3conform.tests b/tests/es3conform.tests
index b0e6ef0..65e48af 100644
--- a/tests/es3conform.tests
+++ b/tests/es3conform.tests
@@ -54,9 +54,9 @@ class GTFTest(ExecTest):
def interpretResult(self, out, returncode, results, dmesg):
mo = self.pass_re.search(out)
if mo is not None and int(mo.group('passed')) > 0:
- results['result'] = 'dmesg-warn' if dmesg != '' else 'pass'
+ results['result'] = 'dmesg-warn' if dmesg else 'pass'
else:
- results['result'] = 'dmesg-fail' if dmesg != '' else 'fail'
+ results['result'] = 'dmesg-fail' if dmesg else 'fail'
return out
def populateTests(runfile):
diff --git a/tests/igt.tests b/tests/igt.tests
index 0f19c82..fcfb1a3 100644
--- a/tests/igt.tests
+++ b/tests/igt.tests
@@ -54,11 +54,11 @@ class IGTTest(ExecTest):
def interpretResult(self, out, returncode, results, dmesg):
if returncode == 0:
- results['result'] = 'dmesg-warn' if dmesg != '' else 'pass'
+ results['result'] = 'dmesg-warn' if dmesg else 'pass'
elif returncode == 77:
results['result'] = 'skip'
else:
- results['result'] = 'dmesg-fail' if dmesg != '' else 'fail'
+ results['result'] = 'dmesg-fail' if dmesg else 'fail'
return out
def listTests(listname):
diff --git a/tests/oglconform.tests b/tests/oglconform.tests
index ace2f9c..8ce42a0 100644
--- a/tests/oglconform.tests
+++ b/tests/oglconform.tests
@@ -53,9 +53,9 @@ class OGLCTest(ExecTest):
if self.skip_re.search(out) is not None:
results['result'] = 'skip'
elif re.search('Total Passed : 1', out) is not None:
- results['result'] = 'dmesg-warn' if dmesg != '' else 'pass'
+ results['result'] = 'dmesg-warn' if dmesg else 'pass'
else:
- results['result'] = 'dmesg-fail' if dmesg != '' else 'fail'
+ results['result'] = 'dmesg-fail' if dmesg else 'fail'
return out
# Create a new top-level 'oglconform' category
--
1.8.1.5
More information about the Piglit
mailing list