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.

Cc: Ben Widawsky <b...@bwidawsk.net>
Requested-by: Ben Widawsky <b...@bwidawsk.net>
Signed-off-by: Daniel Vetter <daniel.vet...@ffwll.ch>
---
 tests/igt.tests | 32 +++++++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/tests/igt.tests b/tests/igt.tests
index f3884925deaa..df747e3fac78 100644
--- a/tests/igt.tests
+++ b/tests/igt.tests
@@ -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):
-- 
1.8.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reply via email to