[Piglit] [PATCH 15/35] framework/test: Make shader paths relative

Dylan Baker dylan at pnwbakers.com
Wed Apr 4 22:27:03 UTC 2018


Because they need to be relative at build time for serialization.
---
 framework/test/shader_test.py | 16 ++++++++++------
 tests/all.py                  |  7 +++++--
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/framework/test/shader_test.py b/framework/test/shader_test.py
index 3dc2c39..dbad16b 100644
--- a/framework/test/shader_test.py
+++ b/framework/test/shader_test.py
@@ -34,7 +34,7 @@ from framework import exceptions
 from framework import status
 from .base import ReducedProcessMixin, TestIsSkip
 from .opengl import FastSkipMixin, FastSkip
-from .piglit_test import PiglitBaseTest
+from .piglit_test import PiglitBaseTest, ROOT_DIR
 
 __all__ = [
     'ShaderTest',
@@ -67,7 +67,7 @@ class Parser(object):
         # cost. The first one looks for the start of the config block or raises
         # an exception. The second looks for the GL version or raises an
         # exception
-        with io.open(self.filename, mode='r', encoding='utf-8') as shader_file:
+        with io.open(os.path.join(ROOT_DIR, self.filename), 'r', encoding='utf-8') as shader_file:
             # The mock in python 3.3 doesn't support readlines(), so use
             # read().split() as a workaround
             lines = (l for l in shader_file.read().split('\n'))
@@ -183,7 +183,9 @@ class ShaderTest(FastSkipMixin, PiglitBaseTest):
     @PiglitBaseTest.command.getter
     def command(self):
         """ Add -auto and -fbo to the test command """
-        return self._command + ['-auto', '-fbo']
+        command = super(ShaderTest, self).command
+        shaderfile = os.path.join(ROOT_DIR, command[1])
+        return [command[0]] + [shaderfile, '-auto', '-fbo']
 
     @command.setter
     def command(self, new):
@@ -283,10 +285,12 @@ class MultiShaderTest(ReducedProcessMixin, PiglitBaseTest):
         self._process_skips()
         super(MultiShaderTest, self).run()
 
-    @PiglitBaseTest.command.getter  # pylint: disable=no-member
+    @PiglitBaseTest.command.getter
     def command(self):
-        """Add -auto to the test command."""
-        return self._command + ['-auto', '-report-subtests']
+        command = super(MultiShaderTest, self).command
+        shaderfiles = (x for x in command[1:] if not x.startswith('-'))
+        shaderfiles = [os.path.join(ROOT_DIR, s) for s in shaderfiles]
+        return [command[0]] + shaderfiles + ['-auto', '-report-subtests']
 
     def _is_subtest(self, line):
         return line.startswith('PIGLIT TEST:')
diff --git a/tests/all.py b/tests/all.py
index 6a2b990..cf6ee5a 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -21,7 +21,9 @@ from framework.driver_classifier import DriverClassifier
 from framework.test import (PiglitGLTest, PiglitBaseTest,
                             GLSLParserTest, GLSLParserNoConfigError)
 from framework.test.shader_test import ShaderTest, MultiShaderTest
-from framework.test.piglit_test import ASMParserTest, BuiltInConstantsTest
+from framework.test.piglit_test import (
+    ASMParserTest, BuiltInConstantsTest, ROOT_DIR
+)
 from .py_modules.constants import TESTS_DIR, GENERATED_TESTS_DIR
 
 __all__ = ['profile']
@@ -304,8 +306,9 @@ for basedir in [TESTS_DIR, GENERATED_TESTS_DIR]:
         for filename in filenames:
             testname, ext = os.path.splitext(filename)
             if ext == '.shader_test':
+                dirname = os.path.relpath(dirpath, ROOT_DIR)
                 if PROCESS_ISOLATION:
-                    test = ShaderTest.new(os.path.join(dirpath, filename))
+                    test = ShaderTest.new(os.path.join(dirname, filename))
                 else:
                     shader_tests[groupname].append(os.path.join(dirpath, filename))
                     continue
-- 
git-series 0.9.1


More information about the Piglit mailing list