On 1 February 2012 16:06, Kenneth Graunke <span dir="ltr"><<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>></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 <<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>><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>
- """Add an instance of GLSLParserTest to the given group."""<br>
- group[test_name] = GLSLParserTest(filepath)<br>
-<br>
-def import_glsl_parser_tests(group, basepath, subdirectories):<br>
- """<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's path relative to ``basepath``. For example,<br>
- if::<br>
- import_glsl_parser_tests(group, 'a', ['b1', 'b2'])<br>
- is called and the file 'a/b1/c/d.frag' exists, then the test is<br>
- registered into the group as ``group['b1/c/d.frag']``.<br>
- """<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('.')[-1]<br>
- if ext in ['vert', 'geom', 'frag']:<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>
"""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('shader_runner ' + test)<br>
<br>
+# Add any GLSLParserTests: .vert/.geom/.frag files containing "[config]" within<br>
+# the first two lines.<br></blockquote><div><br>This comment is stale (it says you're identifying parser tests by looking for "[config]" but you're actually looking for "[end config]").<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, ['vert', 'geom', 'frag']):<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, 'r') as f:<br>
+ for line in f:<br>
+ if '[end config]' in line:<br>
+ return True<br>
+ return False<br>
+ if looks_like_a_parser_test(shader):<br>
+ name = path.relpath(shader, dir).replace('parsertest/shaders', 'parsertest')<br>
+ profile.test_list[name] = GLSLParserTest(shader)<br>
+<br>
def add_getactiveuniform_count(group, name, expected):<br>
path = 'shaders/'<br>
group['glsl-getactiveuniform-count: ' + name] = PlainExecTest(['glsl-getactiveuniform-count',<br>
@@ -805,20 +819,8 @@ add_concurrent_test(gl30, 'gl-3.0-required-sized-texture-formats')<br>
add_concurrent_test(gl30, 'gl-3.0-required-renderbuffer-attachment-formats')<br>
add_concurrent_test(gl30, 'gl-3.0-required-texture-attachment-formats')<br>
<br>
-# Group spec/glsl-1.00<br>
-spec['glsl-1.00'] = Group()<br>
-import_glsl_parser_tests(spec['glsl-1.00'],<br>
- os.path.join(testsDir, 'spec', 'glsl-1.00'),<br>
- ['compiler'])<br>
-<br>
# Group spec/glsl-1.10<br>
spec['glsl-1.10'] = Group()<br>
-import_glsl_parser_tests(spec['glsl-1.10'],<br>
- os.path.join(testsDir, 'spec', 'glsl-1.10'),<br>
- ['preprocessor', 'compiler'])<br>
-import_glsl_parser_tests(spec['glsl-1.10'],<br>
- os.path.join(generatedTestDir, 'spec', 'glsl-1.10'),<br>
- ['preprocessor', 'compiler'])<br>
spec['glsl-1.10']['execution'] = Group()<br>
spec['glsl-1.10']['execution']['clipping'] = Group()<br>
for mode in ['fixed', 'pos_clipvert', 'clipvert_pos']:<br>
@@ -830,12 +832,6 @@ add_concurrent_test(spec['glsl-1.10']['api'], 'getactiveattrib 110');<br>
<br>
# Group spec/glsl-1.20<br>
spec['glsl-1.20'] = Group()<br>
-import_glsl_parser_tests(spec['glsl-1.20'],<br>
- os.path.join(testsDir, 'spec', 'glsl-1.20'),<br>
- ['preprocessor', 'compiler'])<br>
-import_glsl_parser_tests(spec['glsl-1.20'],<br>
- os.path.join(generatedTestDir, 'spec', 'glsl-1.20'),<br>
- ['compiler'])<br>
spec['glsl-1.20']['execution'] = Group()<br>
<br>
def add_recursion_test(group, name):<br>
@@ -867,12 +863,6 @@ add_concurrent_test(spec['glsl-1.20']['api'], 'getactiveattrib 120');<br>
<br>
# Group spec/glsl-1.30<br>
spec['glsl-1.30'] = Group()<br>
-import_glsl_parser_tests(spec['glsl-1.30'],<br>
- os.path.join(testsDir, 'spec', 'glsl-1.30'),<br>
- ['preprocessor', 'compiler'])<br>
-import_glsl_parser_tests(spec['glsl-1.30'],<br>
- os.path.join(generatedTestDir, 'spec', 'glsl-1.30'),<br>
- ['compiler'])<br>
spec['glsl-1.30']['execution'] = Group()<br>
spec['glsl-1.30']['execution']['clipping'] = Group()<br>
spec['glsl-1.30']['execution']['textureSize'] = Group()<br>
@@ -907,24 +897,6 @@ add_concurrent_test(spec['glsl-1.30']['execution'], 'vertexid-drawelements')<br>
spec['glsl-1.30']['api'] = Group()<br>
add_concurrent_test(spec['glsl-1.30']['api'], 'getactiveattrib 130');<br>
<br>
-# Group AMD_conservative_depth<br>
-spec['AMD_conservative_depth'] = Group()<br>
-import_glsl_parser_tests(spec['AMD_conservative_depth'],<br>
- os.path.join(testsDir, 'spec', 'amd_conservative_depth'),<br>
- [''])<br>
-<br>
-# Group AMD_shader_stencil_export<br>
-spec['AMD_shader_stencil_export'] = Group()<br>
-import_glsl_parser_tests(spec['AMD_shader_stencil_export'],<br>
- os.path.join(testsDir, 'spec', 'amd_shader_stencil_export'),<br>
- [''])<br>
-<br>
-# Group ARB_shader_stencil_export<br>
-spec['ARB_shader_stencil_export'] = Group()<br>
-import_glsl_parser_tests(spec['ARB_shader_stencil_export'],<br>
- os.path.join(testsDir, 'spec', 'arb_shader_stencil_export'),<br>
- [''])<br>
-<br>
# Group ARB_ES2_compatibility<br>
arb_es2_compatibility = Group()<br>
spec['ARB_ES2_compatibility'] = arb_es2_compatibility<br>
@@ -950,13 +922,6 @@ arb_draw_elements_base_vertex['draw-elements-base-vertex-neg-user_varrays'] = Pl<br>
add_plain_test(arb_draw_elements_base_vertex, 'draw-elements-instanced-base-vertex')<br>
arb_draw_elements_base_vertex['draw-elements-instanced-base-vertex-user_varrays'] = PlainExecTest(['draw-elements-instanced-base-vertex', '-auto', 'user_varrays'])<br>
<br>
-# Group ARB_draw_instanced<br>
-arb_draw_instanced = Group()<br>
-spec['ARB_draw_instanced'] = arb_draw_instanced<br>
-import_glsl_parser_tests(arb_draw_instanced,<br>
- testsDir + '/spec/arb_draw_instanced',<br>
- [''])<br>
-<br>
# Group ARB_fragment_program<br>
arb_fragment_program = Group()<br>
spec['ARB_fragment_program'] = arb_fragment_program<br>
@@ -987,9 +952,6 @@ add_plain_test(arb_robustness, 'arb_robustness_client-mem-bounds')<br>
# Group ARB_shader_texture_lod<br>
arb_shader_texture_lod = Group()<br>
spec['ARB_shader_texture_lod'] = arb_shader_texture_lod<br>
-import_glsl_parser_tests(arb_shader_texture_lod,<br>
- os.path.join(testsDir, 'spec', 'arb_shader_texture_lod'),<br>
- ['compiler'])<br>
arb_shader_texture_lod['execution'] = Group()<br>
add_plain_test(arb_shader_texture_lod['execution'], 'arb_shader_texture_lod-texgrad')<br>
arb_shader_texture_lod['execution']['tex-miplevel-selection-texture2DLod'] = PlainExecTest(['tex-miplevel-selection', '-auto', '-nobias', '-nolod', '-GL_ARB_shader_texture_lod'])<br>
@@ -1009,10 +971,6 @@ arb_shader_objects['delete-repeat'] = concurrent_test('arb_shader_objects-delete<br>
# Group ARB_explicit_attrib_location<br>
arb_explicit_attrib_location = Group()<br>
spec['ARB_explicit_attrib_location'] = arb_explicit_attrib_location<br>
-import_glsl_parser_tests(arb_explicit_attrib_location,<br>
- os.path.join(testsDir,<br>
- 'spec', 'arb_explicit_attrib_location'),<br>
- [''])<br>
add_plain_test(arb_explicit_attrib_location, 'glsl-explicit-location-01')<br>
add_plain_test(arb_explicit_attrib_location, 'glsl-explicit-location-02')<br>
add_plain_test(arb_explicit_attrib_location, 'glsl-explicit-location-03')<br>
@@ -1532,20 +1490,6 @@ arb_draw_buffers = Group()<br>
spec['ARB_draw_buffers'] = arb_draw_buffers<br>
add_plain_test(arb_draw_buffers, 'arb_draw_buffers-state_change')<br>
<br>
-# group glslparsertest ------------------------------------------------------<br>
-glslparsertest = Group()<br>
-# Add all shader source files in the directories below.<br>
-for filename in os.listdir(testsDir + '/glslparsertest/shaders'):<br>
- ext = filename.rsplit('.')[-1]<br>
- if ext in ['vert', 'geo', 'frag']:<br>
- add_glsl_parser_test(glslparsertest, path.join(testsDir, 'glslparsertest/shaders', filename), filename)<br>
-del glslparsertest['CorrectPreprocess11.frag']<br>
-for filename in os.listdir(testsDir + '/glslparsertest/glsl2'):<br>
- ext = filename.rsplit('.')[-1]<br>
- if ext in ['vert', 'geo', 'frag']:<br>
- add_glsl_parser_test(glslparsertest, path.join(testsDir, 'glslparsertest/glsl2', filename), 'glsl2/' + filename)<br>
-# end group glslparsertest ---------------------------------------------------<br>
-<br>
hiz = Group()<br>
add_plain_test(hiz, 'hiz-depth-stencil-test-fbo-d0-s8')<br>
add_plain_test(hiz, 'hiz-depth-stencil-test-fbo-d24-s0')<br>
@@ -1585,7 +1529,6 @@ profile.tests['general'] = general<br>
profile.tests['hiz'] = hiz<br>
profile.tests['fbo'] = fbo<br>
profile.tests['glean'] = glean<br>
-profile.tests['glslparsertest'] = glslparsertest<br>
profile.tests['mesa'] = mesa<br>
profile.tests['shaders'] = shaders<br>
profile.tests['texturing'] = 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 <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>><br>