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

Kenneth Graunke kenneth at whitecape.org
Tue May 20 17:34:24 PDT 2014


On 05/20/2014 03:31 PM, Matt Turner wrote:
> 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

A couple of these tests are redundant or rather...absurd.

Let's run through the list...

> 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);
> +}

Seems OK.

> 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);
> +}

Seems OK.

> 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);
> +}

Seems OK.

> 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);
> +}

This ought to fail for two reasons:
1. Non-scalar used as an if condition
2. Non-boolean used as an if condition

Each of these cases is independently tested by if-01.vert and if-02.vert
in tests/glslparsertest.  They're also "meaner" in that the illegal code
is not dead code.

I'm in favor of deleting this test.

> 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);
> +}

Seems kind of weird, but sure, why not?

> 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);
> +}

This is redundant with:
tests/glslparsertest/shaders/extension3.V110.frag

I think we should delete it.

> 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);
> +}

Seems OK.  Dubious value, but why not?

> 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);
> +}

Seems OK.

> 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);
> +}

Test fails for two reasons;
1. void is missing.
2. Two literals in a row.

#1 was already tested by syntax-error-check-2, so there's no point in
checking it a second time.  I'm inclined to either add "void" back, or
delete this test.

> 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);
> +}

This test should be deleted.

The actual error here is that "x" is undeclared---which is tested by
undefined-variable.frag.  The rest of the test---negation, ternary
selection, vec4 constructors, statement with no effect---are a total red
herring.

If you add "uniform bool x;" it compiles (and I believe it should).

> 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);
> +}
> 

Seems OK.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20140520/ef91bd50/attachment.sig>


More information about the Piglit mailing list