[Piglit] [PATCH] all.py: filter directories traversed to find shader tests
Brian Paul
brianp at vmware.com
Tue Oct 24 19:17:43 UTC 2017
On 10/24/2017 11:01 AM, Dylan Baker wrote:
> Quoting Brian Paul (2017-10-23 10:47:50)
>> The script searches all files under tests/ and generated_tests/ for
>> files ending in ".shader_test". For each match, a ShaderTest() object
>> is created and added to the test list.
>>
>> For GL extensions or versions not supported by the driver, this is
>> wasted effort.
>>
>> This patch looks for directories under spec/ and tries to determine if
>> the extension/feature is actually supported by the current driver. If
>> not, it's skipped.
>>
>> This somewhat reduces Piglit start up time, but substantially more
>> time is spent in the ShaderTest() constructor which actually opens
>> and parses each file to determine its GL/ES dependencies. I'll try
>> to address that in the future.
>>
>> v2:
>> Use a different approach suggested by Dylan:
>> if not is_dirpath_feature_supported(dirpath):
>> continue
>> Also, fix naming conventions and minor formatting issues.
>> ---
>> tests/all.py | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
>> 1 file changed, 56 insertions(+), 1 deletion(-)
>>
>> diff --git a/tests/all.py b/tests/all.py
>> index fd3371a..0db1288 100644
>> --- a/tests/all.py
>> +++ b/tests/all.py
>> @@ -8,11 +8,13 @@ import collections
>> import itertools
>> import os
>> import platform
>> +import re
>>
>> import six
>> from six.moves import range
>>
>> from framework import grouptools
>> +from framework.test import opengl
>> from framework import options
>> from framework.profile import TestProfile
>> from framework.driver_classifier import DriverClassifier
>> @@ -204,16 +206,69 @@ def power_set(s):
>> result.append(p + [s[-1]])
>> return result
>>
>> +
>> +def gl_extension_supported(ext_name):
>> + """Is the named OpenGL extension supported?"""
>> + return ext_name in wfl_info.gl_extensions
>> +
>> +def is_feature_directory_supported(dir_name):
>> + """Determine if dir_name specifies an OpenGL feature (extension or GL
>> + version) which is supported by the host. If we return False, it means
>> + the extension/version is definitely not supported. If we return True,
>> + it means the extension/version is possibly suppported. We're a little
>> + fuzzy because we don't yet parse all the directory name possibilities
>> + (like ES tests).
>> + """
>> + if dir_name[:4] in {"amd_", "arb_", "ati_", "ext_", "khr_", "oes_"}:
>> + # The directory is a GL extension name, but of the format "arb_foo_bar"
>> + # instead of "GL_ARB_foo_bar". We convert the former into the later
>> + # and check if the extension is supported.
>> + extName = "GL_" + dir_name[0:4].upper() + dir_name[4:]
>
> If you could convert this to ext_name,
>
>> + return gl_extension_supported(extName)
>> + elif re.match("gl-\d\.\d+", dir_name[0:3]):
>> + # The directory is a GL version
>> + version = dir_name[3:]
>> + return float(version) <= float(wfl_info.gl_version)
>> + elif re.match("glsl-\d\.\d+", dir_name[0:5]):
>> + # The directory is a GLSL version
>> + version = dir_name[5:]
>> + return float(version) <= float(wfl_info.glsl_version)
>> + else:
>> + # The directory is something else. Don't skip it.
>> + return True
>> +
>> +
>> +def is_dirpath_feature_supported(dirpath):
>> + """Examine dirpath to see if it ends in "spec/foobar". If so, check
>> + if foobar is a supported extension/version/feature. Return False if
>> + foobar is not supported, True otherwise.
>> + """
>> + p = os.path.split(dirpath)
>> + q = os.path.split(p[0])
>> + if q[1] == "spec":
>> + if not is_feature_directory_supported(p[1]):
>> + return False
>> + return True
>> +
>> +
>> ######
>> # Collecting all tests
>> profile = TestProfile() # pylint: disable=invalid-name
>>
>> shader_tests = collections.defaultdict(list)
>>
>> +wfl_info = opengl.WflInfo()
>> +
>> +
>> # Find and add all shader tests.
>> for basedir in [TESTS_DIR, GENERATED_TESTS_DIR]:
>> - for dirpath, _, filenames in os.walk(basedir):
>> + for dirpath, dirnames, filenames in os.walk(basedir):
>
> I don't think this change is relavent in v2
>
> With those two changes:
> Reviewed-by: Dylan Baker <dylan at pnwbakers.com>
Thanks. But actually, I'm going to re-do this again. os.path.walk()
can be replaced by a more efficient traversal...
-Brian
>
>> groupname = grouptools.from_path(os.path.relpath(dirpath, basedir))
>> +
>> + if not is_dirpath_feature_supported(dirpath):
>> + print("Skipping {}".format(dirpath))
>> + continue
>> +
>> for filename in filenames:
>> testname, ext = os.path.splitext(filename)
>> if ext == '.shader_test':
>> --
>> 1.9.1
>>
More information about the Piglit
mailing list