On Wed, Oct 18, 2017 at 6:37 PM, Dylan Baker <dy...@pnwbakers.com> wrote:
> Quoting Brian Paul (2017-10-12 21:23:06) > > 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. > > --- > > tests/all.py | 57 ++++++++++++++++++++++++++++++ > +++++++++++++++++++++++++-- > > 1 file changed, 55 insertions(+), 2 deletions(-) > > > > diff --git a/tests/all.py b/tests/all.py > > index 54346d4..8c9e33d 100644 > > --- a/tests/all.py > > +++ b/tests/all.py > > @@ -8,11 +8,12 @@ import collections > > import itertools > > import os > > import platform > > - > > +import re > > please don't remove the newline, platform and re are stdlib modules, six > is a > third part module > > > 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 +205,68 @@ def power_set(s): > > result.append(p + [s[-1]]) > > return result > > > > + > > +def gl_extension_supported(extName): > > + """Is the named OpenGL extension supported?""" > > + return extName in wfl_info.gl_extensions > > Please use pep8 style names. Normal variables are seperated with > underscores, > ext_name, dir_name, etc). > > > + > > +def is_feature_directory_supported(dirName): > > + """Determine if dirName 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 dirName[0:4] in { "amd_", "arb_", "ati_", "ext_", "khr_", "oes_" > }: > > Python style is no spaces around the braces. > > The leading 0 is also optional > > > + # 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_" + dirName[0:4].upper() + dirName[4:] > > + return gl_extension_supported(extName) > > + elif re.match("gl-\d\.\d+", dirName[0:3]): > > + # The directory is a GL version > > + version = dirName[3:] > > + return float(version) <= float(wfl_info.gl_version) > > + elif re.match("glsl-\d\.\d+", dirName[0:5]): > > + # The directory is a GLSL version > > + version = dirName[5:] > > + return float(version) <= float(wfl_info.glsl_version) > > + else: > > + # The directory is something else. Don't skip it. > > + return True > > + > > +def filter_directories(dirPath, dirNames): > > + """Examine the dirNames under dirPath. If the a dirName corresponds > > + to an OpenGL feature/version, check if it's supported by the OpenGL > > + driver. If it's not, remove it from the directory list. > > + This is used to prune the directory search for *.shader_runner, etc. > > + files. > > + """ > > + lastPart = os.path.split(dirPath)[-1] > > os.path.basename is the function to do that. > > > + if lastPart == "spec": > > + for dir in dirNames: > > + if not is_feature_directory_supported(dir): > > + print("Skipping spec/%s" % dir) > > Please use str.format instead of %. "Skipping spec/{}".format(dir) > > > + dirNames.remove(dir) > > + > > + > > ###### > > # 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): > > groupname = grouptools.from_path(os.path.relpath(dirpath, > basedir)) > > + > > + filter_directories(dirpath, dirnames) > > + > > Does this actually filter anything? Yes, it works as advertised. We ignore that variable, and even if it > does, this seems fragile, a change in the way os.walk works and it stops > working. I think a better approach would be to do somehting like: > > if not is_feature_directory_supported(dirpath): > continue > I actually had it coded like that at one point. I can change it back. v2 coming soon. -Brian > > for filename in filenames: > > testname, ext = os.path.splitext(filename) > > if ext == '.shader_test': > > -- > > 1.9.1 > > > > _______________________________________________ > > Piglit mailing list > > Piglit@lists.freedesktop.org > > https://lists.freedesktop.org/mailman/listinfo/piglit > > _______________________________________________ > Piglit mailing list > Piglit@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/piglit > >
_______________________________________________ Piglit mailing list Piglit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/piglit