summaryrefslogtreecommitdiff
path: root/test/glx_public_api.c
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2013-11-11 09:59:25 -0800
committerEric Anholt <eric@anholt.net>2013-11-14 11:18:15 -0800
commit04cf940e1b6406e3bda59b857fe410073332b032 (patch)
treef5cc9cb4f99609488df9a462b3c334779761ff53 /test/glx_public_api.c
parented938dc4c592f0e3420a2b0ab6e3b5f9cec0c1f7 (diff)
downloadlibepoxy-04cf940e1b6406e3bda59b857fe410073332b032.tar.gz
Add an initial testsuite for GLX API.
Diffstat (limited to 'test/glx_public_api.c')
-rw-r--r--test/glx_public_api.c103
1 files changed, 103 insertions, 0 deletions
diff --git a/test/glx_public_api.c b/test/glx_public_api.c
new file mode 100644
index 0000000..71cf45c
--- /dev/null
+++ b/test/glx_public_api.c
@@ -0,0 +1,103 @@
+/*
+ * 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.
+ */
+
+#include <stdio.h>
+#include <assert.h>
+#include "epoxy/gl.h"
+#include "epoxy/glx.h"
+#include <X11/Xlib.h>
+
+#include "glx_common.h"
+
+static Display *dpy;
+
+static bool
+test_gl_version(void)
+{
+ int version = epoxy_gl_version();
+ if (version < 12) {
+ fprintf(stderr,
+ "Reported GL version %d, should be at least 12\n",
+ version);
+ return false;
+ }
+
+ return true;
+}
+
+static bool
+test_glx_version(void)
+{
+ int version = epoxy_glx_version();
+ const char *version_string;
+ int ret;
+ int server_major, server_minor;
+ int client_major, client_minor;
+ int server, client, expected;
+
+ if (version < 13) {
+ fprintf(stderr,
+ "Reported GLX version %d, should be at least 13 "
+ "according to Linux GL ABI\n",
+ version);
+ return false;
+ }
+
+ version_string = glXQueryServerString(dpy, 0, GLX_VERSION);
+ ret = sscanf(version_string, "%d.%d", &server_major, &server_minor);
+ assert(ret == 2);
+ server = server_major * 10 + server_minor;
+
+ version_string = glXGetClientString(dpy, GLX_VERSION);
+ ret = sscanf(version_string, "%d.%d", &client_major, &client_minor);
+ assert(ret == 2);
+ client = client_major * 10 + client_minor;
+
+ if (client < server)
+ expected = client;
+ else
+ expected = server;
+
+ if (version != expected) {
+ fprintf(stderr,
+ "Reported GLX version %d, should be %d (%s)\n",
+ version, expected, version_string);
+ return false;
+ }
+
+ return true;
+}
+
+int
+main(int argc, char **argv)
+{
+ bool pass = true;
+
+ dpy = get_display_or_skip();
+ make_glx_context_current_or_skip(dpy);
+
+ pass = test_gl_version() && pass;
+ pass = test_glx_version() && pass;
+
+ return pass != true;
+}