[Piglit] [PATCH 2/4] KHR_debug: test PushDebugGroup() and PopDebugGroup()
Timothy Arceri
t_arceri at yahoo.com.au
Thu Aug 29 21:22:40 PDT 2013
---
tests/spec/khr_debug/debug-push-pop-group.c | 281 +++++++++++++++++++++++++++
1 file changed, 281 insertions(+)
create mode 100644 tests/spec/khr_debug/debug-push-pop-group.c
diff --git a/tests/spec/khr_debug/debug-push-pop-group.c b/tests/spec/khr_debug/debug-push-pop-group.c
new file mode 100644
index 0000000..c60e040
--- /dev/null
+++ b/tests/spec/khr_debug/debug-push-pop-group.c
@@ -0,0 +1,281 @@
+/*
+ * 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 *TestMessage1 = "Piglit Message 1";
+static const char *TestMessage2 = "Piglit Message 2";
+static const char *TestMessage3 = "Piglit Message 3";
+static const char *TestMessage4 = "Piglit Message 4";
+
+static const int MessageId1 = 101;
+static const int MessageId2 = 202;
+static const int MessageId3 = 303;
+static const int MessageId4 = 404;
+
+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 GLboolean fetch_one_log_message()
+{
+ char log[4096];
+ GLboolean ret =
+ !!glGetDebugMessageLog(1, 4096, NULL, NULL, NULL, NULL, NULL, log);
+
+ if (ret) {
+ printf("Log: %s\n", log);
+ }
+ return ret;
+}
+
+static bool check_inheritance_messages(int expectedCount, GLuint* expectedIds)
+{
+ bool pass = true;
+ int max_messages = 5;
+ int bufSize = 1280;
+ int i;
+ GLuint count;
+ GLuint ids[max_messages];
+ GLchar messageLog[bufSize];
+
+ count = glGetDebugMessageLog(max_messages,
+ bufSize,
+ NULL,
+ NULL,
+ ids,
+ NULL,
+ NULL,
+ messageLog);
+
+ if (count != expectedCount) {
+ fprintf(stderr, "Expected message count: %i Actual message count: %i\n",
+ expectedCount, count);
+ pass = false;
+ }
+
+ for (i = 0; i < count; i++) {
+ if (expectedIds[i] != ids[i]) {
+ fprintf(stderr, "Expected id: %i Actual id: %i\n",
+ expectedIds[i], ids[i]);
+ pass = false;
+ }
+ }
+
+ return pass;
+}
+
+static void insert_inheritance_messages()
+{
+ glDebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_MARKER, MessageId1,
+ GL_DEBUG_SEVERITY_NOTIFICATION, -1, TestMessage1);
+
+ glDebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_MARKER, MessageId2,
+ GL_DEBUG_SEVERITY_NOTIFICATION, -1, TestMessage2);
+
+ glDebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_MARKER, MessageId3,
+ GL_DEBUG_SEVERITY_NOTIFICATION, -1, TestMessage3);
+
+ glDebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_MARKER, MessageId4,
+ GL_DEBUG_SEVERITY_NOTIFICATION, -1, TestMessage4);
+}
+
+/*
+ * Test inheritance of group filtering (nesting)
+ */
+static bool test_push_pop_group_inheritance()
+{
+ bool pass = true;
+ GLuint allowedIds1[] = {MessageId1};
+ GLuint allowedIds2[] = {MessageId2};
+ GLuint allowedIds3[] = {MessageId3};
+
+ GLuint expectedIds1[] = {MessageId1};
+ GLuint expectedIds2[] = {MessageId1, MessageId2};
+ GLuint expectedIds3[] = {MessageId1, MessageId2, MessageId3};
+
+ puts("Testing Push Pop debug group inheritance");
+
+ /* Setup of the default active debug group: Filter everything out */
+ glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE,
+ GL_DONT_CARE, 0, NULL, GL_FALSE);
+
+ /* Push debug group 1 and allow messages with the id 101*/
+ glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 1, -1, "Push_Pop 1");
+ glDebugMessageControl(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_MARKER,
+ GL_DONT_CARE, 1, allowedIds1, GL_TRUE);
+ insert_inheritance_messages();
+ pass = check_inheritance_messages(1, expectedIds1);
+
+ /* Push debug group 1 and allow messages with the id 101 and 202*/
+ glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 1, -1, "Push_Pop 2");
+ glDebugMessageControl(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_MARKER,
+ GL_DONT_CARE, 1, allowedIds2, GL_TRUE);
+ insert_inheritance_messages();
+ pass = check_inheritance_messages(2, expectedIds2) && pass;
+
+ /* Push debug group 1 and allow messages with the id 101, 202 and 303*/
+ glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 1, -1, "Push_Pop 3");
+ glDebugMessageControl(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_MARKER,
+ GL_DONT_CARE, 1, allowedIds3, GL_TRUE);
+ insert_inheritance_messages();
+ pass = check_inheritance_messages(3, expectedIds3) && pass;
+
+ /* Pop debug group 3 */
+ glPopDebugGroup();
+ insert_inheritance_messages();
+ pass = check_inheritance_messages(2, expectedIds2) && pass;
+
+ /* Pop debug group 2 */
+ glPopDebugGroup();
+ insert_inheritance_messages();
+ pass = check_inheritance_messages(1, expectedIds1) && pass;
+
+ /* Pop group 1, restore the volume control of the default debug group. */
+ glPopDebugGroup();
+ insert_inheritance_messages();
+
+ if (fetch_one_log_message()) {
+ fprintf(stderr, "The message log should be empty\n");
+ pass = false;
+ }
+
+ return pass;
+}
+
+/*
+ * Test Push/Pop Debug Group
+ */
+static bool test_push_pop_debug_group()
+{
+ bool pass = true;
+ int max_messages = 5;
+ int bufSize = 1280;
+ int i, nextMessage = 0;
+ GLuint count;
+
+ GLsizei lengths[max_messages];
+ GLchar messageLog[bufSize];
+
+ puts("Testing Push Pop debug message group");
+
+ /* Setup of the default active debug group: Filter everything in */
+ glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE,
+ 0, NULL, GL_TRUE);
+
+ /* Generate a debug marker debug output message */
+ glDebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_MARKER, MessageId1,
+ GL_DEBUG_SEVERITY_NOTIFICATION, -1, TestMessage1);
+
+ /* Push debug group 1 */
+ glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 1, -1, TestMessage2);
+
+ /* Setup of the debug group 1: Filter everything out */
+ glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE,
+ 0, NULL, GL_FALSE);
+
+ /* This message shouldn't appear in the debug output log */
+ glDebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_MARKER, MessageId1,
+ GL_DEBUG_SEVERITY_NOTIFICATION, -1, TestMessage3);
+
+ /* Pop group 1, restore the volume control of the default debug group. */
+ glPopDebugGroup();
+
+ /* Generate a debug marker debug output message */
+ glDebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_MARKER, MessageId1,
+ GL_DEBUG_SEVERITY_NOTIFICATION, -1, TestMessage4);
+
+ /* Check that message log has done correct filtering */
+ count = glGetDebugMessageLog(max_messages,
+ bufSize,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ lengths,
+ messageLog);
+
+ if (count != 4) {
+ fprintf(stderr, "The message log should contain 4 messages not %i messages\n", count);
+ pass = false;
+ }
+
+ if (pass) {
+ /* the thrid message should be from glPopDebugGroup() */
+ nextMessage = lengths[0] + lengths[1];
+ if (strcmp(TestMessage2, messageLog+nextMessage) != 0) {
+ fprintf(stderr, "Expected: %s Message: %s\n", TestMessage2, messageLog+nextMessage);
+ pass = false;
+ }
+
+ /* double check that message 3 didnt sneak into the list */
+ nextMessage = 0;
+ for (i = 0; i < count; i++) {
+ if (strcmp(TestMessage3, messageLog+nextMessage) == 0) {
+ fprintf(stderr, "The log should not contain the message: %s",
+ messageLog+nextMessage);
+ pass = false;
+ }
+ nextMessage += lengths[i];
+ }
+
+ /* the forth message should be message 4 */
+ nextMessage = lengths[0] + lengths[1] + lengths[2] + lengths[4];
+ if (strcmp(TestMessage4, messageLog+nextMessage) != 0) {
+ fprintf(stderr, "Expected: %s Message: %s\n", TestMessage4, messageLog+nextMessage);
+ pass = false;
+ }
+ }
+
+ return pass;
+}
+
+void piglit_init(int argc, char **argv)
+{
+ bool pass = true;
+
+ piglit_require_extension("GL_KHR_debug");
+
+ glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
+ glEnable(GL_DEBUG_OUTPUT);
+
+ if (!piglit_check_gl_error(GL_NO_ERROR))
+ piglit_report_result(PIGLIT_FAIL);
+
+ /* test message control and debug groups */
+ pass = test_push_pop_debug_group();
+ pass = test_push_pop_group_inheritance() && pass;
+
+ piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
+}
--
1.7.9.5
More information about the Piglit
mailing list