[Piglit] [PATCH 1/4] ATI_fs: add api error tests

2017-12-02 Thread Miklós Máté
One for each paragraph in the Errors section of the spec.

v2: don't exit on first failure, improve some tests, move spec quotes
to top, add license headers, drop redundant error checks, add build
system integration, add tests to all.py

Signed-off-by: Miklós Máté 
---
 tests/all.py   |  14 +
 tests/spec/CMakeLists.txt  |   1 +
 tests/spec/ati_fragment_shader/CMakeLists.gl.txt   |  26 ++
 tests/spec/ati_fragment_shader/CMakeLists.txt  |   1 +
 tests/spec/ati_fragment_shader/error01-genzero.c   |  66 +
 tests/spec/ati_fragment_shader/error02-inside.c|  71 +
 tests/spec/ati_fragment_shader/error03-outside.c   |  95 ++
 tests/spec/ati_fragment_shader/error04-endshader.c | 146 ++
 tests/spec/ati_fragment_shader/error05-passes.c| 140 +
 .../spec/ati_fragment_shader/error06-regswizzle.c  | 322 +
 tests/spec/ati_fragment_shader/error07-instcount.c | 104 +++
 tests/spec/ati_fragment_shader/error08-secondary.c | 106 +++
 tests/spec/ati_fragment_shader/error09-allconst.c  | 100 +++
 tests/spec/ati_fragment_shader/error10-dotx.c  | 136 +
 .../spec/ati_fragment_shader/error11-invaliddst.c  | 175 +++
 .../spec/ati_fragment_shader/error12-invalidsrc.c  | 163 +++
 .../spec/ati_fragment_shader/error13-invalidarg.c  | 140 +
 .../spec/ati_fragment_shader/error14-invalidmod.c  | 147 ++
 18 files changed, 1953 insertions(+)
 create mode 100644 tests/spec/ati_fragment_shader/CMakeLists.gl.txt
 create mode 100644 tests/spec/ati_fragment_shader/CMakeLists.txt
 create mode 100644 tests/spec/ati_fragment_shader/error01-genzero.c
 create mode 100644 tests/spec/ati_fragment_shader/error02-inside.c
 create mode 100644 tests/spec/ati_fragment_shader/error03-outside.c
 create mode 100644 tests/spec/ati_fragment_shader/error04-endshader.c
 create mode 100644 tests/spec/ati_fragment_shader/error05-passes.c
 create mode 100644 tests/spec/ati_fragment_shader/error06-regswizzle.c
 create mode 100644 tests/spec/ati_fragment_shader/error07-instcount.c
 create mode 100644 tests/spec/ati_fragment_shader/error08-secondary.c
 create mode 100644 tests/spec/ati_fragment_shader/error09-allconst.c
 create mode 100644 tests/spec/ati_fragment_shader/error10-dotx.c
 create mode 100644 tests/spec/ati_fragment_shader/error11-invaliddst.c
 create mode 100644 tests/spec/ati_fragment_shader/error12-invalidsrc.c
 create mode 100644 tests/spec/ati_fragment_shader/error13-invalidarg.c
 create mode 100644 tests/spec/ati_fragment_shader/error14-invalidmod.c

diff --git a/tests/all.py b/tests/all.py
index e5561fbbe..2ef9ed5c4 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -2097,6 +2097,20 @@ with profile.test_list.group_manager(
 PiglitGLTest,
 grouptools.join('spec', 'ATI_fragment_shader')) as g:
 g(['ati-fs-bad-delete'])
