Add an initial testsuite for GLX API.

macos/v1.5.9
Eric Anholt 11 years ago
parent ed938dc4c5
commit 04cf940e1b
  1. 1
      .gitignore
  2. 6
      Makefile.am
  3. 1
      configure.ac
  4. 42
      test/Makefile.am
  5. 104
      test/glx_common.c
  6. 31
      test/glx_common.h
  7. 103
      test/glx_public_api.c

1
.gitignore vendored

@ -80,6 +80,7 @@ core
# #
configure.lineno configure.lineno
.dirstamp .dirstamp
test-driver
gl_generated_dispatch.c gl_generated_dispatch.c
gl_generated.h gl_generated.h

@ -20,9 +20,9 @@
SUBDIRS = src SUBDIRS = src
#if HAVE_X11 if HAVE_X11
#SUBDIRS += test SUBDIRS += test
#endif endif
pkgconfigdir = $(libdir)/pkgconfig pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = epoxy.pc pkgconfig_DATA = epoxy.pc

@ -69,6 +69,7 @@ AC_CONFIG_FILES([
epoxy.pc epoxy.pc
Makefile Makefile
src/Makefile src/Makefile
test/Makefile
]) ])
AC_OUTPUT AC_OUTPUT

@ -0,0 +1,42 @@
# Copyright 2005 Adam Jackson.
#
# 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
# ADAM JACKSON 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.
EPOXY = $(builddir)/../src/libepoxy.la
check_LTLIBRARIES = libglx_common.la
libglx_common_la_SOURCES = \
glx_common.c \
glx_common.h
$()
AM_CPPFLAGS = \
-I$(top_srcdir)/include \
$(X11_CFLAGS)
TESTS = \
glx_public_api
$()
check_PROGRAMS = $(TESTS)
glx_public_api_LDFLAGS = $(X11_LIBS) $(EPOXY) libglx_common.la
glx_public_api_DEPENDENCIES = libglx_common.la

@ -0,0 +1,104 @@
/*
* 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 <stdlib.h>
#include <X11/Xlib.h>
#include "epoxy/glx.h"
Display *
get_display_or_skip(void)
{
Display *dpy = XOpenDisplay(NULL);
if (!dpy) {
fprintf(stderr, "couldn't open display\n");
exit(77);
}
return dpy;
}
static XVisualInfo *
get_glx_visual(Display *dpy)
{
XVisualInfo *visinfo;
int attrib[] = {
GLX_RGBA,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
GLX_DOUBLEBUFFER,
None
};
int screen = DefaultScreen(dpy);
visinfo = glXChooseVisual(dpy, screen, attrib);
if (visinfo == NULL) {
fprintf(stderr,
"Couldn't get an RGBA, double-buffered visual\n");
exit(1);
}
return visinfo;
}
static Window
get_glx_window(Display *dpy, XVisualInfo *visinfo, bool map)
{
XSetWindowAttributes window_attr;
unsigned long mask;
int screen = DefaultScreen(dpy);
Window root_win = RootWindow(dpy, screen);
Window win;
window_attr.background_pixel = 0;
window_attr.border_pixel = 0;
window_attr.colormap = XCreateColormap(dpy, root_win,
visinfo->visual, AllocNone);
window_attr.event_mask = StructureNotifyMask | ExposureMask |
KeyPressMask;
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
win = XCreateWindow(dpy, root_win, 0, 0,
10, 10, /* width, height */
0, visinfo->depth, InputOutput,
visinfo->visual, mask, &window_attr);
return win;
}
void
make_glx_context_current_or_skip(Display *dpy)
{
GLXContext ctx;
XVisualInfo *visinfo = get_glx_visual(dpy);
Window win = get_glx_window(dpy, visinfo, false);
ctx = glXCreateContext(dpy, visinfo, False, True);
if (ctx == None) {
fprintf(stderr, "glXCreateContext failed\n");
exit(1);
}
glXMakeCurrent(dpy, win, ctx);
}

@ -0,0 +1,31 @@
/*
* 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 "epoxy/glx.h"
Display *
get_display_or_skip(void);
GLXContext
make_glx_context_current_or_skip(Display *dpy);

@ -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;
}
Loading…
Cancel
Save