[Piglit] [PATCH 3/4] ATI_fs: add some api tests

Miklós Máté mtmkls at gmail.com
Sat Dec 2 22:36:04 UTC 2017


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

Signed-off-by: Miklós Máté <mtmkls at gmail.com>
---
 tests/all.py                                     |  2 +
 tests/spec/ati_fragment_shader/CMakeLists.gl.txt |  3 +
 tests/spec/ati_fragment_shader/api-alphafirst.c  | 71 +++++++++++++++++++
 tests/spec/ati_fragment_shader/api-gen.c         | 87 ++++++++++++++++++++++++
 4 files changed, 163 insertions(+)
 create mode 100644 tests/spec/ati_fragment_shader/api-alphafirst.c
 create mode 100644 tests/spec/ati_fragment_shader/api-gen.c

diff --git a/tests/all.py b/tests/all.py
index 29f0847cb..8f0492079 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -2096,6 +2096,8 @@ with profile.test_list.group_manager(
 with profile.test_list.group_manager(
         PiglitGLTest,
         grouptools.join('spec', 'ATI_fragment_shader')) as g:
+    g(['ati_fragment_shader-api-alphafirst'])
+    g(['ati_fragment_shader-api-gen'])
     g(['ati-fs-bad-delete'])
     g(['ati_fragment_shader-error01-genzero'])
     g(['ati_fragment_shader-error02-inside'])
diff --git a/tests/spec/ati_fragment_shader/CMakeLists.gl.txt b/tests/spec/ati_fragment_shader/CMakeLists.gl.txt
index 5783711d0..e6b2d834f 100644
--- a/tests/spec/ati_fragment_shader/CMakeLists.gl.txt
+++ b/tests/spec/ati_fragment_shader/CMakeLists.gl.txt
@@ -8,6 +8,9 @@ link_libraries (
 	${OPENGL_gl_LIBRARY}
 )
 
+piglit_add_executable (ati_fragment_shader-api-gen            api-gen.c)
+piglit_add_executable (ati_fragment_shader-api-alphafirst     api-alphafirst.c)
+
 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)
diff --git a/tests/spec/ati_fragment_shader/api-alphafirst.c b/tests/spec/ati_fragment_shader/api-alphafirst.c
new file mode 100644
index 000000000..b446e61a5
--- /dev/null
+++ b/tests/spec/ati_fragment_shader/api-alphafirst.c
@@ -0,0 +1,71 @@
+/*
+ * Copyright © 2017 Miklós Máté
+ *
+ * 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 (including the next
+ * paragraph) 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
+ * THE AUTHORS OR COPYRIGHT HOLDERS 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.
+ */
+
+/**
+ * Tests API for GL_ATI_fragment_shader: shader pass beginning with alpha instruction.
+ */
+
+#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;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+	bool pass = true;
+
+	piglit_require_extension("GL_ATI_fragment_shader");
+
+	/* Create a shader pass beginning with an alpha instruction */
+
+	glBeginFragmentShaderATI();
+	glAlphaFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE,
+			GL_PRIMARY_COLOR_ARB, GL_NONE, GL_NONE);
+	pass &= piglit_check_gl_error(GL_NO_ERROR);
+	glEndFragmentShaderATI();
+	pass &= piglit_check_gl_error(GL_NO_ERROR);
+
+	glBeginFragmentShaderATI();
+	glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
+			GL_REG_1_ATI, GL_NONE, GL_NONE);
+	glPassTexCoordATI(GL_REG_0_ATI, GL_REG_0_ATI, GL_SWIZZLE_STR_ATI);
+	glAlphaFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE,
+			GL_PRIMARY_COLOR_ARB, GL_NONE, GL_NONE);
+	pass &= piglit_check_gl_error(GL_NO_ERROR);
+	glEndFragmentShaderATI();
+	pass &= piglit_check_gl_error(GL_NO_ERROR);
+
+	piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
+}
diff --git a/tests/spec/ati_fragment_shader/api-gen.c b/tests/spec/ati_fragment_shader/api-gen.c
new file mode 100644
index 000000000..9fd941245
--- /dev/null
+++ b/tests/spec/ati_fragment_shader/api-gen.c
@@ -0,0 +1,87 @@
+/*
+ * Copyright © 2017 Miklós Máté
+ *
+ * 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 (including the next
+ * paragraph) 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
+ * THE AUTHORS OR COPYRIGHT HOLDERS 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.
+ */
+
+/**
+ * Tests basic API functionality for GL_ATI_fragment_shader:
+ * - generating names
+ * - deleting named shaders
+ */
+
+#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;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+	unsigned id;
+	bool pass = true;
+
+	piglit_require_extension("GL_ATI_fragment_shader");
+
+	/* gen some shaders */
+	id = glGenFragmentShadersATI(3);
+	pass &= piglit_check_gl_error(GL_NO_ERROR);
+	if (id == 0)
+		pass = false;
+
+	/* delete them */
+	glDeleteFragmentShaderATI(id);
+	pass &= piglit_check_gl_error(GL_NO_ERROR);
+	glDeleteFragmentShaderATI(id+1);
+	pass &= piglit_check_gl_error(GL_NO_ERROR);
+	glDeleteFragmentShaderATI(id+2);
+	pass &= piglit_check_gl_error(GL_NO_ERROR);
+
+	/* gen a few more, leave them hanging */
+	id = glGenFragmentShadersATI(3);
+	pass &= piglit_check_gl_error(GL_NO_ERROR);
+
+	/* bind allocates the name, no need for gen */
+	glBindFragmentShaderATI(42);
+	pass &= piglit_check_gl_error(GL_NO_ERROR);
+	glDeleteFragmentShaderATI(42);
+	pass &= piglit_check_gl_error(GL_NO_ERROR);
+
+	/* bind an other one, leave it hanging */
+	glBindFragmentShaderATI(43);
+	pass &= piglit_check_gl_error(GL_NO_ERROR);
+
+	/* try to delete a non-existent one */
+	glDeleteFragmentShaderATI(628);
+	pass &= piglit_check_gl_error(GL_NO_ERROR);
+
+	piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
+}
-- 
2.15.0.rc0



More information about the Piglit mailing list