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">
This avoids the fuss of adding more add_shader_test_dir calls every time<br>
you add a new folder with shader runner tests in it.  Presumably, if you<br>
drop a new .shader_test file into tests or generated_tests, you&#39;ve added<br>
a new shader runner test and want it to be run.  If not, you can rename<br>
it to have a different extension.<br>
<br>
Signed-off-by: Kenneth Graunke &lt;<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>&gt;<br></blockquote><div><br>Reviewed-by: Paul Berry &lt;<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>&gt;<br>
 </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
---<br>
 tests/all.tests |   78 ++++++++++--------------------------------------------<br>
 1 files changed, 15 insertions(+), 63 deletions(-)<br>
<br>
diff --git a/tests/all.tests b/tests/all.tests<br>
index 3211016..b48ef9a 100644<br>
--- a/tests/all.tests<br>
+++ b/tests/all.tests<br>
@@ -320,22 +320,19 @@ add_fbo_depthstencil_tests(general, &#39;default_fb&#39;)<br>
<br>
 shaders = Group()<br>
<br>
-def add_shader_test_dir(group, dirpath, recursive=False):<br>
-       &quot;&quot;&quot;Add all shader tests in a directory to the given group.&quot;&quot;&quot;<br>
-       for filename in os.listdir(dirpath):<br>
-               filepath = path.join(dirpath, filename)<br>
-               if path.isdir(filepath):<br>
-                       if not recursive:<br>
-                               continue<br>
-                       if not filename in group:<br>
-                               group[filename] = Group()<br>
-                       add_shader_test_dir(group[filename], filepath, recursive)<br>
-               else:<br>
-                       ext = filename.rsplit(&#39;.&#39;)[-1]<br>
-                       if ext != &#39;shader_test&#39;:<br>
-                               continue<br>
-                       testname = filename[0:-(len(ext) + 1)] # +1 for &#39;.&#39;<br>
-                       group[testname] = concurrent_test(&#39;shader_runner &#39; + filepath)<br>
+def find_files_with_extension(top, ext_list):<br>
+       &quot;&quot;&quot;Recursively find files in `top&#39; with a matching file extension.&quot;&quot;&quot;<br>
+       files = []<br>
+       for dirpath, dirnames, filenames in os.walk(top):<br>
+               matching = filter(lambda f: f.rsplit(&#39;.&#39;)[-1] in ext_list, filenames)<br>
+               files.extend(map(lambda f: path.join(dirpath, f), matching))<br>
+       return files<br>
+<br>
+# Add all .shader_test files as tests.<br>
+for dir in (testsDir, generatedTestDir):<br>
+       for test in find_files_with_extension(dir, [&#39;shader_test&#39;]):<br>
+               name = path.splitext(path.relpath(test, dir))[0]<br>
+               profile.test_list[name] = concurrent_test(&#39;shader_runner &#39; + test)<br>
<br>
 def add_getactiveuniform_count(group, name, expected):<br>
        path = &#39;shaders/&#39;<br>
@@ -344,9 +341,6 @@ def add_getactiveuniform_count(group, name, expected):<br>
                                                                   path + name + &#39;.vert&#39;,<br>
                                                                   expected])<br>
<br>
-add_shader_test_dir(shaders,<br>
-                    testsDir + &#39;/shaders&#39;,<br>
-                    recursive=True)<br>
 add_plain_test(shaders, &#39;activeprogram-bad-program&#39;)<br>
 add_plain_test(shaders, &#39;activeprogram-get&#39;)<br>
 add_plain_test(shaders, &#39;ati-fs-bad-delete&#39;)<br>
@@ -862,17 +856,8 @@ import_glsl_parser_tests(spec[&#39;glsl-1.10&#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;linker&#39;] = Group()<br>
-add_shader_test_dir(spec[&#39;glsl-1.10&#39;][&#39;linker&#39;],<br>
-                   os.path.join(testsDir, &#39;spec&#39;, &#39;glsl-1.10&#39;, &#39;linker&#39;),<br>
-                   recursive=True)<br>
 spec[&#39;glsl-1.10&#39;][&#39;execution&#39;] = Group()<br>
-add_shader_test_dir(spec[&#39;glsl-1.10&#39;][&#39;execution&#39;],<br>
-                   os.path.join(testsDir, &#39;spec&#39;, &#39;glsl-1.10&#39;, &#39;execution&#39;),<br>
-                   recursive=True)<br>
-add_shader_test_dir(spec[&#39;glsl-1.10&#39;][&#39;execution&#39;],<br>
-                   os.path.join(generatedTestDir, &#39;spec&#39;, &#39;glsl-1.10&#39;, &#39;execution&#39;),<br>
-                   recursive=True)<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>
        cmdline = &#39;clip-plane-transformation &#39; + mode<br>
        spec[&#39;glsl-1.10&#39;][&#39;execution&#39;][&#39;clipping&#39;][cmdline] = concurrent_test(cmdline)<br>
@@ -889,12 +874,6 @@ 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>
-add_shader_test_dir(spec[&#39;glsl-1.20&#39;][&#39;execution&#39;],<br>
-                   os.path.join(testsDir, &#39;spec&#39;, &#39;glsl-1.20&#39;, &#39;execution&#39;),<br>
-                   recursive=True)<br>
-add_shader_test_dir(spec[&#39;glsl-1.20&#39;][&#39;execution&#39;],<br>
-                   os.path.join(generatedTestDir, &#39;spec&#39;, &#39;glsl-1.20&#39;, &#39;execution&#39;),<br>
-                   recursive=True)<br>
<br>
 def add_recursion_test(group, name):<br>
        # When the recursion tests fail it is usually because the GLSL<br>
@@ -932,6 +911,7 @@ 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>
 spec[&#39;glsl-1.30&#39;][&#39;execution&#39;][&#39;texelFetch&#39;] = Group()<br>
 for stage in [&#39;vs&#39;, &#39;fs&#39;]:<br>
@@ -947,12 +927,6 @@ for stage in [&#39;vs&#39;, &#39;fs&#39;]:<br>
<br>
 add_plain_test(spec[&#39;glsl-1.30&#39;][&#39;execution&#39;], &#39;fs-texelFetch-2D&#39;)<br>
 add_plain_test(spec[&#39;glsl-1.30&#39;][&#39;execution&#39;], &#39;fs-texelFetchOffset-2D&#39;)<br>
-add_shader_test_dir(spec[&#39;glsl-1.30&#39;][&#39;execution&#39;],<br>
-                   os.path.join(testsDir, &#39;spec&#39;, &#39;glsl-1.30&#39;, &#39;execution&#39;),<br>
-                   recursive=True)<br>
-add_shader_test_dir(spec[&#39;glsl-1.30&#39;][&#39;execution&#39;],<br>
-                   os.path.join(generatedTestDir, &#39;spec&#39;, &#39;glsl-1.30&#39;, &#39;execution&#39;),<br>
-                   recursive=True)<br>
 spec[&#39;glsl-1.30&#39;][&#39;linker&#39;] = Group()<br>
 spec[&#39;glsl-1.30&#39;][&#39;linker&#39;][&#39;clipping&#39;] = Group()<br>
 add_plain_test(spec[&#39;glsl-1.30&#39;][&#39;linker&#39;][&#39;clipping&#39;], &#39;mixing-clip-distance-and-clip-vertex-disallowed&#39;)<br>
@@ -1020,24 +994,14 @@ import_glsl_parser_tests(arb_draw_instanced,<br>
                         testsDir + &#39;/spec/arb_draw_instanced&#39;,<br>
                         [&#39;&#39;])<br>
<br>
-add_shader_test_dir(arb_draw_instanced,<br>
-                    testsDir + &#39;/spec/arb_draw_instanced/execution&#39;,<br>
-                    recursive=True)<br>
-<br>
 # Group ARB_fragment_program<br>
 arb_fragment_program = Group()<br>
 spec[&#39;ARB_fragment_program&#39;] = arb_fragment_program<br>
-add_shader_test_dir(spec[&#39;ARB_fragment_program&#39;],<br>
-                   os.path.join(testsDir, &#39;spec&#39;, &#39;arb_fragment_program&#39;),<br>
-                   recursive=True)<br>
 arb_fragment_program[&#39;minmax&#39;] = concurrent_test(&#39;arb_fragment_program-minmax&#39;)<br>
<br>
 # Group ARB_fragment_program_shadow<br>
 arb_fragment_program_shadow = Group()<br>
 spec[&#39;ARB_fragment_program_shadow&#39;] = arb_fragment_program_shadow<br>
-add_shader_test_dir(spec[&#39;ARB_fragment_program_shadow&#39;],<br>
-                   os.path.join(testsDir, &#39;spec&#39;, &#39;arb_fragment_program_shadow&#39;),<br>
-                   recursive=True)<br>
<br>
 # Group ARB_framebuffer_object<br>
 arb_framebuffer_object = Group()<br>
@@ -1064,9 +1028,6 @@ 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_shader_test_dir(arb_shader_texture_lod[&#39;execution&#39;],<br>
-                   os.path.join(testsDir, &#39;spec&#39;, &#39;arb_shader_texture_lod&#39;, &#39;execution&#39;),<br>
-                   recursive=True)<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>

 arb_shader_texture_lod[&#39;execution&#39;][&#39;tex-miplevel-selection-texture2DLod-lod&#39;] = PlainExecTest([&#39;tex-miplevel-selection&#39;, &#39;-auto&#39;, &#39;-nobias&#39;, &#39;-GL_ARB_shader_texture_lod&#39;])<br>

@@ -1100,9 +1061,6 @@ arb_texture_rectangle = Group()<br>
 spec[&#39;ARB_texture_rectangle&#39;] = arb_texture_rectangle<br>
 add_texwrap_test1(arb_texture_rectangle, &#39;RECT&#39;)<br>
 add_texwrap_test2(arb_texture_rectangle, &#39;RECT&#39;, &#39;proj&#39;)<br>
-add_shader_test_dir(arb_texture_rectangle,<br>
-                    testsDir + &#39;/spec/arb_texture_rectangle&#39;,<br>
-                    recursive=True)<br>
<br>
 arb_texture_storage = Group()<br>
 spec[&#39;ARB_texture_storage&#39;] = arb_texture_storage<br>
@@ -1257,9 +1215,6 @@ ext_texture_array = Group()<br>
 spec[&#39;EXT_texture_array&#39;] = ext_texture_array<br>
 add_plain_test(ext_texture_array, &#39;fbo-generatemipmap-array&#39;)<br>
 spec[&#39;EXT_texture_array&#39;][&#39;maxlayers&#39;] = concurrent_test(&#39;ext_texture_array-maxlayers&#39;)<br>
-add_shader_test_dir(ext_texture_array,<br>
-                    testsDir + &#39;/spec/ext_texture_array&#39;,<br>
-                    recursive=True)<br>
<br>
 ext_texture_compression_latc = Group()<br>
 spec[&#39;EXT_texture_compression_latc&#39;] = ext_texture_compression_latc<br>
@@ -1353,9 +1308,6 @@ ext_texture_integer[&#39;texture_integer_glsl130&#39;] = concurrent_test(&#39;ext_texture_in<br>
<br>
 arb_texture_rg = Group()<br>
 spec[&#39;ARB_texture_rg&#39;] = arb_texture_rg<br>
-add_shader_test_dir(arb_texture_rg,<br>
-                    testsDir + &#39;/spec/arb_texture_rg/execution&#39;,<br>
-                    recursive=True)<br>
 add_fbo_generatemipmap_extension(arb_texture_rg, &#39;GL_ARB_texture_rg&#39;, &#39;fbo-generatemipmap-formats&#39;)<br>
 add_fbo_generatemipmap_extension(arb_texture_rg, &#39;GL_ARB_texture_rg-float&#39;, &#39;fbo-generatemipmap-formats-float&#39;)<br>
 add_fbo_clear_extension(arb_texture_rg, &#39;GL_ARB_texture_rg&#39;, &#39;fbo-clear-formats&#39;)<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>