[Piglit] [PATCH V6] KHR_debug: test ObjectLabel(), GetObjectLabel(), ObjectPtrLabel() and GetObjectPtrLabel()
Timothy Arceri
t_arceri at yahoo.com.au
Tue Aug 27 22:41:28 PDT 2013
V6: fix spelling of generated in multiple places
V5: Removed unneeded assignment that was also out of bounds
V4: Removed failure test that will never be true
V3: changed indentation to tabs, use test label constants
and remove unused variable
V2: fixed whitespaces, broke tests into subtests,
added missing build dir, and tidied up fail messages
Signed-off-by: Timothy Arceri <t_arceri at yahoo.com.au>
---
tests/all.tests | 5 +
tests/spec/CMakeLists.txt | 1 +
tests/spec/khr_debug/CMakeLists.gl.txt | 14 ++
tests/spec/khr_debug/CMakeLists.txt | 1 +
tests/spec/khr_debug/debug-object-label.c | 268 +++++++++++++++++++++++++++++
5 files changed, 289 insertions(+)
create mode 100644 tests/spec/khr_debug/CMakeLists.gl.txt
create mode 100644 tests/spec/khr_debug/CMakeLists.txt
create mode 100644 tests/spec/khr_debug/debug-object-label.c
diff --git a/tests/all.tests b/tests/all.tests
index 7c1503a..3effafe 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -1220,6 +1220,11 @@ arb_debug_output = Group()
spec['ARB_debug_output'] = arb_debug_output
add_plain_test(arb_debug_output, 'arb_debug_output-api_error')
+# Group KHR_debug
+khr_debug = Group()
+spec['KHR_debug'] = khr_debug
+add_plain_test(khr_debug, 'khr_debug-object-label')
+
# Group ARB_occlusion_query2
arb_occlusion_query2 = Group()
spec['ARB_occlusion_query2'] = arb_occlusion_query2
diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
index 17c991a..9c10046 100644
--- a/tests/spec/CMakeLists.txt
+++ b/tests/spec/CMakeLists.txt
@@ -1,6 +1,7 @@
add_subdirectory (amd_performance_monitor)
add_subdirectory (arb_color_buffer_float)
add_subdirectory (arb_debug_output)
+add_subdirectory (khr_debug)
add_subdirectory (arb_depth_clamp)
add_subdirectory (arb_draw_instanced)
add_subdirectory (arb_es2_compatibility)
diff --git a/tests/spec/khr_debug/CMakeLists.gl.txt b/tests/spec/khr_debug/CMakeLists.gl.txt
new file mode 100644
index 0000000..b0079df
--- /dev/null
+++ b/tests/spec/khr_debug/CMakeLists.gl.txt
@@ -0,0 +1,14 @@
+include_directories(
+ ${GLEXT_INCLUDE_DIR}
+ ${OPENGL_INCLUDE_PATH}
+)
+
+link_libraries (
+ piglitutil_${piglit_target_api}
+ ${OPENGL_gl_LIBRARY}
+ ${OPENGL_glu_LIBRARY}
+)
+
+piglit_add_executable (khr_debug-object-label debug-object-label.c)
+
+# vim: ft=cmake:
diff --git a/tests/spec/khr_debug/CMakeLists.txt b/tests/spec/khr_debug/CMakeLists.txt
new file mode 100644
index 0000000..144a306
--- /dev/null
+++ b/tests/spec/khr_debug/CMakeLists.txt
@@ -0,0 +1 @@
+piglit_include_target_api()
diff --git a/tests/spec/khr_debug/debug-object-label.c b/tests/spec/khr_debug/debug-object-label.c
new file mode 100644
index 0000000..0d16eaa
--- /dev/null
+++ b/tests/spec/khr_debug/debug-object-label.c
@@ -0,0 +1,268 @@
+/*
+ * Copyright (c) 2013 Timothy Arceri <t_arceri at yahoo.com.au>
+ *
+ * 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
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, 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
+ * NON-INFRINGEMENT. IN NO EVENT SHALL AUTHORS AND/OR THEIR SUPPLIERS
+ * 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.
+ */
+
+#include "piglit-util-gl-common.h"
+
+static const char *TestLabel = "Test Label";
+static const int TestLabelLen = 10;
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+ config.supports_gl_compat_version = 11;
+
+ config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+enum piglit_result
+piglit_display(void)
+{
+ return PIGLIT_PASS;
+}
+
+static bool
+test_object_ptr_label()
+{
+ GLsync sync;
+ GLsizei length;
+ GLchar label[11];
+ bool pass = true;
+
+ /* basic check to see if glObjectPtrLabel/glGetObjectPtrLabel
+ * set/get the label
+ */
+ sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
+ glObjectPtrLabel(sync, -1, TestLabel);
+ glGetObjectPtrLabel(sync, 12, &length, label);
+
+ if (length != TestLabelLen || (strcmp(TestLabel, label) != 0)) {
+ puts("Label or length does not match");
+ printf(" actual label: %s actual length: %i\n", label, length);
+ printf(" expected label: %s expected length: %i\n", TestLabel, TestLabelLen);
+ pass = false;
+ }
+ glDeleteSync(sync);
+
+ /* An INVALID_VALUE is generated if the <ptr> parameter of ObjectPtrLabel
+ * is not the name of a sync object.
+ */
+ glObjectPtrLabel(NULL, length, label);
+
+ if (!piglit_check_gl_error(GL_INVALID_VALUE)) {
+ puts(" GL_INVALID_VALUE should be generated when ObjectPtrLabel()"
+ " ptr is not the name of a sync object");
+ pass = false;
+ }
+
+ return pass;
+}
+
+static bool
+test_object_label()
+{
+ GLsizei numBuffers = 1;
+ GLsizei length;
+ GLuint buffers[numBuffers];
+ GLuint invalidBufferName;
+ GLint maxLabelLength;
+ GLchar label[11];
+ GLchar *bigLabel;
+ int i;
+ bool pass = true;
+
+ glGenBuffers(numBuffers, buffers);
+
+ /* An INVALID_VALUE error is generated if the number of characters in
+ * <label>, excluding the null terminator when <length> is negative, is not
+ * less than the value of MAX_LABEL_LENGTH.
+ */
+ glGetIntegerv(GL_MAX_LABEL_LENGTH, &maxLabelLength);
+ bigLabel = (char *) malloc(maxLabelLength);
+ for (i = 0; i <maxLabelLength; i++) {
+ bigLabel[i] = 'a';
+ }
+
+ glBindBuffer(GL_ARRAY_BUFFER, buffers[0]);
+ glObjectLabel(GL_BUFFER, buffers[0], -1, bigLabel);
+
+ if (!piglit_check_gl_error(GL_INVALID_VALUE)) {
+ puts(" GL_INVALID_VALUE should be generated when label >= MAX_LABEL_LENGTH");
+ pass = false;
+ }
+
+ /* If <label> is NULL, any debug label is effectively removed from the object.
+ */
+ glObjectLabel(GL_BUFFER, buffers[0], -1, TestLabel);
+ glObjectLabel(GL_BUFFER, buffers[0], -1, NULL);
+ glGetObjectLabel(GL_BUFFER, buffers[0], 11, &length, label);
+
+ if (length != 0 || (strcmp("", label) != 0)) {
+ puts("Setting label to NULL should remove the label");
+ printf(" actual label: %s actual length: %i\n", label, length);
+ pass = false;
+ }
+
+ /* An INVALID_ENUM error is generated by ObjectLabel if <identifier> is not
+ * one of the object types.
+ */
+ glObjectLabel(GL_ARRAY_BUFFER, buffers[0], -1, TestLabel);
+
+ if (!piglit_check_gl_error(GL_INVALID_ENUM)) {
+ puts(" GL_INVALID_ENUM should be generated when the ObjectLabel identifier is invalid");
+ pass = false;
+ }
+
+ /* An INVALID_VALUE error is generated by ObjectLabel if <name> is not
+ * the name of a valid object of the type specified by <identifier>.
+ */
+ invalidBufferName = buffers[0];
+ glDeleteBuffers(numBuffers, buffers);
+ glObjectLabel(GL_BUFFER, invalidBufferName, -1, TestLabel);
+
+ if (!piglit_check_gl_error(GL_INVALID_VALUE)) {
+ puts(" GL_INVALID_VALUE should be generated when the ObjectLabel name is invalid");
+ pass = false;
+ }
+
+ return pass;
+}
+
+static bool
+test_get_object_label()
+{
+ GLsizei numBuffers = 5;
+ GLsizei length;
+ GLuint buffers[numBuffers];
+ GLuint invalidBufferName;
+ GLchar label[12];
+ bool pass = true;
+
+ glGenBuffers(numBuffers, buffers);
+
+ /* The maximum number of characters that may
+ * be written into <label>, including the null terminator, is specified by
+ * <bufSize>.
+ */
+ glBindBuffer(GL_ARRAY_BUFFER, buffers[0]);
+ glObjectLabel(GL_BUFFER, buffers[0], -1, TestLabel);
+ glGetObjectLabel(GL_BUFFER, buffers[0], 10, &length, label);
+
+ if (length != 9 || (strcmp("Test Labe", label) != 0)) {
+ puts("BufSize should limit the maximum label length to 9");
+ printf(" actual label: %s actual length: %i\n", label, length);
+ pass = false;
+ }
+
+ /* If no debug label was specified for the object then <label>
+ * will contain a null-terminated empty string, and zero will be returned
+ * in <length>.
+ */
+ glBindBuffer(GL_ARRAY_BUFFER, buffers[1]);
+ glGetObjectLabel(GL_BUFFER, buffers[1], 11, &length, label);
+
+ if (length != 0 || (strcmp("", label) != 0)) {
+ puts("Label should be empty and length 0");
+ printf(" actual label: %s actual length: %i\n", label, length);
+ pass = false;
+ }
+
+ /* If <label> is NULL and <length> is non-NULL then no string
+ * will be returned and the length of the label will be returned in
+ * <length>.
+ */
+ glBindBuffer(GL_ARRAY_BUFFER, buffers[2]);
+ glObjectLabel(GL_BUFFER, buffers[2], -1, TestLabel);
+ glGetObjectLabel(GL_BUFFER, buffers[2], 11, &length, NULL);
+
+ if (length != TestLabelLen) {
+ printf("Label length should be %i\n", TestLabelLen);
+ printf(" actual length: %i\n", length);
+ pass = false;
+ }
+
+ /* If <length> is NULL, no length is returned.
+ */
+ glBindBuffer(GL_ARRAY_BUFFER, buffers[3]);
+ glObjectLabel(GL_BUFFER, buffers[3], -1, TestLabel);
+ glGetObjectLabel(GL_BUFFER, buffers[3], 11, NULL, label);
+
+ if (strcmp(TestLabel, label) != 0) {
+ puts("Label doent match expected string when length NULL");
+ printf(" label: %s expected: %s\n", label, TestLabel);
+ pass = false;
+ }
+
+ /* <label> will be null-terminated. The actual number of
+ * characters written into <label>,
+ * excluding the null terminator, is returned in <length>.
+ */
+ glBindBuffer(GL_ARRAY_BUFFER, buffers[4]);
+ glObjectLabel(GL_BUFFER, buffers[4], -1, TestLabel);
+ glGetObjectLabel(GL_BUFFER, buffers[4], 12, &length, label);
+
+ if (length != TestLabelLen || (strcmp(TestLabel, label) != 0)) {
+ puts("Label or length does not match");
+ printf(" actual label: %s actual length: %i\n", label, length);
+ printf(" expected label: %s expected length: %i\n", TestLabel, TestLabelLen);
+ pass = false;
+ }
+
+ /* An INVALID_ENUM error is generated by GetObjectLabel if identifier is not
+ * one of the valid object types
+ */
+ glGetObjectLabel(GL_ARRAY_BUFFER, buffers[4], 11, &length, label);
+
+ if (!piglit_check_gl_error(GL_INVALID_ENUM)) {
+ puts(" GL_INVALID_ENUM should be generated when GetObjectLabel identifier is invalid");
+ pass = false;
+ }
+
+ /* An INVALID_VALUE error is generated by GetObjectLabel if <name> is not
+ * the name of a valid object of the type specified by <identifier>.
+ */
+ invalidBufferName = buffers[4];
+ glDeleteBuffers(numBuffers, buffers);
+ glGetObjectLabel(GL_BUFFER, invalidBufferName, 11, &length, label);
+
+ if (!piglit_check_gl_error(GL_INVALID_VALUE)) {
+ puts(" GL_INVALID_VALUE should be generated when GetObjectLabel name is invalid");
+ pass = false;
+ }
+
+ return pass;
+}
+
+void piglit_init(int argc, char **argv)
+{
+ bool pass = true;
+
+ piglit_require_extension("GL_KHR_debug");
+
+ pass = test_object_label() && pass;
+ pass = test_get_object_label() && pass;
+ if (piglit_is_extension_supported("GL_ARB_sync"))
+ pass = test_object_ptr_label() && pass;
+
+ piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
+}
--
1.7.9.5
More information about the Piglit
mailing list