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.
Signed-off-by: Dylan Baker <baker.dyla...@gmail.com> --- framework/core.py | 30 ++++++++++++++++++++++++----- framework/exectest.py | 50 ++++++------------------------------------------ framework/gleantest.py | 6 +++--- framework/shader_test.py | 2 +- piglit-run.py | 5 +++-- tests/es3conform.py | 6 +++--- tests/igt.py | 8 ++++---- tests/oglconform.py | 6 +++--- 8 files changed, 48 insertions(+), 65 deletions(-) diff --git a/framework/core.py b/framework/core.py index da2a716..01aa1b5 100644 --- a/framework/core.py +++ b/framework/core.py @@ -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 @@ -354,14 +355,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, @@ -424,7 +424,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 +440,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 +478,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 +564,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 diff --git a/framework/exectest.py b/framework/exectest.py index 6af1496..4f88dbc 100644 --- a/framework/exectest.py +++ b/framework/exectest.py @@ -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 diff --git a/framework/gleantest.py b/framework/gleantest.py index bfef61a..4abb54a 100644 --- a/framework/gleantest.py +++ b/framework/gleantest.py @@ -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 diff --git a/framework/shader_test.py b/framework/shader_test.py index 95bc92e..48697a7 100755 --- a/framework/shader_test.py +++ b/framework/shader_test.py @@ -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.""" diff --git a/piglit-run.py b/piglit-run.py index 3c33c76..faf3adb 100755 --- a/piglit-run.py +++ b/piglit-run.py @@ -109,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])) @@ -151,6 +150,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() diff --git a/tests/es3conform.py b/tests/es3conform.py index 1995a9c..dadebb9 100644 --- a/tests/es3conform.py +++ b/tests/es3conform.py @@ -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): diff --git a/tests/igt.py b/tests/igt.py index 2c107f3..b5c9f3c 100644 --- a/tests/igt.py +++ b/tests/igt.py @@ -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' diff --git a/tests/oglconform.py b/tests/oglconform.py index b9b79b8..857d0cd 100644 --- a/tests/oglconform.py +++ b/tests/oglconform.py @@ -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 -- 1.8.5.3 _______________________________________________ Piglit mailing list Piglit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/piglit