+g(['ati_fragment_shader-error01-genzero'])
+g(['ati_fragment_shader-error02-inside'])
+g(['ati_fragment_shader-error03-outside'])
+g(['ati_fragment_shader-error04-endshader'])
+g(['ati_fragment_shader-error05-passes'])
+g(['ati_fragment_shader-error06-regswizzle'])
+g(['ati_fragment_shader-error07-instcount'])
+g(['ati_fragment_shader-error08-secondary'])
+g(['ati_fragment_shader-error09-allconst'])
+g(['ati_fragment_shader-error10-dotx'])
+g(['ati_fragment_shader-error11-invaliddst'])
+g(['ati_fragment_shader-error12-invalidsrc'])
+g(['ati_fragment_shader-error13-invalidarg'])
+g(['ati_fragment_shader-error14-invalidmod'])
 
 # Group ARB_framebuffer_object
 with profile.test_list.group_manager(
diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
index 99fa95f5f..5e66fa8e5 100644
--- a/tests/spec/CMakeLists.txt
+++ b/tests/spec/CMakeLists.txt
@@ -81,6 +81,7 @@ add_subdirectory (arb_transform_feedback3)
 add_subdirectory (arb_transform_feedback_overflow_query)
 add_subdirectory (arb_viewport_array)
 add_subdirectory (ati_envmap_bumpmap)
+add_subdirectory (ati_fragment_shader)
 add_subdirectory (ext_depth_bounds_test)
 add_subdirectory (ext_frag_depth)
 add_subdirectory (ext_fog_coord)
diff --git a/tests/spec/ati_fragment_shader/CMakeLists.gl.txt 
b/tests/spec/ati_fragment_shader/CMakeLists.gl.txt
new file mode 100644
index 0..f0d578157
--- /dev/null
+++ b/tests/spec/ati_fragment_shader/CMakeLists.gl.txt
@@ -0,0 +1,26 @@
+include_directories(
+   ${GLEXT_INCLUDE_DIR}
+   ${OPENGL_INCLUDE_PATH}
+)
+
+link_libraries (
+   piglitutil_${piglit_target_api}
+   ${OPENGL_gl_LIBRARY}
+)
+
+piglit_add_executable (ati_fragment_shader-error01-genzero
error01-genzero.c)
+piglit_add_executable (ati_fragment_shader-error02-inside error02-inside.c)
+piglit_add_executable (ati_fragment_shader-error03-outside
error03-outside.c)
+piglit_add_executable (ati_fragment_shader-error04-endshader  
error04-endshader.c)
+piglit_add_executable (ati_fragment_shader-er

Re: [Piglit] [PATCH 1/4] ATI_fs: add api error tests

2017-11-21 Thread Eric Anholt
Miklós Máté  writes:

> On 21/11/17 21:09, Eric Anholt wrote:
>> Miklós Máté  writes:
>>> +
>>> +   piglit_report_result(PIGLIT_PASS);
>>> +}
>>> diff --git a/tests/spec/ati_fragment_shader/error02-inside.c 
>>> b/tests/spec/ati_fragment_shader/error02-inside.c
>>> new file mode 100644
>>> index 0..5dee70cf6
>>> --- /dev/null
>>> +++ b/tests/spec/ati_fragment_shader/error02-inside.c
>>> @@ -0,0 +1,59 @@
>>> +/* TODO license header */
>>> +
>>> +/**
>>> + * Tests API errors for GL_ATI_fragment_shader.
>>> + * One for each paragraph in the Errors section.
>>> + */
>>> +
>>> +#include "piglit-util-gl.h"
>>> +
>>> +PIGLIT_GL_TEST_CONFIG_BEGIN
>>> +
>>> +   config.supports_gl_compat_version = 10;
>>> +   config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
>>> +
>>> +PIGLIT_GL_TEST_CONFIG_END
>>> +
>>> +enum piglit_result
>>> +piglit_display(void)
>>> +{
>>> +   /* UNREACHED */
>>> +   return PIGLIT_FAIL;
>>> +}
>>> +
>>> +#define check_gl_error(err) if (!piglit_check_gl_error(err)) 
>>> piglit_report_result(PIGLIT_FAIL)
>>> +
>>> +void
>>> +piglit_init(int argc, char **argv)
>>> +{
>>> +   piglit_require_extension("GL_ATI_fragment_shader");
>>> +
>>> +   /*
>>> +* Paragraph 2 of the Errors section:
>>> +*
>>> +* The error INVALID_OPERATION is generated if GenFragmentShadersATI,
>>> +* BindFragmentShaderATI, DeleteFragmentShaderATI, or
>>> +* BeginFragmentShaderATI are specified inside a
>>> +* Begin/EndFragmentShaderATI pair.
>>> +*/
>>> +
>>> +   glBeginFragmentShaderATI();
>>> +
>>> +   check_gl_error(GL_NO_ERROR);
>>> +   glGenFragmentShadersATI(1);
>>> +   check_gl_error(GL_INVALID_OPERATION);
>> Instead of the macro, we'll often have
>>
>> bool pass = true;
>>
>> ...
>>
>> pass = piglit_check_gl_error(GL_NO_ERROR) && pass
>> glGenFragmentShadersATI(1);
>> pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass
>>
>> ...
>>
>> piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
>>
>> That way you get to see multiple errors if there are different cases
>> failing.
> First I did that, but I had a difficult time finding out where Mesa 
> failed to throw the expected error, so I made the check fatal. If people 
> prefer non-fatal checks I can change it back.
>

piglit_check_gl_error() prints the file and line number of the check
that failed, to help you find it.

I'm not requiring a change here, just suggesting a way this has been
handled elsewhere.

>>> +   check_gl_error(GL_NO_ERROR);
>> I'd drop the GL_NO_ERROR checks -- you know there's no error because the
>> last thing you did is check the errors.
> As far as I understand the errors are pushed into a stack. I do these no 
> error checks to make sure the stack is empty before the critical call. 
> If it's not possible for one gl call to push more than one error into 
> the stack, then the no error checks can indeed be trimmed down in this test.

You can see the path in _mesa_error() -> _mesa_record_error() -- it's
just a single value, not a stack.


signature.asc
Description: PGP signature
___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


Re: [Piglit] [PATCH 1/4] ATI_fs: add api error tests

2017-11-21 Thread Miklós Máté

On 21/11/17 21:09, Eric Anholt wrote:

Miklós Máté  writes:


One for each paragraph in the Errors section of the spec.

Signed-off-by: Miklós Máté 
---
  tests/spec/ati_fragment_shader/error01-genzero.c   |  51 
  tests/spec/ati_fragment_shader/error02-inside.c|  59 +
  tests/spec/ati_fragment_shader/error03-outside.c   |  89 +++
  tests/spec/ati_fragment_shader/error04-endshader.c |  93 
  tests/spec/ati_fragment_shader/error05-passes.c| 123 ++
  .../spec/ati_fragment_shader/error06-regswizzle.c  | 263 +
  tests/spec/ati_fragment_shader/error07-instcount.c |  89 +++
  tests/spec/ati_fragment_shader/error08-secondary.c |  82 +++
  tests/spec/ati_fragment_shader/error09-allconst.c  |  78 ++
  tests/spec/ati_fragment_shader/error10-dotx.c  | 115 +
  .../spec/ati_fragment_shader/error11-invaliddst.c  | 171 ++
  .../spec/ati_fragment_shader/error12-invalidsrc.c  | 151 
  .../spec/ati_fragment_shader/error13-invalidarg.c  | 121 ++
  .../spec/ati_fragment_shader/error14-invalidmod.c  | 129 ++

We tend to implement these API error tests as a single .c file.  As
you've experienced, this is a whole lot of copy and pasting, and it's
usually not too big of a deal to get the implementation to pass all of
them.

If it *is* hard to get the implementation to pass all of them, you may
look into piglit_report_subtest_result().

That said, there are some sizeable tests here and some nice usage of
subtests in a few of them, so I think you've generally made the right
choice.

Thanks for the review. I'll refine the code accordingly.


Also, don't forget to add your tests to all.py!  If you don't, your
tests won't be run in everyone's regression testing.  Also, the build
system for the tests should be in the same commit as the tests
themselves.
This is just a preview of my work, in the final version I'll add the 
tests to all.py. I'll also remove your existing ati-fs-bad-delete test, 
because it's a subset of my api-gen test :)





diff --git a/tests/spec/ati_fragment_shader/error01-genzero.c 
b/tests/spec/ati_fragment_shader/error01-genzero.c
new file mode 100644
index 0..a19fb2ffc
--- /dev/null
+++ b/tests/spec/ati_fragment_shader/error01-genzero.c
@@ -0,0 +1,51 @@
+/* TODO license header */

You can see a sample of the license to use in the COPYING file -- just
copy and paste and change the date and "Intel Corporation" to your name.

OK, I'll use that license.



+
+/**
+ * Tests API errors for GL_ATI_fragment_shader.
+ * One for each paragraph in the Errors section.
+ */

I'd move the comment from piglit_init() to here.

Good idea, I'll do that.



+
+#include "piglit-util-gl.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+   config.supports_gl_compat_version = 10;
+   config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+enum piglit_result
+piglit_display(void)
+{
+   /* UNREACHED */
+   return PIGLIT_FAIL;
+}
+
+#define check_gl_error(err) if (!piglit_check_gl_error(err)) 
piglit_report_result(PIGLIT_FAIL)
+
+void
+piglit_init(int argc, char **argv)
+{
+   unsigned id = 42;

Unnecessary initializer.


+   piglit_require_extension("GL_ATI_fragment_shader");
+
+   /*
+* Paragraph 1 of the Errors section:
+*
+* The error INVALID_VALUE is generated if GenFragmentShadersATI is
+* called where  is zero.
+*/
+
+   id = glGenFragmentShadersATI(0);
+   check_gl_error(GL_INVALID_VALUE);
+
+   /* The spec also says that 0 is returned */
+   if (id != 0)
+   piglit_report_result(PIGLIT_FAIL);
+
+   /* Note that the spec also says that no shaders are generated,
+* but there is no way of testing that */

Our general style is that the closing */ of a multi-line comment goes on
its own line.


+
+   piglit_report_result(PIGLIT_PASS);
+}
diff --git a/tests/spec/ati_fragment_shader/error02-inside.c 
b/tests/spec/ati_fragment_shader/error02-inside.c
new file mode 100644
index 0..5dee70cf6
--- /dev/null
+++ b/tests/spec/ati_fragment_shader/error02-inside.c
@@ -0,0 +1,59 @@
+/* TODO license header */
+
+/**
+ * Tests API errors for GL_ATI_fragment_shader.
+ * One for each paragraph in the Errors section.
+ */
+
+#include "piglit-util-gl.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+   config.supports_gl_compat_version = 10;
+   config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+enum piglit_result
+piglit_display(void)
+{
+   /* UNREACHED */
+   return PIGLIT_FAIL;
+}
+
+#define check_gl_error(err) if (!piglit_check_gl_error(err)) 
piglit_report_result(PIGLIT_FAIL)
+
+void
+piglit_init(int argc, char **argv)
+{
+   piglit_require_extension("GL_ATI_fragment_shader");
+
+   /*
+* Paragraph 2 of the Errors section:
+*
+* The error INVALID_OPERATION is generated if GenFrag

Re: [Piglit] [PATCH 1/4] ATI_fs: add api error tests

2017-11-21 Thread Eric Anholt
Miklós Máté  writes:

> One for each paragraph in the Errors section of the spec.
>
> Signed-off-by: Miklós Máté 
> ---
>  tests/spec/ati_fragment_shader/error01-genzero.c   |  51 
>  tests/spec/ati_fragment_shader/error02-inside.c|  59 +
>  tests/spec/ati_fragment_shader/error03-outside.c   |  89 +++
>  tests/spec/ati_fragment_shader/error04-endshader.c |  93 
>  tests/spec/ati_fragment_shader/error05-passes.c| 123 ++
>  .../spec/ati_fragment_shader/error06-regswizzle.c  | 263 
> +
>  tests/spec/ati_fragment_shader/error07-instcount.c |  89 +++
>  tests/spec/ati_fragment_shader/error08-secondary.c |  82 +++
>  tests/spec/ati_fragment_shader/error09-allconst.c  |  78 ++
>  tests/spec/ati_fragment_shader/error10-dotx.c  | 115 +
>  .../spec/ati_fragment_shader/error11-invaliddst.c  | 171 ++
>  .../spec/ati_fragment_shader/error12-invalidsrc.c  | 151 
>  .../spec/ati_fragment_shader/error13-invalidarg.c  | 121 ++
>  .../spec/ati_fragment_shader/error14-invalidmod.c  | 129 ++

We tend to implement these API error tests as a single .c file.  As
you've experienced, this is a whole lot of copy and pasting, and it's
usually not too big of a deal to get the implementation to pass all of
them.

If it *is* hard to get the implementation to pass all of them, you may
look into piglit_report_subtest_result().

That said, there are some sizeable tests here and some nice usage of
subtests in a few of them, so I think you've generally made the right
choice.

Also, don't forget to add your tests to all.py!  If you don't, your
tests won't be run in everyone's regression testing.  Also, the build
system for the tests should be in the same commit as the tests
themselves.

> diff --git a/tests/spec/ati_fragment_shader/error01-genzero.c 
> b/tests/spec/ati_fragment_shader/error01-genzero.c
> new file mode 100644
> index 0..a19fb2ffc
> --- /dev/null
> +++ b/tests/spec/ati_fragment_shader/error01-genzero.c
> @@ -0,0 +1,51 @@
> +/* TODO license header */

You can see a sample of the license to use in the COPYING file -- just
copy and paste and change the date and "Intel Corporation" to your name.

> +
> +/**
> + * Tests API errors for GL_ATI_fragment_shader.
> + * One for each paragraph in the Errors section.
> + */

I'd move the comment from piglit_init() to here.

> +
> +#include "piglit-util-gl.h"
> +
> +PIGLIT_GL_TEST_CONFIG_BEGIN
> +
> + config.supports_gl_compat_version = 10;
> + config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
> +
> +PIGLIT_GL_TEST_CONFIG_END
> +
> +enum piglit_result
> +piglit_display(void)
> +{
> + /* UNREACHED */
> + return PIGLIT_FAIL;
> +}
> +
> +#define check_gl_error(err) if (!piglit_check_gl_error(err)) 
> piglit_report_result(PIGLIT_FAIL)
> +
> +void
> +piglit_init(int argc, char **argv)
> +{
> + unsigned id = 42;

Unnecessary initializer.

> + piglit_require_extension("GL_ATI_fragment_shader");
> +
> + /*
> +  * Paragraph 1 of the Errors section:
> +  *
> +  * The error INVALID_VALUE is generated if GenFragmentShadersATI is
> +  * called where  is zero.
> +  */
> +
> + id = glGenFragmentShadersATI(0);
> + check_gl_error(GL_INVALID_VALUE);
> +
> + /* The spec also says that 0 is returned */
> + if (id != 0)
> + piglit_report_result(PIGLIT_FAIL);
> +
> + /* Note that the spec also says that no shaders are generated,
> +  * but there is no way of testing that */

Our general style is that the closing */ of a multi-line comment goes on
its own line.

> +
> + piglit_report_result(PIGLIT_PASS);
> +}
> diff --git a/tests/spec/ati_fragment_shader/error02-inside.c 
> b/tests/spec/ati_fragment_shader/error02-inside.c
> new file mode 100644
> index 0..5dee70cf6
> --- /dev/null
> +++ b/tests/spec/ati_fragment_shader/error02-inside.c
> @@ -0,0 +1,59 @@
> +/* TODO license header */
> +
> +/**
> + * Tests API errors for GL_ATI_fragment_shader.
> + * One for each paragraph in the Errors section.
> + */
> +
> +#include "piglit-util-gl.h"
> +
> +PIGLIT_GL_TEST_CONFIG_BEGIN
> +
> + config.supports_gl_compat_version = 10;
> + config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
> +
> +PIGLIT_GL_TEST_CONFIG_END
> +
> +enum piglit_result
> +piglit_display(void)
> +{
> + /* UNREACHED */
> + return PIGLIT_FAIL;
> +}
> +
> +#define check_gl_error(err) if (!piglit_check_gl_error(err)) 
> piglit_report_result(PIGLIT_FAIL)
> +
> +void
> +piglit_init(int argc, char **argv)
> +{
> + piglit_require_extension("GL_ATI_fragment_shader");
> +
> + /*
> +  * Paragraph 2 of the Errors section:
> +  *
> +  * The error INVALID_OPERATION is generated if GenFragmentShadersATI,
> +  * BindFragmentShaderATI, DeleteFragmentShaderATI, or
> +  * BeginFragmentShaderATI are specified inside a
> +  * Begin/EndFragmentShaderATI pair.
> +   

[Piglit] [PATCH 1/4] ATI_fs: add api error tests

2017-11-20 Thread Miklós Máté
One for each paragraph in the Errors section of the spec.

Signed-off-by: Miklós Máté 
---
 tests/spec/ati_fragment_shader/error01-genzero.c   |  51 
 tests/spec/ati_fragment_shader/error02-inside.c|  59 +
 tests/spec/ati_fragment_shader/error03-outside.c   |  89 +++
 tests/spec/ati_fragment_shader/error04-endshader.c |  93 
 tests/spec/ati_fragment_shader/error05-passes.c| 123 ++
 .../spec/ati_fragment_shader/error06-regswizzle.c  | 263 +
 tests/spec/ati_fragment_shader/error07-instcount.c |  89 +++
 tests/spec/ati_fragment_shader/error08-secondary.c |  82 +++
 tests/spec/ati_fragment_shader/error09-allconst.c  |  78 ++
 tests/spec/ati_fragment_shader/error10-dotx.c  | 115 +
 .../spec/ati_fragment_shader/error11-invaliddst.c  | 171 ++
 .../spec/ati_fragment_shader/error12-invalidsrc.c  | 151 
 .../spec/ati_fragment_shader/error13-invalidarg.c  | 121 ++
 .../spec/ati_fragment_shader/error14-invalidmod.c  | 129 ++
 14 files changed, 1614 insertions(+)
 create mode 100644 tests/spec/ati_fragment_shader/error01-genzero.c
 create mode 100644 tests/spec/ati_fragment_shader/error02-inside.c
 create mode 100644 tests/spec/ati_fragment_shader/error03-outside.c
 create mode 100644 tests/spec/ati_fragment_shader/error04-endshader.c
 create mode 100644 tests/spec/ati_fragment_shader/error05-passes.c
 create mode 100644 tests/spec/ati_fragment_shader/error06-regswizzle.c
 create mode 100644 tests/spec/ati_fragment_shader/error07-instcount.c
 create mode 100644 tests/spec/ati_fragment_shader/error08-secondary.c
 create mode 100644 tests/spec/ati_fragment_shader/error09-allconst.c
 create mode 100644 tests/spec/ati_fragment_shader/error10-dotx.c
 create mode 100644 tests/spec/ati_fragment_shader/error11-invaliddst.c
 create mode 100644 tests/spec/ati_fragment_shader/error12-invalidsrc.c
 create mode 100644 tests/spec/ati_fragment_shader/error13-invalidarg.c
 create mode 100644 tests/spec/ati_fragment_shader/error14-invalidmod.c

diff --git a/tests/spec/ati_fragment_shader/error01-genzero.c 
b/tests/spec/ati_fragment_shader/error01-genzero.c
new file mode 100644
index 0..a19fb2ffc
--- /dev/null
+++ b/tests/spec/ati_fragment_shader/error01-genzero.c
@@ -0,0 +1,51 @@
+/* TODO license header */
+
+/**
+ * Tests API errors for GL_ATI_fragment_shader.
+ * One for each paragraph in the Errors section.
+ */
+
+#include "piglit-util-gl.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+   config.supports_gl_compat_version = 10;
+   config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+enum piglit_result
+piglit_display(void)
+{
+   /* UNREACHED */
+   return PIGLIT_FAIL;
+}
+
+#define check_gl_error(err) if (!piglit_check_gl_error(err)) 
piglit_report_result(PIGLIT_FAIL)
+
+void
+piglit_init(int argc, char **argv)
+{
+   unsigned id = 42;
+
+   piglit_require_extension("GL_ATI_fragment_shader");
+
+   /*
+* Paragraph 1 of the Errors section:
+*
+* The error INVALID_VALUE is generated if GenFragmentShadersATI is
+* called where  is zero.
+*/
+
+   id = glGenFragmentShadersATI(0);
+   check_gl_error(GL_INVALID_VALUE);
+
+   /* The spec also says that 0 is returned */
+   if (id != 0)
+   piglit_report_result(PIGLIT_FAIL);
+
+   /* Note that the spec also says that no shaders are generated,
+* but there is no way of testing that */
+
+   piglit_report_result(PIGLIT_PASS);
+}
diff --git a/tests/spec/ati_fragment_shader/error02-inside.c 
b/tests/spec/ati_fragment_shader/error02-inside.c
new file mode 100644
index 0..5dee70cf6
--- /dev/null
+++ b/tests/spec/ati_fragment_shader/error02-inside.c
@@ -0,0 +1,59 @@
+/* TODO license header */
+
+/**
+ * Tests API errors for GL_ATI_fragment_shader.
+ * One for each paragraph in the Errors section.
+ */
+
+#include "piglit-util-gl.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+   config.supports_gl_compat_version = 10;
+   config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+enum piglit_result
+piglit_display(void)
+{
+   /* UNREACHED */
+   return PIGLIT_FAIL;
+}
+
+#define check_gl_error(err) if (!piglit_check_gl_error(err)) 
piglit_report_result(PIGLIT_FAIL)
+
+void
+piglit_init(int argc, char **argv)
+{
+   piglit_require_extension("GL_ATI_fragment_shader");
+
+   /*
+* Paragraph 2 of the Errors section:
+*
+* The error INVALID_OPERATION is generated if GenFragmentShadersATI,
+* BindFragmentShaderATI, DeleteFragmentShaderATI, or
+* BeginFragmentShaderATI are specified inside a
+* Begin/EndFragmentShaderATI pair.
+*/
+
+   glBeginFragmentShaderATI();
+
+   check_gl_error(GL_NO_ERROR);
+   glGenFragmentShadersATI(1);
+   check_gl_error(GL_INVALID_OPERATION);
+
+   check_gl_