<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Oct 18, 2017 at 6:37 PM, Dylan Baker <span dir="ltr"><<a href="mailto:dylan@pnwbakers.com" target="_blank">dylan@pnwbakers.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Quoting Brian Paul (2017-10-12 21:23:06)<br>
<div><div class="h5">> The script searches all files under tests/ and generated_tests/ for<br>
> files ending in ".shader_test".  For each match, a ShaderTest() object<br>
> is created and added to the test list.<br>
><br>
> For GL extensions or versions not supported by the driver, this is<br>
> wasted effort.<br>
><br>
> This patch looks for directories under spec/ and tries to determine if<br>
> the extension/feature is actually supported by the current driver.  If<br>
> not, it's skipped.<br>
><br>
> This somewhat reduces Piglit start up time, but substantially more<br>
> time is spent in the ShaderTest() constructor which actually opens<br>
> and parses each file to determine its GL/ES dependencies.  I'll try<br>
> to address that in the future.<br>
> ---<br>
>  tests/all.py | 57 ++++++++++++++++++++++++++++++<wbr>+++++++++++++++++++++++++--<br>
>  1 file changed, 55 insertions(+), 2 deletions(-)<br>
><br>
> diff --git a/tests/all.py b/tests/all.py<br>
> index 54346d4..8c9e33d 100644<br>
> --- a/tests/all.py<br>
> +++ b/tests/all.py<br>
> @@ -8,11 +8,12 @@ import collections<br>
>  import itertools<br>
>  import os<br>
>  import platform<br>
> -<br>
> +import re<br>
<br>
</div></div>please don't remove the newline, platform and re are stdlib modules, six is a<br>
third part module<br>
<span class=""><br>
>  import six<br>
>  from six.moves import range<br>
><br>
>  from framework import grouptools<br>
> +from framework.test import opengl<br>
>  from framework import options<br>
>  from framework.profile import TestProfile<br>
>  from framework.driver_classifier import DriverClassifier<br>
> @@ -204,16 +205,68 @@ def power_set(s):<br>
>          result.append(p + [s[-1]])<br>
>      return result<br>
><br>
> +<br>
> +def gl_extension_supported(<wbr>extName):<br>
> +    """Is the named OpenGL extension supported?"""<br>
> +    return extName in wfl_info.gl_extensions<br>
<br>
</span>Please use pep8 style names. Normal variables are seperated with underscores,<br>
ext_name, dir_name, etc).<br>
<span class=""><br>
> +<br>
> +def is_feature_directory_<wbr>supported(dirName):<br>
> +    """Determine if dirName specifies an OpenGL feature (extension or GL<br>
> +    version) which is supported by the host.  If we return False, it means<br>
> +    the extension/version is definitely not supported.  If we return True,<br>
> +    it means the extension/version is possibly suppported.  We're a little<br>
> +    fuzzy because we don't yet parse all the directory name possibilities<br>
> +    (like ES tests).<br>
> +    """<br>
> +    if dirName[0:4] in { "amd_", "arb_", "ati_", "ext_", "khr_", "oes_" }:<br>
<br>
</span>Python style is no spaces around the braces.<br>
<br>
The leading 0 is also optional<br>
<div><div class="h5"><br>
> +        # The directory is a GL extension name, but of the format "arb_foo_bar"<br>
> +        # instead of "GL_ARB_foo_bar".  We convert the former into the later<br>
> +        # and check if the extension is supported.<br>
> +        extName = "GL_" + dirName[0:4].upper() + dirName[4:]<br>
> +        return gl_extension_supported(<wbr>extName)<br>
> +    elif re.match("gl-\d\.\d+", dirName[0:3]):<br>
> +        # The directory is a GL version<br>
> +        version = dirName[3:]<br>
> +        return float(version) <= float(wfl_info.gl_version)<br>
> +    elif re.match("glsl-\d\.\d+", dirName[0:5]):<br>
> +        # The directory is a GLSL version<br>
> +        version = dirName[5:]<br>
> +        return float(version) <= float(wfl_info.glsl_version)<br>
> +    else:<br>
> +        # The directory is something else.  Don't skip it.<br>
> +        return True<br>
> +<br>
> +def filter_directories(dirPath, dirNames):<br>
> +    """Examine the dirNames under dirPath.  If the a dirName corresponds<br>
> +    to an OpenGL feature/version, check if it's supported by the OpenGL<br>
> +    driver.  If it's not, remove it from the directory list.<br>
> +    This is used to prune the directory search for *.shader_runner, etc.<br>
> +    files.<br>
> +    """<br>
> +    lastPart = os.path.split(dirPath)[-1]<br>
<br>
</div></div>os.path.basename is the function to do that.<br>
<span class=""><br>
> +    if lastPart == "spec":<br>
> +        for dir in dirNames:<br>
> +            if not is_feature_directory_<wbr>supported(dir):<br>
> +                print("Skipping spec/%s" % dir)<br>
<br>
</span>Please use str.format instead of %. "Skipping spec/{}".format(dir)<br>
<span class=""><br>
> +                dirNames.remove(dir)<br>
> +<br>
> +<br>
>  ######<br>
>  # Collecting all tests<br>
>  profile = TestProfile()  # pylint: disable=invalid-name<br>
><br>
>  shader_tests = collections.defaultdict(list)<br>
><br>
> +wfl_info = opengl.WflInfo()<br>
> +<br>
> +<br>
>  # Find and add all shader tests.<br>
>  for basedir in [TESTS_DIR, GENERATED_TESTS_DIR]:<br>
> -    for dirpath, _, filenames in os.walk(basedir):<br>
> +    for dirpath, dirnames, filenames in os.walk(basedir):<br>
>          groupname = grouptools.from_path(os.path.<wbr>relpath(dirpath, basedir))<br>
> +<br>
> +        filter_directories(dirpath, dirnames)<br>
> +<br>
<br>
</span>Does this actually filter anything?</blockquote><div><br></div><div>Yes, it works as advertised.</div><div><br></div><div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> We ignore that variable, and even if it<br>
does, this seems fragile, a change in the way os.walk works and it stops<br>
working. I think a better approach would be to do somehting like:<br>
<br>
            if not is_feature_directory_<wbr>supported(dirpath):<br>
                continue<br></blockquote><div><br></div><div><br></div><div>I actually had it coded like that at one point.  I can change it back.  v2 coming soon.</div><div><br></div><div>-Brian</div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5"><br>
>          for filename in filenames:<br>
>              testname, ext = os.path.splitext(filename)<br>
>              if ext == '.shader_test':<br>
> --<br>
> 1.9.1<br>
><br>
> ______________________________<wbr>_________________<br>
> Piglit mailing list<br>
> <a href="mailto:Piglit@lists.freedesktop.org">Piglit@lists.freedesktop.org</a><br>
> <a href="https://lists.freedesktop.org/mailman/listinfo/piglit" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/piglit</a><br>
</div></div><br>______________________________<wbr>_________________<br>
Piglit mailing list<br>
<a href="mailto:Piglit@lists.freedesktop.org">Piglit@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/piglit" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/piglit</a><br>
<br></blockquote></div><br></div></div>