[Piglit] [PATCH] GLX_OML_sync_control: Sanity check values returned by glXGetMscRateOML

Ian Romanick idr at freedesktop.org
Fri Dec 20 16:31:52 PST 2013


From: Ian Romanick <ian.d.romanick at intel.com>

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
Cc: Lauri Kasanen <cand at gmx.com>
---
Lauri's patches to Mesa's implementation of glXGetMscRateOML inspired me
to write this test.  Previously there were *no* calls to
glXGetMscRateOML anywhere in piglit.

 tests/all.tests                                   |  1 +
 tests/spec/glx_oml_sync_control/CMakeLists.gl.txt |  1 +
 tests/spec/glx_oml_sync_control/getmscrate.c      | 88 +++++++++++++++++++++++
 3 files changed, 90 insertions(+)
 create mode 100644 tests/spec/glx_oml_sync_control/getmscrate.c

diff --git a/tests/all.tests b/tests/all.tests
index bfffff1..229ce2a 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -443,6 +443,7 @@ create_context_es2_profile['invalid OpenGL ES version'] = concurrent_test('glx-c
 
 oml_sync_control = Group();
 glx['GLX_OML_sync_control'] = oml_sync_control
+oml_sync_control['glXGetMscRateOML'] = concurrent_test('glx-oml-sync-control-getmscrate')
 oml_sync_control['swapbuffersmsc-divisor-zero'] = concurrent_test('glx-oml-sync-control-swapbuffersmsc-divisor-zero')
 oml_sync_control['swapbuffersmsc-return'] = concurrent_test('glx-oml-sync-control-swapbuffersmsc-return')
 oml_sync_control['swapbuffersmsc-return swap_interval 0'] = concurrent_test('glx-oml-sync-control-swapbuffersmsc-return 0')
diff --git a/tests/spec/glx_oml_sync_control/CMakeLists.gl.txt b/tests/spec/glx_oml_sync_control/CMakeLists.gl.txt
index d73365d..98446cf 100644
--- a/tests/spec/glx_oml_sync_control/CMakeLists.gl.txt
+++ b/tests/spec/glx_oml_sync_control/CMakeLists.gl.txt
@@ -22,6 +22,7 @@ IF(PIGLIT_BUILD_GLX_TESTS)
 	link_libraries (
 		${X11_X11_LIB}
 	)
+	piglit_add_executable (glx-oml-sync-control-getmscrate getmscrate.c common.c)
 	piglit_add_executable (glx-oml-sync-control-swapbuffersmsc-divisor-zero swapbuffersmsc-divisor-zero.c common.c)
 	piglit_add_executable (glx-oml-sync-control-swapbuffersmsc-return swapbuffersmsc-return.c common.c)
 	piglit_add_executable (glx-oml-sync-control-waitformsc waitformsc.c common.c)
diff --git a/tests/spec/glx_oml_sync_control/getmscrate.c b/tests/spec/glx_oml_sync_control/getmscrate.c
new file mode 100644
index 0000000..9f0a43b
--- /dev/null
+++ b/tests/spec/glx_oml_sync_control/getmscrate.c
@@ -0,0 +1,88 @@
+/*
+ * Copyright © 2013 Intel Corporation
+ *
+ * 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.
+ */
+
+/**
+ * \file getmscrate.c
+ * Verifies that glXGetMscRateOML returns sensible data.
+ */
+
+#include "piglit-util-gl-common.h"
+#include "piglit-glx-util.h"
+#include "common.h"
+
+int piglit_width = 50, piglit_height = 50;
+
+enum piglit_result
+draw(Display *dpy)
+{
+	int32_t numerator = 0xDEADBEEF;
+	int32_t denominator = 0xDEADBEEF;
+	bool pass = true;
+
+	if (!glXGetMscRateOML(dpy, win, &numerator, &denominator)) {
+		printf("glXGetMscRateOML returned failure.\n");
+		return PIGLIT_FAIL;
+	}
+
+	if (numerator == 0xDEADBEEF) {
+		printf("glXGetMscRateOML did not write numerator.");
+		pass = false;
+	} else if (numerator <= 0) {
+		printf("Numerator <= 0: %d\n", numerator);
+		pass = false;
+	}
+
+	if (denominator == 0xDEADBEEF) {
+		printf("glXGetMscRateOML did not write denominator.");
+		pass = false;
+	} else if (denominator <= 0) {
+		printf("Denominator <= 0: %d\n", denominator);
+		pass = false;
+	}
+
+	/* The GLX_OML_sync_control spec says:
+	 *
+	 *     "If the MSC rate in Hertz is an integer, then <denominator>
+	 *     will be 1 and <numerator> will be the MSC rate."
+	 */
+	if (denominator != 1 && (numerator % denominator == 0)) {
+		printf("Numerator should be %d and denominator should be 1,\n"
+		       "but are %d and %d instead.\n",
+		       numerator / denominator,
+		       numerator, denominator);
+		pass = false;
+	}
+
+	piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
+
+	/* UNREACHED */
+	return PIGLIT_FAIL;
+}
+
+int
+main(int argc, char **argv)
+{
+	piglit_oml_sync_control_test_run(draw);
+
+	return 0;
+}
-- 
1.8.1.4



More information about the Piglit mailing list