Skip to contentSkip to conversation

tests/igt: Add runtime environment checks

PATCH In review Daniel Vetter 5 participants 9 messages Nov 26, 2013 6 messages not in the archive

lore
Share & tools
lore
#0 lore raw

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
index f3884925deaa..8d02c1a60255 100644
@@ -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
#1 lore raw
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
---
 tests/igt.tests | 32 +++++++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)
tests/igt.tests +31 -1
index f3884925deaa..8d02c1a60255 100644
@@ -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]

#3 lore raw
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
---
 tests/igt.tests | 32 +++++++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)
tests/igt.tests +31 -1
index f3884925deaa..8d02c1a60255 100644
@@ -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
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

#5 lore raw
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
---
 tests/igt.tests | 32 +++++++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)
tests/igt.tests +31 -1
index f3884925deaa..8d02c1a60255 100644
@@ -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
Signature · 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
#6 lore raw
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]

#8 lore raw
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

#10 lore raw
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]

#12 lore raw
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]

#14 lore raw

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
index f3884925deaa..df747e3fac78 100644
@@ -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