[Piglit] [PATCH 11/11] all.tests: Add all GLSL parser tests implicitly.

Kenneth Graunke kenneth at whitecape.org
Wed Feb 1 16:06:38 PST 2012


Unlike the previous commits, this is a bit trickier: not all .vert or
.frag files are parser tests.  They must have a valid [config] section.

Since [config] could theoretically be used in normal shaders, we look
for [end config] instead.  This is not foolproof, but ought to be good
enough.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 framework/glsl_parser_test.py |   37 -----------------
 tests/all.tests               |   87 +++++++----------------------------------
 2 files changed, 15 insertions(+), 109 deletions(-)

diff --git a/framework/glsl_parser_test.py b/framework/glsl_parser_test.py
index 0d97986..483b1d1 100755
--- a/framework/glsl_parser_test.py
+++ b/framework/glsl_parser_test.py
@@ -43,43 +43,6 @@ from core import Test, testBinDir, TestResult
 from cStringIO import StringIO
 from exectest import PlainExecTest
 
-def add_glsl_parser_test(group, filepath, test_name):
-	"""Add an instance of GLSLParserTest to the given group."""
-	group[test_name] = GLSLParserTest(filepath)
-
-def import_glsl_parser_tests(group, basepath, subdirectories):
-	"""
-	Recursively register each shader source file in the given
-	``subdirectories`` as a GLSLParserTest .
-
-	:subdirectories: A list of subdirectories under the basepath.
-
-	The name with which each test is registered into the given group is
-	the shader source file's path relative to ``basepath``. For example,
-	if::
-		import_glsl_parser_tests(group, 'a', ['b1', 'b2'])
-	is called and the file 'a/b1/c/d.frag' exists, then the test is
-	registered into the group as ``group['b1/c/d.frag']``.
-	"""
-	for d in subdirectories:
-		walk_dir = path.join(basepath, d)
-		for (dirpath, dirnames, filenames) in os.walk(walk_dir):
-			# Ignore dirnames.
-			for f in filenames:
-				# Add f as a test if its file extension is good.
-				ext = f.rsplit('.')[-1]
-				if ext in ['vert', 'geom', 'frag']:
-					filepath = path.join(dirpath, f)
-					# testname := filepath relative to
-					# basepath.
-					testname = os.path.relpath(
-						filepath, basepath)
-					assert isinstance(testname, basestring)
-					add_glsl_parser_test(
-						group,
-						filepath,
-						testname)
-
 class GLSLParserTest(PlainExecTest):
 	"""Test for the GLSL parser (and more) on a GLSL source file.
 
diff --git a/tests/all.tests b/tests/all.tests
index c468abd..e6ac33a 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -9,7 +9,7 @@ from glob import glob
 from framework.core import *
 from framework.exectest import *
 from framework.gleantest import *
-from framework.glsl_parser_test import GLSLParserTest, add_glsl_parser_test, import_glsl_parser_tests
+from framework.glsl_parser_test import GLSLParserTest
 
 # Blacklisted tests are removed from the test profile.
 blacklist = [
@@ -336,6 +336,20 @@ for dir in (testsDir, generatedTestDir):
 		name = path.splitext(path.relpath(test, dir))[0]
 		profile.test_list[name] = concurrent_test('shader_runner ' + test)
 
+# Add any GLSLParserTests: .vert/.geom/.frag files containing "[config]" within
+# the first two lines.
+for dir in (testsDir, generatedTestDir):
+	for shader in find_files_with_extension(dir, ['vert', 'geom', 'frag']):
+		def looks_like_a_parser_test(filepath):
+			with open(filepath, 'r') as f:
+				for line in f:
+					if '[end config]' in line:
+						return True
+				return False
+		if looks_like_a_parser_test(shader):
+			name = path.relpath(shader, dir).replace('parsertest/shaders', 'parsertest')
+			profile.test_list[name] = GLSLParserTest(shader)
+
 def add_getactiveuniform_count(group, name, expected):
 	path = 'shaders/'
 	group['glsl-getactiveuniform-count: ' + name] = PlainExecTest(['glsl-getactiveuniform-count',
@@ -805,20 +819,8 @@ add_concurrent_test(gl30, 'gl-3.0-required-sized-texture-formats')
 add_concurrent_test(gl30, 'gl-3.0-required-renderbuffer-attachment-formats')
 add_concurrent_test(gl30, 'gl-3.0-required-texture-attachment-formats')
 
-# Group spec/glsl-1.00
-spec['glsl-1.00'] = Group()
-import_glsl_parser_tests(spec['glsl-1.00'],
-			 os.path.join(testsDir, 'spec', 'glsl-1.00'),
-			 ['compiler'])
-
 # Group spec/glsl-1.10
 spec['glsl-1.10'] = Group()
-import_glsl_parser_tests(spec['glsl-1.10'],
-			 os.path.join(testsDir, 'spec', 'glsl-1.10'),
-			 ['preprocessor', 'compiler'])
-import_glsl_parser_tests(spec['glsl-1.10'],
-			 os.path.join(generatedTestDir, 'spec', 'glsl-1.10'),
-			 ['preprocessor', 'compiler'])
 spec['glsl-1.10']['execution'] = Group()
 spec['glsl-1.10']['execution']['clipping'] = Group()
 for mode in ['fixed', 'pos_clipvert', 'clipvert_pos']:
@@ -830,12 +832,6 @@ add_concurrent_test(spec['glsl-1.10']['api'], 'getactiveattrib 110');
 
 # Group spec/glsl-1.20
 spec['glsl-1.20'] = Group()
-import_glsl_parser_tests(spec['glsl-1.20'],
-			 os.path.join(testsDir, 'spec', 'glsl-1.20'),
-			 ['preprocessor', 'compiler'])
-import_glsl_parser_tests(spec['glsl-1.20'],
-			 os.path.join(generatedTestDir, 'spec', 'glsl-1.20'),
-			 ['compiler'])
 spec['glsl-1.20']['execution'] = Group()
 
 def add_recursion_test(group, name):
@@ -867,12 +863,6 @@ add_concurrent_test(spec['glsl-1.20']['api'], 'getactiveattrib 120');
 
 # Group spec/glsl-1.30
 spec['glsl-1.30'] = Group()
-import_glsl_parser_tests(spec['glsl-1.30'],
-			 os.path.join(testsDir, 'spec', 'glsl-1.30'),
-			 ['preprocessor', 'compiler'])
-import_glsl_parser_tests(spec['glsl-1.30'],
-			 os.path.join(generatedTestDir, 'spec', 'glsl-1.30'),
-			 ['compiler'])
 spec['glsl-1.30']['execution'] = Group()
 spec['glsl-1.30']['execution']['clipping'] = Group()
 spec['glsl-1.30']['execution']['textureSize'] = Group()
@@ -907,24 +897,6 @@ add_concurrent_test(spec['glsl-1.30']['execution'], 'vertexid-drawelements')
 spec['glsl-1.30']['api'] = Group()
 add_concurrent_test(spec['glsl-1.30']['api'], 'getactiveattrib 130');
 
-# Group AMD_conservative_depth
-spec['AMD_conservative_depth'] = Group()
-import_glsl_parser_tests(spec['AMD_conservative_depth'],
-			 os.path.join(testsDir, 'spec', 'amd_conservative_depth'),
-			 [''])
-
-# Group AMD_shader_stencil_export
-spec['AMD_shader_stencil_export'] = Group()
-import_glsl_parser_tests(spec['AMD_shader_stencil_export'],
-			 os.path.join(testsDir, 'spec', 'amd_shader_stencil_export'),
-			 [''])
-
-# Group ARB_shader_stencil_export
-spec['ARB_shader_stencil_export'] = Group()
-import_glsl_parser_tests(spec['ARB_shader_stencil_export'],
-			 os.path.join(testsDir, 'spec', 'arb_shader_stencil_export'),
-			 [''])
-
 # Group ARB_ES2_compatibility
 arb_es2_compatibility = Group()
 spec['ARB_ES2_compatibility'] = arb_es2_compatibility
@@ -950,13 +922,6 @@ arb_draw_elements_base_vertex['draw-elements-base-vertex-neg-user_varrays'] = Pl
 add_plain_test(arb_draw_elements_base_vertex, 'draw-elements-instanced-base-vertex')
 arb_draw_elements_base_vertex['draw-elements-instanced-base-vertex-user_varrays'] = PlainExecTest(['draw-elements-instanced-base-vertex', '-auto', 'user_varrays'])
 
-# Group ARB_draw_instanced
-arb_draw_instanced = Group()
-spec['ARB_draw_instanced'] = arb_draw_instanced
-import_glsl_parser_tests(arb_draw_instanced,
-                        testsDir + '/spec/arb_draw_instanced',
-                        [''])
-
 # Group ARB_fragment_program
 arb_fragment_program = Group()
 spec['ARB_fragment_program'] = arb_fragment_program
@@ -987,9 +952,6 @@ add_plain_test(arb_robustness, 'arb_robustness_client-mem-bounds')
 # Group ARB_shader_texture_lod
 arb_shader_texture_lod = Group()
 spec['ARB_shader_texture_lod'] = arb_shader_texture_lod
-import_glsl_parser_tests(arb_shader_texture_lod,
-			 os.path.join(testsDir, 'spec', 'arb_shader_texture_lod'),
-			 ['compiler'])
 arb_shader_texture_lod['execution'] = Group()
 add_plain_test(arb_shader_texture_lod['execution'], 'arb_shader_texture_lod-texgrad')
 arb_shader_texture_lod['execution']['tex-miplevel-selection-texture2DLod'] = PlainExecTest(['tex-miplevel-selection', '-auto', '-nobias', '-nolod', '-GL_ARB_shader_texture_lod'])
@@ -1009,10 +971,6 @@ arb_shader_objects['delete-repeat'] = concurrent_test('arb_shader_objects-delete
 # Group ARB_explicit_attrib_location
 arb_explicit_attrib_location = Group()
 spec['ARB_explicit_attrib_location'] = arb_explicit_attrib_location
-import_glsl_parser_tests(arb_explicit_attrib_location,
-			 os.path.join(testsDir,
-			 'spec', 'arb_explicit_attrib_location'),
-			 [''])
 add_plain_test(arb_explicit_attrib_location, 'glsl-explicit-location-01')
 add_plain_test(arb_explicit_attrib_location, 'glsl-explicit-location-02')
 add_plain_test(arb_explicit_attrib_location, 'glsl-explicit-location-03')
@@ -1532,20 +1490,6 @@ arb_draw_buffers = Group()
 spec['ARB_draw_buffers'] = arb_draw_buffers
 add_plain_test(arb_draw_buffers, 'arb_draw_buffers-state_change')
 
-# group glslparsertest ------------------------------------------------------
-glslparsertest = Group()
-# Add all shader source files in the directories below.
-for filename in os.listdir(testsDir + '/glslparsertest/shaders'):
-	ext = filename.rsplit('.')[-1]
-	if ext in ['vert', 'geo', 'frag']:
-		add_glsl_parser_test(glslparsertest, path.join(testsDir, 'glslparsertest/shaders', filename), filename)
-del glslparsertest['CorrectPreprocess11.frag']
-for filename in os.listdir(testsDir + '/glslparsertest/glsl2'):
-	ext = filename.rsplit('.')[-1]
-	if ext in ['vert', 'geo', 'frag']:
-		add_glsl_parser_test(glslparsertest, path.join(testsDir, 'glslparsertest/glsl2', filename), 'glsl2/' + filename)
-# end group glslparsertest ---------------------------------------------------
-
 hiz = Group()
 add_plain_test(hiz, 'hiz-depth-stencil-test-fbo-d0-s8')
 add_plain_test(hiz, 'hiz-depth-stencil-test-fbo-d24-s0')
@@ -1585,7 +1529,6 @@ profile.tests['general'] = general
 profile.tests['hiz'] = hiz
 profile.tests['fbo'] = fbo
 profile.tests['glean'] = glean
-profile.tests['glslparsertest'] = glslparsertest
 profile.tests['mesa'] = mesa
 profile.tests['shaders'] = shaders
 profile.tests['texturing'] = texturing
-- 
1.7.7.6



More information about the Piglit mailing list