Commit 90a25641 authored by Dylan Baker's avatar Dylan Baker

Use the new dmesg class

This actually makes use of the new dmesg class rather than the dmesg
functions. It touches a lot of files, but almost all of these changes
are code removal rather than code addition.

v5: - Fix dmesg handling in resume
Signed-off-by: Dylan Baker's avatarDylan Baker <baker.dylan.c@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu> (v4)
parent 3e7d2a3e
......@@ -42,6 +42,7 @@ except ImportError:
import json
import framework.status as status
from .dmesg import get_dmesg
from .threads import synchronized_self
from .log import log
......@@ -424,7 +425,7 @@ class Test(object):
def run(self):
raise NotImplementedError
def execute(self, env, path, json_writer):
def execute(self, env, path, json_writer, dmesg):
'''
Run the test.
......@@ -440,8 +441,10 @@ class Test(object):
try:
status("running")
time_start = time.time()
dmesg.update_dmesg()
self._test_hook_execute_run()
result = self.run(env)
result = dmesg.update_result(result)
time_end = time.time()
if 'time' not in result:
result['time'] = time_end - time_start
......@@ -476,11 +479,29 @@ class Group(dict):
pass
class TestProfile:
class TestProfile(object):
def __init__(self):
self.tests = Group()
self.test_list = {}
self.filters = []
# Sets a default of a Dummy
self.dmesg = False
@property
def dmesg(self):
""" Return dmesg """
return self.__dmesg
@dmesg.setter
def dmesg(self, not_dummy):
""" Set dmesg
Argumnts:
not_dummy -- if Truthy dmesg will try to get a PosixDmesg, if Falsy it
will get a DummyDmesg
"""
self.__dmesg = get_dmesg(not_dummy)
def flatten_group_hierarchy(self):
'''
......@@ -544,7 +565,7 @@ class TestProfile:
"""
name, test = pair
test.execute(env, name, json_writer)
test.execute(env, name, json_writer, self.dmesg)
# Multiprocessing.dummy is a wrapper around Threading that provides a
# multiprocessing compatible API
......
......@@ -35,34 +35,6 @@ else:
PIGLIT_PLATFORM = ''
def read_dmesg():
proc = subprocess.Popen(['dmesg', '-l', 'emerg,alert,crit,err,warn,notice'], 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 ''
# ExecTest: A shared base class for tests that simply runs an executable.
class ExecTest(Test):
def __init__(self, command):
......@@ -85,7 +57,7 @@ class ExecTest(Test):
return
self._command = value
def interpretResult(self, out, returncode, results, dmesg):
def interpretResult(self, out, returncode, results):
raise NotImplementedError
return out
......@@ -111,19 +83,14 @@ 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())
out, err, returncode = self.get_command_result(command,
fullenv)
# https://bugzilla.gnome.org/show_bug.cgi?id=680214 is
# affecting many developers. If we catch it
......@@ -158,7 +125,7 @@ class ExecTest(Test):
results['result'] = 'skip'
else:
results['result'] = 'fail'
out = self.interpretResult(out, returncode, results, dmesg_diff)
out = self.interpretResult(out, returncode, results)
crash_codes = [
# Unix: terminated by a signal
......@@ -202,7 +169,6 @@ class ExecTest(Test):
err, out)
results['returncode'] = returncode
results['command'] = ' '.join(self.command)
results['dmesg'] = dmesg_diff
else:
results = TestResult()
......@@ -257,16 +223,11 @@ class PlainExecTest(ExecTest):
# Prepend testBinDir to the path.
self._command[0] = os.path.join(testBinDir, self._command[0])
def interpretResult(self, out, returncode, results, dmesg):
def interpretResult(self, out, returncode, results):
outlines = out.split('\n')
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)
if len(outpiglit) > 0:
try:
for piglit in outpiglit:
......@@ -284,4 +245,5 @@ class PlainExecTest(ExecTest):
if 'result' not in results:
results['result'] = 'fail'
return out
......@@ -41,11 +41,11 @@ class GleanTest(ExecTest):
def command(self):
return self._command + self.globalParams
def interpretResult(self, out, returncode, results, dmesg):
def interpretResult(self, out, returncode, results):
if "{'result': 'skip'}" in out:
results['result'] = 'skip'
elif out.find('FAIL') >= 0:
results['result'] = 'dmesg-fail' if dmesg != '' else 'fail'
results['result'] = 'fail'
else:
results['result'] = 'dmesg-warn' if dmesg != '' else 'pass'
results['result'] = 'pass'
return out
......@@ -241,7 +241,7 @@ class ShaderTest(PlainExecTest):
self.__command = [runner] + self.__shader_runner_args
return self.__command
def run(self, env = Environment()):
def run(self, env):
""" Parse the test file's [require] block to determine which
executable is needed to run the test. Then run the executable on the
test file."""
......
......@@ -75,6 +75,7 @@ def main():
env.exclude_tests.add(key)
profile = core.merge_test_profiles(results.options['profile'])
profile.dmesg = env.dmesg
# This is resumed, don't bother with time since it wont be accurate anyway
profile.run(env, json_writer)
......
......@@ -151,6 +151,8 @@ def main():
json_writer.write_dict_key('tests')
json_writer.open_dict()
time_start = time.time()
# Set the dmesg type
profile.dmesg = args.dmesg
profile.run(env, json_writer)
time_end = time.time()
......
......@@ -53,12 +53,12 @@ class GTFTest(ExecTest):
def __init__(self, testpath):
ExecTest.__init__(self, [path.join(testBinDir, 'GTF3'), '-minfmt', '-width=113', '-height=47', '-run=' + testpath])
def interpretResult(self, out, returncode, results, dmesg):
def interpretResult(self, out, returncode, results):
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'] = 'pass'
else:
results['result'] = 'dmesg-fail' if dmesg != '' else 'fail'
results['result'] = 'fail'
return out
def populateTests(runfile):
......
......@@ -74,19 +74,19 @@ class IGTTest(ExecTest):
def __init__(self, binary, arguments=[]):
ExecTest.__init__(self, [path.join(igtTestRoot, binary)] + arguments)
def interpretResult(self, out, returncode, results, dmesg):
def interpretResult(self, out, returncode, results):
if not igtEnvironmentOk:
return out
if returncode == 0:
results['result'] = 'dmesg-warn' if dmesg != '' else 'pass'
results['result'] = 'pass'
elif returncode == 77:
results['result'] = 'skip'
else:
results['result'] = 'dmesg-fail' if dmesg != '' else 'fail'
results['result'] = 'fail'
return out
def run(self, env):
env.dmesg = True
if not igtEnvironmentOk:
results = TestResult()
results['result'] = 'fail'
......
......@@ -51,13 +51,13 @@ class OGLCTest(ExecTest):
def __init__(self, category, subtest):
ExecTest.__init__(self, [bin_oglconform, '-minFmt', '-v', '4', '-test', category, subtest])
def interpretResult(self, out, returncode, results, dmesg):
def interpretResult(self, out, returncode, results):
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'] = 'pass'
else:
results['result'] = 'dmesg-fail' if dmesg != '' else 'fail'
results['result'] = 'fail'
return out
# Create a new top-level 'oglconform' category
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment