[Piglit] [PATCH 02/11] glean/glsl1: Port illegal shader tests to piglit.

Matt Turner mattst88 at gmail.com
Tue May 20 15:31:54 PDT 2014


From: Kenneth Graunke <kenneth at whitecape.org>

---
 tests/glean/tglsl1.cpp                             | 152 +--------------------
 tests/shaders/glsl1/COPYRIGHT                      |  31 +++++
 tests/shaders/glsl1/break-with-no-loop.frag        |   9 ++
 tests/shaders/glsl1/continue-with-no-loop.frag     |   9 ++
 .../shaders/glsl1/glsl-1.20-array-error-check.frag |  11 ++
 tests/shaders/glsl1/if-boolean-scalar-check.frag   |  11 ++
 tests/shaders/glsl1/illegal-assignment.frag        |   9 ++
 .../glsl1/preprocessor-test-extension-test-3.frag  |  10 ++
 tests/shaders/glsl1/syntax-error-check-1.frag      |   9 ++
 tests/shaders/glsl1/syntax-error-check-2.frag      |   8 ++
 tests/shaders/glsl1/syntax-error-check-3.frag      |   9 ++
 .../glsl1/t-intermediate-add-unary-math.frag       |   8 ++
 tests/shaders/glsl1/undefined-variable.frag        |   9 ++
 13 files changed, 134 insertions(+), 151 deletions(-)
 create mode 100644 tests/shaders/glsl1/COPYRIGHT
 create mode 100644 tests/shaders/glsl1/break-with-no-loop.frag
 create mode 100644 tests/shaders/glsl1/continue-with-no-loop.frag
 create mode 100644 tests/shaders/glsl1/glsl-1.20-array-error-check.frag
 create mode 100644 tests/shaders/glsl1/if-boolean-scalar-check.frag
 create mode 100644 tests/shaders/glsl1/illegal-assignment.frag
 create mode 100644 tests/shaders/glsl1/preprocessor-test-extension-test-3.frag
 create mode 100644 tests/shaders/glsl1/syntax-error-check-1.frag
 create mode 100644 tests/shaders/glsl1/syntax-error-check-2.frag
 create mode 100644 tests/shaders/glsl1/syntax-error-check-3.frag
 create mode 100644 tests/shaders/glsl1/t-intermediate-add-unary-math.frag
 create mode 100644 tests/shaders/glsl1/undefined-variable.frag

diff --git a/tests/glean/tglsl1.cpp b/tests/glean/tglsl1.cpp
index 4cb2ad0..cd0d449 100644
--- a/tests/glean/tglsl1.cpp
+++ b/tests/glean/tglsl1.cpp
@@ -43,7 +43,6 @@ namespace GLEAN {
 
 #define FLAG_NONE             0x0
 #define FLAG_LOOSE            0x1 // to indicate a looser tolerance test is needed
-#define FLAG_ILLEGAL_SHADER   0x2  // the shader test should not compile
 #define FLAG_ILLEGAL_LINK     0x4  // the shaders should not link
 #define FLAG_VERSION_1_20     0x8  // GLSL 1.20 test
 #define FLAG_VERSION_1_30     0x10  // GLSL 1.30 test
@@ -3252,19 +3251,6 @@ static const ShaderProgram Programs[] = {
 	},
 
 	{
-		// Test using a non-existant function.  Should not compile.
-		"Preprocessor test (extension test 3)",
-		NO_VERTEX_SHADER,
-		"#extension GL_FOO_bar: require\n"
-		"void main() { \n"
-		"   gl_FragColor = vec4(1.0, 0.0, 0.0, 0.0); \n"
-		"} \n",
-		{ 0.0, 1.0, 0.0, 0.0 },
-		DONT_CARE_Z,
-		FLAG_ILLEGAL_SHADER
-	},
-
-	{
 		"Preprocessor test (11)",
 		NO_VERTEX_SHADER,
 		"#define FOO \n"
@@ -3343,116 +3329,6 @@ static const ShaderProgram Programs[] = {
 		FLAG_NONE
 	},
 
-
-	// Illegal shaders ==================================================
-	{
-		"undefined variable",
-		NO_VERTEX_SHADER,
-		"void main() { \n"
-		"   vec3 v = u; \n"
-		"   gl_FragColor = vec4(0.5); \n"
-		"} \n",
-		{ 0.5, 0.5, 0.5, 0.5 },
-		DONT_CARE_Z,
-		FLAG_ILLEGAL_SHADER
-	},
-
-	{
-		"if (boolean-scalar) check",
-		NO_VERTEX_SHADER,
-		"void main() { \n"
-		"   vec3 v; \n"
-		"   if (v) { \n"
-		"   } \n"
-		"   gl_FragColor = vec4(0.5); \n"
-		"} \n",
-		{ 0.5, 0.5, 0.5, 0.5 },
-		DONT_CARE_Z,
-		FLAG_ILLEGAL_SHADER
-	},
-
-	{
-		"break with no loop",
-		NO_VERTEX_SHADER,
-		"void main() { \n"
-		"   break; \n"
-		"   gl_FragColor = vec4(0.5); \n"
-		"} \n",
-		{ 0.5, 0.5, 0.5, 0.5 },
-		DONT_CARE_Z,
-		FLAG_ILLEGAL_SHADER
-	},
-
-	{
-		"continue with no loop",
-		NO_VERTEX_SHADER,
-		"void main() { \n"
-		"   continue; \n"
-		"   gl_FragColor = vec4(0.5); \n"
-		"} \n",
-		{ 0.5, 0.5, 0.5, 0.5 },
-		DONT_CARE_Z,
-		FLAG_ILLEGAL_SHADER
-	},
-
-	{
-		"illegal assignment",
-		NO_VERTEX_SHADER,
-		"void main() { \n"
-		"   float x = main; \n"
-		"   gl_FragColor = vec4(0.5); \n"
-		"} \n",
-		{ 0.5, 0.5, 0.5, 0.5 },
-		DONT_CARE_Z,
-		FLAG_ILLEGAL_SHADER
-	},
-
-	{
-		"syntax error check (1)",
-		NO_VERTEX_SHADER,
-		"void main() { \n"
-		"   float x = ; \n"
-		"   gl_FragColor = vec4(0.5); \n"
-		"} \n",
-		{ 0.5, 0.5, 0.5, 0.5 },
-		DONT_CARE_Z,
-		FLAG_ILLEGAL_SHADER
-	},
-
-	{
-		"syntax error check (2)",
-		NO_VERTEX_SHADER,
-		"main() { \n"
-		"   gl_FragColor = vec4(0.5); \n"
-		"} \n",
-		{ 0.5, 0.5, 0.5, 0.5 },
-		DONT_CARE_Z,
-		FLAG_ILLEGAL_SHADER
-	},
-
-	{
-		"syntax error check (3)",
-		NO_VERTEX_SHADER,
-		"main() { \n"
-		"   float x = 1.0 2.0; \n"
-		"   gl_FragColor = vec4(0.5); \n"
-		"} \n",
-		{ 0.5, 0.5, 0.5, 0.5 },
-		DONT_CARE_Z,
-		FLAG_ILLEGAL_SHADER
-	},
-
-	{
-		"TIntermediate::addUnaryMath",
-		NO_VERTEX_SHADER,
-		"void main() { \n"
-		"   -vec4(x ? 1.0 : -1.0); \n"
-		"} \n",
-		{ 0.5, 0.5, 0.5, 0.5 },
-		DONT_CARE_Z,
-		FLAG_ILLEGAL_SHADER
-	},
-
 	// GLSL 1.20 tests ======================================================
 	{
 		"mat2x4 construct",
@@ -3883,19 +3759,6 @@ static const ShaderProgram Programs[] = {
 		DONT_CARE_Z,
 		FLAG_VERSION_1_20
 	},
-	{
-		"GLSL 1.20 array error check",
-		NO_VERTEX_SHADER,
-		"#version 120 \n"
-		"// Note array size disagreement here: \n"
-		"const float [2] x = float[3](1.0, 2.0); \n"
-		"void main() { \n"
-		"   gl_FragColor = vec4(1); \n"
-		"} \n",
-		{ 1.0, 1.0, 1.0, 1.0 },
-		DONT_CARE_Z,
-		FLAG_VERSION_1_20 | FLAG_ILLEGAL_SHADER
-	},
 
 	// Other new GLSL 1.20, 1.30 features (just parse/compile tests)
 	{
@@ -4369,7 +4232,7 @@ GLSLTest::checkCompileStatus(GLenum target, GLuint shader,
 		// env->log << infoLog << "\n";
 	}
 
-	if (!stat && (p.flags & FLAG_ILLEGAL_SHADER) == 0) {
+	if (!stat) {
 		// this _should_ have compiled
 		env->log << "FAILURE:\n";
 		env->log << "  Shader test: " << p.name << "\n";
@@ -4380,13 +4243,6 @@ GLSLTest::checkCompileStatus(GLenum target, GLuint shader,
 		env->log << infoLog;
 		return false;
 	}
-	else if (stat && (p.flags & FLAG_ILLEGAL_SHADER)) {
-		// this should _not_ have compiled!
-		env->log << "FAILURE:\n";
-		env->log << "  Shader test: " << p.name << "\n";
-		env->log << "  Shader should not have compiled, but it did.\n";
-		return false;
-	}
 	return true;
 }
 
@@ -4446,12 +4302,6 @@ GLSLTest::testProgram(const ShaderProgram &p)
 		goto cleanup;
 	}
 
-	if (p.flags & FLAG_ILLEGAL_SHADER) {
-		// don't render/test
-		retVal = true;
-		goto cleanup;
-	}
-
 	program = glCreateProgram();
 	if (fragShader)
 		glAttachShader(program, fragShader);
diff --git a/tests/shaders/glsl1/COPYRIGHT b/tests/shaders/glsl1/COPYRIGHT
new file mode 100644
index 0000000..057bba2
--- /dev/null
+++ b/tests/shaders/glsl1/COPYRIGHT
@@ -0,0 +1,31 @@
+Shaders in this directory were ported from Glean, and have the following
+copyright:
+
+// BEGIN_COPYRIGHT -*- glean -*-
+//
+// Copyright (C) 1999  Allen Akin   All Rights Reserved.
+// Copyright (C) 2008  VMware, Inc.  All Rights Reserved.
+// 
+// Permission is hereby granted, free of charge, to any person
+// obtaining a copy of this software and associated documentation
+// files (the "Software"), to deal in the Software without
+// restriction, including without limitation the rights to use,
+// copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following
+// conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the
+// Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+// KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+// WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+// PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL ALLEN AKIN BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+// AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+// OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+//
+// END_COPYRIGHT
diff --git a/tests/shaders/glsl1/break-with-no-loop.frag b/tests/shaders/glsl1/break-with-no-loop.frag
new file mode 100644
index 0000000..350635e
--- /dev/null
+++ b/tests/shaders/glsl1/break-with-no-loop.frag
@@ -0,0 +1,9 @@
+// [config]
+// expect_result: fail
+// glsl_version: 1.10
+// [end config]
+
+void main() {
+   break;
+   gl_FragColor = vec4(0.5);
+}
diff --git a/tests/shaders/glsl1/continue-with-no-loop.frag b/tests/shaders/glsl1/continue-with-no-loop.frag
new file mode 100644
index 0000000..57da42c
--- /dev/null
+++ b/tests/shaders/glsl1/continue-with-no-loop.frag
@@ -0,0 +1,9 @@
+// [config]
+// expect_result: fail
+// glsl_version: 1.10
+// [end config]
+
+void main() {
+   continue;
+   gl_FragColor = vec4(0.5);
+}
diff --git a/tests/shaders/glsl1/glsl-1.20-array-error-check.frag b/tests/shaders/glsl1/glsl-1.20-array-error-check.frag
new file mode 100644
index 0000000..6230549
--- /dev/null
+++ b/tests/shaders/glsl1/glsl-1.20-array-error-check.frag
@@ -0,0 +1,11 @@
+// [config]
+// expect_result: fail
+// glsl_version: 1.10
+// [end config]
+
+#version 120
+// Note array size disagreement here:
+const float [2] x = float[3](1.0, 2.0);
+void main() {
+   gl_FragColor = vec4(1);
+}
diff --git a/tests/shaders/glsl1/if-boolean-scalar-check.frag b/tests/shaders/glsl1/if-boolean-scalar-check.frag
new file mode 100644
index 0000000..4a2c85e
--- /dev/null
+++ b/tests/shaders/glsl1/if-boolean-scalar-check.frag
@@ -0,0 +1,11 @@
+// [config]
+// expect_result: fail
+// glsl_version: 1.10
+// [end config]
+
+void main() {
+   vec3 v;
+   if (v) {
+   }
+   gl_FragColor = vec4(0.5);
+}
diff --git a/tests/shaders/glsl1/illegal-assignment.frag b/tests/shaders/glsl1/illegal-assignment.frag
new file mode 100644
index 0000000..4ede1e6
--- /dev/null
+++ b/tests/shaders/glsl1/illegal-assignment.frag
@@ -0,0 +1,9 @@
+// [config]
+// expect_result: fail
+// glsl_version: 1.10
+// [end config]
+
+void main() {
+   float x = main;
+   gl_FragColor = vec4(0.5);
+}
diff --git a/tests/shaders/glsl1/preprocessor-test-extension-test-3.frag b/tests/shaders/glsl1/preprocessor-test-extension-test-3.frag
new file mode 100644
index 0000000..8e99f60
--- /dev/null
+++ b/tests/shaders/glsl1/preprocessor-test-extension-test-3.frag
@@ -0,0 +1,10 @@
+// [config]
+// expect_result: fail
+// glsl_version: 1.10
+// [end config]
+
+// Test using a non-existant function.  Should not compile.
+#extension GL_FOO_bar: require
+void main() {
+   gl_FragColor = vec4(1.0, 0.0, 0.0, 0.0);
+}
diff --git a/tests/shaders/glsl1/syntax-error-check-1.frag b/tests/shaders/glsl1/syntax-error-check-1.frag
new file mode 100644
index 0000000..6b0ba27
--- /dev/null
+++ b/tests/shaders/glsl1/syntax-error-check-1.frag
@@ -0,0 +1,9 @@
+// [config]
+// expect_result: fail
+// glsl_version: 1.10
+// [end config]
+
+void main() {
+   float x = ;
+   gl_FragColor = vec4(0.5);
+}
diff --git a/tests/shaders/glsl1/syntax-error-check-2.frag b/tests/shaders/glsl1/syntax-error-check-2.frag
new file mode 100644
index 0000000..baf5afc
--- /dev/null
+++ b/tests/shaders/glsl1/syntax-error-check-2.frag
@@ -0,0 +1,8 @@
+// [config]
+// expect_result: fail
+// glsl_version: 1.10
+// [end config]
+
+main() {
+   gl_FragColor = vec4(0.5);
+}
diff --git a/tests/shaders/glsl1/syntax-error-check-3.frag b/tests/shaders/glsl1/syntax-error-check-3.frag
new file mode 100644
index 0000000..1610e61
--- /dev/null
+++ b/tests/shaders/glsl1/syntax-error-check-3.frag
@@ -0,0 +1,9 @@
+// [config]
+// expect_result: fail
+// glsl_version: 1.10
+// [end config]
+
+main() {
+   float x = 1.0 2.0;
+   gl_FragColor = vec4(0.5);
+}
diff --git a/tests/shaders/glsl1/t-intermediate-add-unary-math.frag b/tests/shaders/glsl1/t-intermediate-add-unary-math.frag
new file mode 100644
index 0000000..c8d672f
--- /dev/null
+++ b/tests/shaders/glsl1/t-intermediate-add-unary-math.frag
@@ -0,0 +1,8 @@
+// [config]
+// expect_result: fail
+// glsl_version: 1.10
+// [end config]
+
+void main() {
+   -vec4(x ? 1.0 : -1.0);
+}
diff --git a/tests/shaders/glsl1/undefined-variable.frag b/tests/shaders/glsl1/undefined-variable.frag
new file mode 100644
index 0000000..0ca7525
--- /dev/null
+++ b/tests/shaders/glsl1/undefined-variable.frag
@@ -0,0 +1,9 @@
+// [config]
+// expect_result: fail
+// glsl_version: 1.10
+// [end config]
+
+void main() {
+   vec3 v = u;
+   gl_FragColor = vec4(0.5);
+}
-- 
1.8.3.2



More information about the Piglit mailing list