[Piglit] [PATCH 3/6] tests/igt.py: simplify setting the root
Dylan Baker
baker.dylan.c at gmail.com
Mon Jan 19 09:38:11 PST 2015
This uses dict.get() to simplify and streamline the logic.
---
tests/igt.py | 20 +++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)
diff --git a/tests/igt.py b/tests/igt.py
index 55b0f4a..f0064fc 100644
--- a/tests/igt.py
+++ b/tests/igt.py
@@ -61,16 +61,14 @@ def checkEnvironment():
print "Test Environment check: Succeeded."
return True
-if 'IGT_TEST_ROOT' in os.environ:
- igtTestRoot = os.environ['IGT_TEST_ROOT']
-else:
- igtTestRoot = os.path.join(framework.core.PIGLIT_CONFIG.get('igt', 'path'),
- 'tests')
- assert os.path.exists(igtTestRoot)
+IGT_TEST_ROOT = os.environ.get(
+ 'IGT_TEST_ROOT',
+ os.path.join(framework.core.PIGLIT_CONFIG.get('igt', 'path'), 'tests'))
+assert os.path.exists(IGT_TEST_ROOT)
# check for the test lists
-if not (os.path.exists(os.path.join(igtTestRoot, 'single-tests.txt'))
- and os.path.exists(os.path.join(igtTestRoot, 'multi-tests.txt'))):
+if not (os.path.exists(os.path.join(IGT_TEST_ROOT, 'single-tests.txt'))
+ and os.path.exists(os.path.join(IGT_TEST_ROOT, 'multi-tests.txt'))):
print "intel-gpu-tools test lists not found."
sys.exit(0)
@@ -83,7 +81,7 @@ class IGTTest(Test):
if arguments is None:
arguments = []
super(IGTTest, self).__init__(
- [os.path.join(igtTestRoot, binary)] + arguments)
+ [os.path.join(IGT_TEST_ROOT, binary)] + arguments)
self.timeout = 600
def interpret_result(self):
@@ -108,7 +106,7 @@ class IGTTest(Test):
super(IGTTest, self).run()
def listTests(listname):
- with open(os.path.join(igtTestRoot, listname + '.txt'), 'r') as f:
+ with open(os.path.join(IGT_TEST_ROOT, listname + '.txt'), 'r') as f:
lines = (line.rstrip() for line in f.readlines())
found_header = False
@@ -129,7 +127,7 @@ tests.extend(listTests("multi-tests"))
def addSubTestCases(test):
proc = subprocess.Popen(
- [os.path.join(igtTestRoot, test), '--list-subtests'],
+ [os.path.join(IGT_TEST_ROOT, test), '--list-subtests'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
env=os.environ.copy(),
--
2.2.1
More information about the Piglit
mailing list