[Piglit] [PATCH 5/6] igt.py: add docstrings.
Dylan Baker
baker.dylan.c at gmail.com
Mon Jan 19 09:38:13 PST 2015
In some cases this is really just about formatting.
---
tests/igt.py | 29 +++++++++++++++++++++--------
1 file changed, 21 insertions(+), 8 deletions(-)
diff --git a/tests/igt.py b/tests/igt.py
index 6c3613e..0dc6891 100644
--- a/tests/igt.py
+++ b/tests/igt.py
@@ -22,6 +22,14 @@
# OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
+"""IGTTest: Execute an intel-gpu-tools test.
+
+To use this, create an igt symlink in piglit/bin which points to the root
+of the intel-gpu-tools sources with the compiled tests. Piglit will
+automatically add all tests into the 'igt' category.
+
+"""
+
import os
import re
import sys
@@ -33,15 +41,13 @@ from framework.profile import TestProfile, Test
__all__ = ['profile']
-#############################################################################
-##### IGTTest: Execute an intel-gpu-tools test
-#####
-##### To use this, create an igt symlink in piglit/bin which points to the root
-##### of the intel-gpu-tools sources with the compiled tests. Piglit will
-##### automatically add all tests into the 'igt' category.
-#############################################################################
def check_environment():
+ """Check that the environment that piglit is running in is appropraite.
+
+ IGT requires root, debugfs to be mounted, and to be the only drm client.
+
+ """
debugfs_path = "/sys/kernel/debug/dri"
if os.getuid() != 0:
print "Test Environment check: not root!"
@@ -61,6 +67,7 @@ def check_environment():
print "Test Environment check: Succeeded."
return True
+
IGT_TEST_ROOT = os.environ.get(
'IGT_TEST_ROOT',
os.path.join(framework.core.PIGLIT_CONFIG.get('igt', 'path'), 'tests'))
@@ -73,10 +80,11 @@ if not (os.path.exists(os.path.join(IGT_TEST_ROOT, 'single-tests.txt'))
sys.exit(0)
IGT_ENVIRONMENT_OK = check_environment()
-
profile = TestProfile() # pylint: disable=invalid-name
+
class IGTTest(Test):
+ """Test class for running libdrm."""
def __init__(self, binary, arguments=None):
if arguments is None:
arguments = []
@@ -105,7 +113,9 @@ class IGTTest(Test):
super(IGTTest, self).run()
+
def list_tests(listname):
+ """Parse igt test list and return them as a list."""
with open(os.path.join(IGT_TEST_ROOT, listname + '.txt'), 'r') as f:
lines = (line.rstrip() for line in f.readlines())
@@ -122,7 +132,9 @@ def list_tests(listname):
return progs
+
def add_subtest_cases(test):
+ """Get subtest instances."""
proc = subprocess.Popen(
[os.path.join(IGT_TEST_ROOT, test), '--list-subtests'],
stdout=subprocess.PIPE,
@@ -151,6 +163,7 @@ def add_subtest_cases(test):
def populate_profile():
+ """Add all tests to the profile."""
tests = list_tests("single-tests") # pylint: disable=invalid-name
tests.extend(list_tests("multi-tests"))
--
2.2.1
More information about the Piglit
mailing list