tests/igt: Add runtime environment checks
PATCH 1/1 tests/igt: Add runtime environment checks
This is one of the nice pieces that I've never ported from the old make based test runner. Note that we only use the result of the check when actually running the testcases so that enumerating tests still works as non-root on arbitrary machines.
--- tests/igt.tests | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-)
tests/igt.tests +31 -1
@@ -28,7 +28,7 @@ import sys import subprocess from os import path -from framework.core import testBinDir, TestProfile +from framework.core import testBinDir, TestProfile, TestResult from framework.exectest import ExecTest #############################################################################
@@ -39,6 +39,24 @@ from framework.exectest import ExecTest ##### automatically add all tests into the 'igt' category. ############################################################################# +def checkEnvironment(): + debugfs_path = "/sys/kernel/debug/dri" + if os.getuid() != 0: + print "Test Environment check: not root!" + return False + if not os.path.isdir(debugfs_path): + print "Test Environment check: debugfs not mounted properly!" + return False + for subdir in os.listdir(debugfs_path): + clients = open(os.path.join(debugfs_path, subdir, "clients"), 'r') + lines = clients.readlines() + if len(lines) > 2: + print "Test Environment check: other drm clients running!" + return False + + print "Test Environment check: Succeeded." + return True + if not os.path.exists(os.path.join(testBinDir, 'igt')): print "igt symlink not found!" sys.exit(0)
@@ -46,6 +64,8 @@ if not os.path.exists(os.path.join(testBinDir, 'igt')): # Chase the piglit/bin/igt symlink to find where the tests really live. igtTestRoot = path.join(path.realpath(path.join(testBinDir, 'igt')), 'tests') +igtEnvironmentOk = checkEnvironment() + profile = TestProfile() class IGTTest(ExecTest):
@@ -54,6 +74,9 @@ class IGTTest(ExecTest): self.timeout = 60*20 # 20 minutes deadline by default def interpretResult(self, out, returncode, results, dmesg): + if not igtEnvironmentOk: + return out + if returncode == 0: results['result'] = 'dmesg-warn' if dmesg != '' else 'pass' elif returncode == 77:
@@ -63,6 +86,13 @@ class IGTTest(ExecTest): return out def run(self, env): env.dmesg = True + if not igtEnvironmentOk: + results = TestResult() + results['result'] = 'skip' + results['info'] = unicode("Test Environment isn't OK") + + return results + return ExecTest.run(self, env) def listTests(listname):
Signature · 1 line
1.8.1.4
Quoted 5 lines · Daniel Vetter
This is one of the nice pieces that I've never ported from the old make based test runner. Note that we only use the result of the check when actually running the testcases so that enumerating tests still works as non-root on arbitrary machines.
So does this bail on the first test, or does this run for all tests? BTW, Damien said he had also implemented this.
Quoted 81 lines
Cc Ben Widawsky <[email protected]>Requested-by Ben Widawsky <[email protected]>Signed-off-by Daniel Vetter <[email protected]>--- tests/igt.tests | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-)tests/igt.tests +31
-1@@ -28,7 +28,7 @@ import sys import subprocess from os import path -from framework.core import testBinDir, TestProfile +from framework.core import testBinDir, TestProfile, TestResult from framework.exectest import ExecTest #############################################################################@@ -39,6 +39,24 @@ from framework.exectest import ExecTest ##### automatically add all tests into the 'igt' category. ############################################################################# +def checkEnvironment(): + debugfs_path = "/sys/kernel/debug/dri" + if os.getuid() != 0: + print "Test Environment check: not root!" + return False + if not os.path.isdir(debugfs_path): + print "Test Environment check: debugfs not mounted properly!" + return False + for subdir in os.listdir(debugfs_path): + clients = open(os.path.join(debugfs_path, subdir, "clients"), 'r') + lines = clients.readlines() + if len(lines) > 2: + print "Test Environment check: other drm clients running!" + return False + + print "Test Environment check: Succeeded." + return True + if not os.path.exists(os.path.join(testBinDir, 'igt')): print "igt symlink not found!" sys.exit(0)@@ -46,6 +64,8 @@ if not os.path.exists(os.path.join(testBinDir, 'igt')): # Chase the piglit/bin/igt symlink to find where the tests really live. igtTestRoot = path.join(path.realpath(path.join(testBinDir, 'igt')), 'tests') +igtEnvironmentOk = checkEnvironment() + profile = TestProfile() class IGTTest(ExecTest):@@ -54,6 +74,9 @@ class IGTTest(ExecTest): self.timeout = 60*20 # 20 minutes deadline by default def interpretResult(self, out, returncode, results, dmesg): + if not igtEnvironmentOk: + return out + if returncode == 0: results['result'] = 'dmesg-warn' if dmesg != '' else 'pass' elif returncode == 77:@@ -63,6 +86,13 @@ class IGTTest(ExecTest): return out def run(self, env): env.dmesg = True + if not igtEnvironmentOk: + results = TestResult() + results['result'] = 'skip' + results['info'] = unicode("Test Environment isn't OK") + + return results + return ExecTest.run(self, env) def listTests(listname):Signature · 1 line
1.8.1.4
Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 8 lines · Ben Widawsky
Quoted 5 lines · Daniel Vetter
This is one of the nice pieces that I've never ported from the old make based test runner. Note that we only use the result of the check when actually running the testcases so that enumerating tests still works as non-root on arbitrary machines.
So does this bail on the first test, or does this run for all tests?
It bails each test individually. Since otherwise enumerating them wouldn't work any more. I've hoped the commit message was clear about it.
Quoted 1 line
BTW, Damien said he had also implemented this.
Only in the make target he created, not in piglit itself. Imo we should have all the testrunner logic in one place, i.e. in the piglit sources. -Daniel
Quoted 85 lines
Quoted 82 lines
Cc Ben Widawsky <[email protected]>Requested-by Ben Widawsky <[email protected]>Signed-off-by Daniel Vetter <daniel.vetter-/[email protected]>--- tests/igt.tests | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-)tests/igt.tests +31
-1@@ -28,7 +28,7 @@ import sys import subprocess from os import path -from framework.core import testBinDir, TestProfile +from framework.core import testBinDir, TestProfile, TestResult from framework.exectest import ExecTest #############################################################################@@ -39,6 +39,24 @@ from framework.exectest import ExecTest ##### automatically add all tests into the 'igt' category. ############################################################################# +def checkEnvironment(): + debugfs_path = "/sys/kernel/debug/dri" + if os.getuid() != 0: + print "Test Environment check: not root!" + return False + if not os.path.isdir(debugfs_path): + print "Test Environment check: debugfs not mounted properly!" + return False + for subdir in os.listdir(debugfs_path): + clients = open(os.path.join(debugfs_path, subdir, "clients"), 'r') + lines = clients.readlines() + if len(lines) > 2: + print "Test Environment check: other drm clients running!" + return False + + print "Test Environment check: Succeeded." + return True + if not os.path.exists(os.path.join(testBinDir, 'igt')): print "igt symlink not found!" sys.exit(0)@@ -46,6 +64,8 @@ if not os.path.exists(os.path.join(testBinDir, 'igt')): # Chase the piglit/bin/igt symlink to find where the tests really live. igtTestRoot = path.join(path.realpath(path.join(testBinDir, 'igt')), 'tests') +igtEnvironmentOk = checkEnvironment() + profile = TestProfile() class IGTTest(ExecTest):@@ -54,6 +74,9 @@ class IGTTest(ExecTest): self.timeout = 60*20 # 20 minutes deadline by default def interpretResult(self, out, returncode, results, dmesg): + if not igtEnvironmentOk: + return out + if returncode == 0: results['result'] = 'dmesg-warn' if dmesg != '' else 'pass' elif returncode == 77:@@ -63,6 +86,13 @@ class IGTTest(ExecTest): return out def run(self, env): env.dmesg = True + if not igtEnvironmentOk: + results = TestResult() + results['result'] = 'skip' + results['info'] = unicode("Test Environment isn't OK") + + return results + return ExecTest.run(self, env) def listTests(listname):Signature · 1 line
1.8.1.4Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
A message that is not in the archive (sent off-list or not yet received): 20131126194619.GS27344-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org
Quoted 8 lines · Daniel Vetter
Quoted 7 lines · Ben Widawsky
Quoted 5 lines · Daniel Vetter
This is one of the nice pieces that I've never ported from the old make based test runner. Note that we only use the result of the check when actually running the testcases so that enumerating tests still works as non-root on arbitrary machines.
Quoted 4 lines
Quoted 1 line
So does this bail on the first test, or does this run for all tests?
It bails each test individually. Since otherwise enumerating them wouldn't work any more. I've hoped the commit message was clear about it.
It wasn't clear to me, though it seemed to be the case from the diff. I'd prefer an early bail, and just check once, and ideally, not generating a JSON file at all.
Quoted 6 lines
Quoted 2 lines
BTW, Damien said he had also implemented this.
Only in the make target he created, not in piglit itself. Imo we should have all the testrunner logic in one place, i.e. in the piglit sources. -Daniel
Damien, can you comment? I could have sworn you said something different on IRC. It sounded like exactly what I wanted.
Quoted 91 lines
Quoted 86 lines
Quoted 83 lines
Cc Ben Widawsky <[email protected]>Requested-by Ben Widawsky <[email protected]>Signed-off-by Daniel Vetter <daniel.vetter-/[email protected]>--- tests/igt.tests | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-)tests/igt.tests +31
-1@@ -28,7 +28,7 @@ import sys import subprocess from os import path -from framework.core import testBinDir, TestProfile +from framework.core import testBinDir, TestProfile, TestResult from framework.exectest import ExecTest #############################################################################@@ -39,6 +39,24 @@ from framework.exectest import ExecTest ##### automatically add all tests into the 'igt' category. ############################################################################# +def checkEnvironment(): + debugfs_path = "/sys/kernel/debug/dri" + if os.getuid() != 0: + print "Test Environment check: not root!" + return False + if not os.path.isdir(debugfs_path): + print "Test Environment check: debugfs not mounted properly!" + return False + for subdir in os.listdir(debugfs_path): + clients = open(os.path.join(debugfs_path, subdir, "clients"), 'r') + lines = clients.readlines() + if len(lines) > 2: + print "Test Environment check: other drm clients running!" + return False + + print "Test Environment check: Succeeded." + return True + if not os.path.exists(os.path.join(testBinDir, 'igt')): print "igt symlink not found!" sys.exit(0)@@ -46,6 +64,8 @@ if not os.path.exists(os.path.join(testBinDir, 'igt')): # Chase the piglit/bin/igt symlink to find where the tests really live. igtTestRoot = path.join(path.realpath(path.join(testBinDir, 'igt')), 'tests') +igtEnvironmentOk = checkEnvironment() + profile = TestProfile() class IGTTest(ExecTest):@@ -54,6 +74,9 @@ class IGTTest(ExecTest): self.timeout = 60*20 # 20 minutes deadline by default def interpretResult(self, out, returncode, results, dmesg): + if not igtEnvironmentOk: + return out + if returncode == 0: results['result'] = 'dmesg-warn' if dmesg != '' else 'pass' elif returncode == 77:@@ -63,6 +86,13 @@ class IGTTest(ExecTest): return out def run(self, env): env.dmesg = True + if not igtEnvironmentOk: + results = TestResult() + results['result'] = 'skip' + results['info'] = unicode("Test Environment isn't OK") + + return results + return ExecTest.run(self, env) def listTests(listname):Signature · 1 line
1.8.1.4Signature · 1 line
Ben Widawsky, Intel Open Source Technology CenterSignature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center
Quoted 6 lines · Ben Widawsky
Quoted 3 lines
Only in the make target he created, not in piglit itself. Imo we should have all the testrunner logic in one place, i.e. in the piglit sources. -Daniel
Damien, can you comment? I could have sworn you said something different on IRC. It sounded like exactly what I wanted.
What Daniel says is correct, the check is part of the runner wrapper, not piglit itself.
I'd rather have a environement check up-front and I don't mind where it lives (igt Vs piglit).
Signature · 1 line
Damien
A message that is not in the archive (sent off-list or not yet received): 20131126195332.GC32421-q+Y1yDQJ1rKUyhp/[email protected]
Quoted 5 lines · Damien Lespiau
Quoted 4 lines · Ben Widawsky
Quoted 3 lines
Only in the make target he created, not in piglit itself. Imo we should have all the testrunner logic in one place, i.e. in the piglit sources. -Daniel
Quoted 8 lines
Quoted 2 lines
Damien, can you comment? I could have sworn you said something different on IRC. It sounded like exactly what I wanted.
What Daniel says is correct, the check is part of the runner wrapper, not piglit itself.
I'd rather have a environement check up-front and I don't mind where it lives (igt Vs piglit).
The problem is that generating the testlist (or printing the commands) is a feature QA actually relies on. I also use it occasionally to quickly test igt library changes. So we can't bail that early. My patch bails fairly late, but I didn't see a better spot. -Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
A message that is not in the archive (sent off-list or not yet received): CAKMK7uEeyNShA8fAF82+prCgYTVd2G60GLVMCCVy56p2uRGeJA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 13 lines · Daniel Vetter
Quoted 11 lines · Damien Lespiau
Quoted 6 lines · Ben Widawsky
Quoted 3 lines
Only in the make target he created, not in piglit itself. Imo we should have all the testrunner logic in one place, i.e. in the piglit sources. -Daniel
Damien, can you comment? I could have sworn you said something different on IRC. It sounded like exactly what I wanted.
What Daniel says is correct, the check is part of the runner wrapper, not piglit itself.
Quoted 8 lines
Quoted 2 lines
I'd rather have a environement check up-front and I don't mind where it lives (igt Vs piglit).
The problem is that generating the testlist (or printing the commands) is a feature QA actually relies on. I also use it occasionally to quickly test igt library changes. So we can't bail that early. My patch bails fairly late, but I didn't see a better spot. -Daniel
I'm confused then about how this really improves my current situation.
Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 7 lines · Ben Widawsky
Quoted 5 lines
The problem is that generating the testlist (or printing the commands) is a feature QA actually relies on. I also use it occasionally to quickly test igt library changes. So we can't bail that early. My patch bails fairly late, but I didn't see a better spot. -Daniel
I'm confused then about how this really improves my current situation.
Quick recap of our irc discussion: I guess I'm trying to solve a slightly different problem, assuming that we always want some kind of test result. Hence everything fails (as of v2) and the result json contains the reason. I think that's the right thing to do for regression testing in a lab-like setting.
For developers I guess a little script or so some option to yell louder and faster than this here could still be useful. Otoh there'll always be test-specific failure modes (like runtime pm not configured properly) and imo it doesn't make much sense to filter for all of them beforehand. And otherwise I kinda expect that people will cook their own scripts anyway to kill X, Wayland and a bunch of deamons that get in the way and then run piglit with a few default options. -Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
A message that is not in the archive (sent off-list or not yet received): 1385453344-25217-1-git-send-email-daniel.vetter-/[email protected]
PATCH 1/1 tests/igt: Add runtime environment checks
This is one of the nice pieces that I've never ported from the old make based test runner. Note that we only use the result of the check when actually running the testcases so that enumerating tests still works as non-root on arbitrary machines.
v2: Fail the tests harder.
--- tests/igt.tests | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-)
tests/igt.tests +31 -1
@@ -28,7 +28,7 @@ import sys import subprocess from os import path -from framework.core import testBinDir, TestProfile +from framework.core import testBinDir, TestProfile, TestResult from framework.exectest import ExecTest #############################################################################
@@ -39,6 +39,24 @@ from framework.exectest import ExecTest ##### automatically add all tests into the 'igt' category. ############################################################################# +def checkEnvironment(): + debugfs_path = "/sys/kernel/debug/dri" + if os.getuid() != 0: + print "Test Environment check: not root!" + return False + if not os.path.isdir(debugfs_path): + print "Test Environment check: debugfs not mounted properly!" + return False + for subdir in os.listdir(debugfs_path): + clients = open(os.path.join(debugfs_path, subdir, "clients"), 'r') + lines = clients.readlines() + if len(lines) > 2: + print "Test Environment check: other drm clients running!" + return False + + print "Test Environment check: Succeeded." + return True + if not os.path.exists(os.path.join(testBinDir, 'igt')): print "igt symlink not found!" sys.exit(0)
@@ -46,6 +64,8 @@ if not os.path.exists(os.path.join(testBinDir, 'igt')): # Chase the piglit/bin/igt symlink to find where the tests really live. igtTestRoot = path.join(path.realpath(path.join(testBinDir, 'igt')), 'tests') +igtEnvironmentOk = checkEnvironment() + profile = TestProfile() class IGTTest(ExecTest):
@@ -54,6 +74,9 @@ class IGTTest(ExecTest): self.timeout = 60*20 # 20 minutes deadline by default def interpretResult(self, out, returncode, results, dmesg): + if not igtEnvironmentOk: + return out + if returncode == 0: results['result'] = 'dmesg-warn' if dmesg != '' else 'pass' elif returncode == 77:
@@ -63,6 +86,13 @@ class IGTTest(ExecTest): return out def run(self, env): env.dmesg = True + if not igtEnvironmentOk: + results = TestResult() + results['result'] = 'fail' + results['info'] = unicode("Test Environment isn't OK") + + return results + return ExecTest.run(self, env) def listTests(listname):
Signature · 1 line
1.8.1.4