From 0e9f0961abdd3f5df494c59cec290159a6f95c33 Mon Sep 17 00:00:00 2001 From: Michal Suchanek Date: Thu, 2 Sep 2010 12:52:06 +0200 Subject: [PATCH] Add kernel message logging in test runs. --- framework/core.py | 17 +++++++++++++++++ framework/exectest.py | 8 ++++++++ framework/gleantest.py | 8 ++++++++ piglit-run.py | 5 ++++- 4 files changed, 37 insertions(+), 1 deletion(-) diff --git a/framework/core.py b/framework/core.py index b237df696..e8c45b065 100644 --- a/framework/core.py +++ b/framework/core.py @@ -264,6 +264,9 @@ class Environment: self.execute = True self.filter = [] self.exclude_filter = [] + self.dmesg = False + if platform.system() != 'Windows': + self.dmesg = True def run(self, command): try: @@ -292,6 +295,7 @@ class Test: raise NotImplementedError def doRun(self, env, path): + self.dmesg = env.dmesg # Exclude tests that don't match the filter regexp if len(env.filter) > 0: if not True in map(lambda f: f.search(path) != None, env.filter): @@ -355,6 +359,19 @@ class Test: if len(ignored) > 0: results['errors_ignored'] = ignored + # Extract lines appended to new compared to old + def message_diff(self, old, new): + offset = 0 + new = new[1:] # Skip possible first incomplete line + while offset < len(new): + l = min(len(old), len(new) - offset) + if(old[len(old)-l:] == new[0:len(new)-offset]): + if(offset == 0): + return [] + else: + return new[len(new)-offset+1:] + offset += 1 + return new class Group(dict): def doRun(self, env, path): diff --git a/framework/exectest.py b/framework/exectest.py index 46b041be6..633a29eb9 100644 --- a/framework/exectest.py +++ b/framework/exectest.py @@ -48,6 +48,7 @@ class PlainExecTest(Test): for e in self.env: fullenv[e] = str(self.env[e]) + dmesg_sav = os.popen("dmesg").readlines() proc = subprocess.Popen( self.command, stdout=subprocess.PIPE, @@ -57,6 +58,13 @@ class PlainExecTest(Test): ) out, err = proc.communicate() + if self.dmesg: + dmesg = os.popen("dmesg").readlines() + errlines = out.split('\n') + errlines += self.message_diff(dmesg_sav, dmesg); + if len(errlines) > 0: + err = '\n'.join(errlines) + outlines = out.split('\n') outpiglit = map(lambda s: s[7:], filter(lambda s: s.startswith('PIGLIT:'), outlines)) diff --git a/framework/gleantest.py b/framework/gleantest.py index 4cabe4f9a..c1408b0cf 100644 --- a/framework/gleantest.py +++ b/framework/gleantest.py @@ -52,6 +52,7 @@ class GleanTest(Test): checkDir(os.path.join(gleanResultDir(), self.name), False) + dmesg_sav = os.popen("dmesg").readlines() glean = subprocess.Popen( [gleanExecutable(), "-r", os.path.join(gleanResultDir(), self.name), "-o", @@ -65,6 +66,13 @@ class GleanTest(Test): out, err = glean.communicate() + if self.dmesg: + dmesg = os.popen("dmesg").readlines() + errlines = out.split('\n') + errlines += self.message_diff(dmesg_sav, dmesg); + if len(errlines) > 0: + err = '\n'.join(errlines) + results['result'] = 'pass' if glean.returncode != 0 or out.find('FAIL') >= 0: results['result'] = 'fail' diff --git a/piglit-run.py b/piglit-run.py index 9f0eca670..7609c12ff 100755 --- a/piglit-run.py +++ b/piglit-run.py @@ -45,6 +45,7 @@ Options: -x regexp, --exclude-tests=regexp Excludey matching tests (can be used more than once) -n name, --name=name Name of the testrun + -D, --no-dmesg Do not log kernel messages Example: %(progName)s tests/all.tests results/all @@ -64,7 +65,7 @@ def main(): env = core.Environment() try: - options, args = getopt(sys.argv[1:], "hdt:n:x:", [ "help", "dry-run", "tests=", "name=", "exclude-tests=" ]) + options, args = getopt(sys.argv[1:], "hdDt:n:x:", [ "help", "dry-run", "no-dmesg", "tests=", "name=", "exclude-tests=" ]) except GetoptError: usage() @@ -75,6 +76,8 @@ def main(): usage() elif name in ('-d', '--dry-run'): env.execute = False + elif name in ('-D', '--no-dmesg'): + env.dmesg = False elif name in ('-t', '--tests'): env.filter[:0] = [re.compile(value)] elif name in ('-x', '--exclude-tests'): -- 2.11.4.GIT