On 1 February 2012 16:06, Kenneth Graunke <span dir="ltr">&lt;<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Unlike the previous commits, this is a bit trickier: not all .vert or<br>
.frag files are parser tests.  They must have a valid [config] section.<br>
<br>
Since [config] could theoretically be used in normal shaders, we look<br>
for [end config] instead.  This is not foolproof, but ought to be good<br>
enough.<br>
<br>
Signed-off-by: Kenneth Graunke &lt;<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>&gt;<br>
---<br>
 framework/glsl_parser_test.py |   37 -----------------<br>
 tests/all.tests               |   87 +++++++----------------------------------<br>
 2 files changed, 15 insertions(+), 109 deletions(-)<br>
<br>
diff --git a/framework/glsl_parser_test.py b/framework/glsl_parser_test.py<br>
index 0d97986..483b1d1 100755<br>
--- a/framework/glsl_parser_test.py<br>
+++ b/framework/glsl_parser_test.py<br>
@@ -43,43 +43,6 @@ from core import Test, testBinDir, TestResult<br>
 from cStringIO import StringIO<br>
 from exectest import PlainExecTest<br>
<br>
-def add_glsl_parser_test(group, filepath, test_name):<br>
-       &quot;&quot;&quot;Add an instance of GLSLParserTest to the given group.&quot;&quot;&quot;<br>
-       group[test_name] = GLSLParserTest(filepath)<br>
-<br>
-def import_glsl_parser_tests(group, basepath, subdirectories):<br>
-       &quot;&quot;&quot;<br>
-       Recursively register each shader source file in the given<br>
-       ``subdirectories`` as a GLSLParserTest .<br>
-<br>
-       :subdirectories: A list of subdirectories under the basepath.<br>
-<br>
-       The name with which each test is registered into the given group is<br>
-       the shader source file&#39;s path relative to ``basepath``. For example,<br>
-       if::<br>
-               import_glsl_parser_tests(group, &#39;a&#39;, [&#39;b1&#39;, &#39;b2&#39;])<br>
-       is called and the file &#39;a/b1/c/d.frag&#39; exists, then the test is<br>
-       registered into the group as ``group[&#39;b1/c/d.frag&#39;]``.<br>
-       &quot;&quot;&quot;<br>
-       for d in subdirectories:<br>
-               walk_dir = path.join(basepath, d)<br>
-               for (dirpath, dirnames, filenames) in os.walk(walk_dir):<br>
-                       # Ignore dirnames.<br>
-                       for f in filenames:<br>
-                               # Add f as a test if its file extension is good.<br>
-                               ext = f.rsplit(&#39;.&#39;)[-1]<br>
-                               if ext in [&#39;vert&#39;, &#39;geom&#39;, &#39;frag&#39;]:<br>
-                                       filepath = path.join(dirpath, f)<br>
-                                       # testname := filepath relative to<br>
-                                       # basepath.<br>
-                                       testname = os.path.relpath(<br>
-                                               filepath, basepath)<br>
-                                       assert isinstance(testname, basestring)<br>
-                                       add_glsl_parser_test(<br>
-                                               group,<br>
-                                               filepath,<br>
-                                               testname)<br>
-<br>
 class GLSLParserTest(PlainExecTest):<br>
        &quot;&quot;&quot;Test for the GLSL parser (and more) on a GLSL source file.<br>
<br>
diff --git a/tests/all.tests b/tests/all.tests<br>
index c468abd..e6ac33a 100644<br>
--- a/tests/all.tests<br>
+++ b/tests/all.tests<br>
@@ -9,7 +9,7 @@ from glob import glob<br>
 from framework.core import *<br>
 from framework.exectest import *<br>
 from framework.gleantest import *<br>
-from framework.glsl_parser_test import GLSLParserTest, add_glsl_parser_test, import_glsl_parser_tests<br>
+from framework.glsl_parser_test import GLSLParserTest<br>
<br>
 # Blacklisted tests are removed from the test profile.<br>
 blacklist = [<br>
@@ -336,6 +336,20 @@ for dir in (testsDir, generatedTestDir):<br>
                name = path.splitext(path.relpath(test, dir))[0]<br>
                profile.test_list[name] = concurrent_test(&#39;shader_runner &#39; + test)<br>
<br>
+# Add any GLSLParserTests: .vert/.geom/.frag files containing &quot;[config]&quot; within<br>
+# the first two lines.<br></blockquote><div><br>This comment is stale (it says you&#39;re identifying parser tests by looking for &quot;[config]&quot; but you&#39;re actually looking for &quot;[end config]&quot;).<br> </div>
<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+for dir in (testsDir, generatedTestDir):<br>
+       for shader in find_files_with_extension(dir, [&#39;vert&#39;, &#39;geom&#39;, &#39;frag&#39;]):<br>
+               def looks_like_a_parser_test(filepath):<br></blockquote><div><br>Nice function name.  Clear, concise, and not too formal.  I love it :)<br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">

+                       with open(filepath, &#39;r&#39;) as f:<br>
+                               for line in f:<br>
+                                       if &#39;[end config]&#39; in line:<br>
+                                               return True<br>
+                               return False<br>
+               if looks_like_a_parser_test(shader):<br>
+                       name = path.relpath(shader, dir).replace(&#39;parsertest/shaders&#39;, &#39;parsertest&#39;)<br>
+                       profile.test_list[name] = GLSLParserTest(shader)<br>
+<br>
 def add_getactiveuniform_count(group, name, expected):<br>
        path = &#39;shaders/&#39;<br>
        group[&#39;glsl-getactiveuniform-count: &#39; + name] = PlainExecTest([&#39;glsl-getactiveuniform-count&#39;,<br>
@@ -805,20 +819,8 @@ add_concurrent_test(gl30, &#39;gl-3.0-required-sized-texture-formats&#39;)<br>
 add_concurrent_test(gl30, &#39;gl-3.0-required-renderbuffer-attachment-formats&#39;)<br>
 add_concurrent_test(gl30, &#39;gl-3.0-required-texture-attachment-formats&#39;)<br>
<br>
-# Group spec/glsl-1.00<br>
-spec[&#39;glsl-1.00&#39;] = Group()<br>
-import_glsl_parser_tests(spec[&#39;glsl-1.00&#39;],<br>
-                        os.path.join(testsDir, &#39;spec&#39;, &#39;glsl-1.00&#39;),<br>
-                        [&#39;compiler&#39;])<br>
-<br>
 # Group spec/glsl-1.10<br>
 spec[&#39;glsl-1.10&#39;] = Group()<br>
-import_glsl_parser_tests(spec[&#39;glsl-1.10&#39;],<br>
-                        os.path.join(testsDir, &#39;spec&#39;, &#39;glsl-1.10&#39;),<br>
-                        [&#39;preprocessor&#39;, &#39;compiler&#39;])<br>
-import_glsl_parser_tests(spec[&#39;glsl-1.10&#39;],<br>
-                        os.path.join(generatedTestDir, &#39;spec&#39;, &#39;glsl-1.10&#39;),<br>
-                        [&#39;preprocessor&#39;, &#39;compiler&#39;])<br>
 spec[&#39;glsl-1.10&#39;][&#39;execution&#39;] = Group()<br>
 spec[&#39;glsl-1.10&#39;][&#39;execution&#39;][&#39;clipping&#39;] = Group()<br>
 for mode in [&#39;fixed&#39;, &#39;pos_clipvert&#39;, &#39;clipvert_pos&#39;]:<br>
@@ -830,12 +832,6 @@ add_concurrent_test(spec[&#39;glsl-1.10&#39;][&#39;api&#39;], &#39;getactiveattrib 110&#39;);<br>
<br>
 # Group spec/glsl-1.20<br>
 spec[&#39;glsl-1.20&#39;] = Group()<br>
-import_glsl_parser_tests(spec[&#39;glsl-1.20&#39;],<br>
-                        os.path.join(testsDir, &#39;spec&#39;, &#39;glsl-1.20&#39;),<br>
-                        [&#39;preprocessor&#39;, &#39;compiler&#39;])<br>
-import_glsl_parser_tests(spec[&#39;glsl-1.20&#39;],<br>
-                        os.path.join(generatedTestDir, &#39;spec&#39;, &#39;glsl-1.20&#39;),<br>
-                        [&#39;compiler&#39;])<br>
 spec[&#39;glsl-1.20&#39;][&#39;execution&#39;] = Group()<br>
<br>
 def add_recursion_test(group, name):<br>
@@ -867,12 +863,6 @@ add_concurrent_test(spec[&#39;glsl-1.20&#39;][&#39;api&#39;], &#39;getactiveattrib 120&#39;);<br>
<br>
 # Group spec/glsl-1.30<br>
 spec[&#39;glsl-1.30&#39;] = Group()<br>
-import_glsl_parser_tests(spec[&#39;glsl-1.30&#39;],<br>
-                        os.path.join(testsDir, &#39;spec&#39;, &#39;glsl-1.30&#39;),<br>
-                        [&#39;preprocessor&#39;, &#39;compiler&#39;])<br>
-import_glsl_parser_tests(spec[&#39;glsl-1.30&#39;],<br>
-                        os.path.join(generatedTestDir, &#39;spec&#39;, &#39;glsl-1.30&#39;),<br>
-                        [&#39;compiler&#39;])<br>
 spec[&#39;glsl-1.30&#39;][&#39;execution&#39;] = Group()<br>
 spec[&#39;glsl-1.30&#39;][&#39;execution&#39;][&#39;clipping&#39;] = Group()<br>
 spec[&#39;glsl-1.30&#39;][&#39;execution&#39;][&#39;textureSize&#39;] = Group()<br>
@@ -907,24 +897,6 @@ add_concurrent_test(spec[&#39;glsl-1.30&#39;][&#39;execution&#39;], &#39;vertexid-drawelements&#39;)<br>
 spec[&#39;glsl-1.30&#39;][&#39;api&#39;] = Group()<br>
 add_concurrent_test(spec[&#39;glsl-1.30&#39;][&#39;api&#39;], &#39;getactiveattrib 130&#39;);<br>
<br>
-# Group AMD_conservative_depth<br>
-spec[&#39;AMD_conservative_depth&#39;] = Group()<br>
-import_glsl_parser_tests(spec[&#39;AMD_conservative_depth&#39;],<br>
-                        os.path.join(testsDir, &#39;spec&#39;, &#39;amd_conservative_depth&#39;),<br>
-                        [&#39;&#39;])<br>
-<br>
-# Group AMD_shader_stencil_export<br>
-spec[&#39;AMD_shader_stencil_export&#39;] = Group()<br>
-import_glsl_parser_tests(spec[&#39;AMD_shader_stencil_export&#39;],<br>
-                        os.path.join(testsDir, &#39;spec&#39;, &#39;amd_shader_stencil_export&#39;),<br>
-                        [&#39;&#39;])<br>
-<br>
-# Group ARB_shader_stencil_export<br>
-spec[&#39;ARB_shader_stencil_export&#39;] = Group()<br>
-import_glsl_parser_tests(spec[&#39;ARB_shader_stencil_export&#39;],<br>
-                        os.path.join(testsDir, &#39;spec&#39;, &#39;arb_shader_stencil_export&#39;),<br>
-                        [&#39;&#39;])<br>
-<br>
 # Group ARB_ES2_compatibility<br>
 arb_es2_compatibility = Group()<br>
 spec[&#39;ARB_ES2_compatibility&#39;] = arb_es2_compatibility<br>
@@ -950,13 +922,6 @@ arb_draw_elements_base_vertex[&#39;draw-elements-base-vertex-neg-user_varrays&#39;] = Pl<br>
 add_plain_test(arb_draw_elements_base_vertex, &#39;draw-elements-instanced-base-vertex&#39;)<br>
 arb_draw_elements_base_vertex[&#39;draw-elements-instanced-base-vertex-user_varrays&#39;] = PlainExecTest([&#39;draw-elements-instanced-base-vertex&#39;, &#39;-auto&#39;, &#39;user_varrays&#39;])<br>
<br>
-# Group ARB_draw_instanced<br>
-arb_draw_instanced = Group()<br>
-spec[&#39;ARB_draw_instanced&#39;] = arb_draw_instanced<br>
-import_glsl_parser_tests(arb_draw_instanced,<br>
-                        testsDir + &#39;/spec/arb_draw_instanced&#39;,<br>
-                        [&#39;&#39;])<br>
-<br>
 # Group ARB_fragment_program<br>
 arb_fragment_program = Group()<br>
 spec[&#39;ARB_fragment_program&#39;] = arb_fragment_program<br>
@@ -987,9 +952,6 @@ add_plain_test(arb_robustness, &#39;arb_robustness_client-mem-bounds&#39;)<br>
 # Group ARB_shader_texture_lod<br>
 arb_shader_texture_lod = Group()<br>
 spec[&#39;ARB_shader_texture_lod&#39;] = arb_shader_texture_lod<br>
-import_glsl_parser_tests(arb_shader_texture_lod,<br>
-                        os.path.join(testsDir, &#39;spec&#39;, &#39;arb_shader_texture_lod&#39;),<br>
-                        [&#39;compiler&#39;])<br>
 arb_shader_texture_lod[&#39;execution&#39;] = Group()<br>
 add_plain_test(arb_shader_texture_lod[&#39;execution&#39;], &#39;arb_shader_texture_lod-texgrad&#39;)<br>
 arb_shader_texture_lod[&#39;execution&#39;][&#39;tex-miplevel-selection-texture2DLod&#39;] = PlainExecTest([&#39;tex-miplevel-selection&#39;, &#39;-auto&#39;, &#39;-nobias&#39;, &#39;-nolod&#39;, &#39;-GL_ARB_shader_texture_lod&#39;])<br>

@@ -1009,10 +971,6 @@ arb_shader_objects[&#39;delete-repeat&#39;] = concurrent_test(&#39;arb_shader_objects-delete<br>
 # Group ARB_explicit_attrib_location<br>
 arb_explicit_attrib_location = Group()<br>
 spec[&#39;ARB_explicit_attrib_location&#39;] = arb_explicit_attrib_location<br>
-import_glsl_parser_tests(arb_explicit_attrib_location,<br>
-                        os.path.join(testsDir,<br>
-                        &#39;spec&#39;, &#39;arb_explicit_attrib_location&#39;),<br>
-                        [&#39;&#39;])<br>
 add_plain_test(arb_explicit_attrib_location, &#39;glsl-explicit-location-01&#39;)<br>
 add_plain_test(arb_explicit_attrib_location, &#39;glsl-explicit-location-02&#39;)<br>
 add_plain_test(arb_explicit_attrib_location, &#39;glsl-explicit-location-03&#39;)<br>
@@ -1532,20 +1490,6 @@ arb_draw_buffers = Group()<br>
 spec[&#39;ARB_draw_buffers&#39;] = arb_draw_buffers<br>
 add_plain_test(arb_draw_buffers, &#39;arb_draw_buffers-state_change&#39;)<br>
<br>
-# group glslparsertest ------------------------------------------------------<br>
-glslparsertest = Group()<br>
-# Add all shader source files in the directories below.<br>
-for filename in os.listdir(testsDir + &#39;/glslparsertest/shaders&#39;):<br>
-       ext = filename.rsplit(&#39;.&#39;)[-1]<br>
-       if ext in [&#39;vert&#39;, &#39;geo&#39;, &#39;frag&#39;]:<br>
-               add_glsl_parser_test(glslparsertest, path.join(testsDir, &#39;glslparsertest/shaders&#39;, filename), filename)<br>
-del glslparsertest[&#39;CorrectPreprocess11.frag&#39;]<br>
-for filename in os.listdir(testsDir + &#39;/glslparsertest/glsl2&#39;):<br>
-       ext = filename.rsplit(&#39;.&#39;)[-1]<br>
-       if ext in [&#39;vert&#39;, &#39;geo&#39;, &#39;frag&#39;]:<br>
-               add_glsl_parser_test(glslparsertest, path.join(testsDir, &#39;glslparsertest/glsl2&#39;, filename), &#39;glsl2/&#39; + filename)<br>
-# end group glslparsertest ---------------------------------------------------<br>
-<br>
 hiz = Group()<br>
 add_plain_test(hiz, &#39;hiz-depth-stencil-test-fbo-d0-s8&#39;)<br>
 add_plain_test(hiz, &#39;hiz-depth-stencil-test-fbo-d24-s0&#39;)<br>
@@ -1585,7 +1529,6 @@ profile.tests[&#39;general&#39;] = general<br>
 profile.tests[&#39;hiz&#39;] = hiz<br>
 profile.tests[&#39;fbo&#39;] = fbo<br>
 profile.tests[&#39;glean&#39;] = glean<br>
-profile.tests[&#39;glslparsertest&#39;] = glslparsertest<br>
 profile.tests[&#39;mesa&#39;] = mesa<br>
 profile.tests[&#39;shaders&#39;] = shaders<br>
 profile.tests[&#39;texturing&#39;] = texturing<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.7.7.6<br>
<br>
_______________________________________________<br>
Piglit mailing list<br>
<a href="mailto:Piglit@lists.freedesktop.org">Piglit@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/piglit" target="_blank">http://lists.freedesktop.org/mailman/listinfo/piglit</a><br>
</font></span></blockquote></div><br>With the comment fixed, this patch is:<br><br>Reviewed-by: Paul Berry &lt;<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>&gt;<br>