glx: delete tests
nobody needs these and they complicate glx interfaces by existing Reviewed-by: Adam Jackson <ajax@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30365>
This commit is contained in:

committed by
Marge Bot

parent
bb5145bcb8
commit
ed2ec808b1
@@ -145,7 +145,3 @@ libgl = shared_library(
|
||||
darwin_versions : '4.0.0',
|
||||
install : true,
|
||||
)
|
||||
|
||||
if with_tests
|
||||
subdir('tests')
|
||||
endif
|
||||
|
@@ -1,716 +0,0 @@
|
||||
/*
|
||||
* Copyright © 2011 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 <gtest/gtest.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "glxclient.h"
|
||||
|
||||
#include <xcb/glx.h>
|
||||
|
||||
#include "mock_xdisplay.h"
|
||||
#include "fake_glx_screen.h"
|
||||
|
||||
/**
|
||||
* \name Wrappers around some X structures to make the more usable for tests
|
||||
*/
|
||||
/*@{*/
|
||||
class fake_glx_screen;
|
||||
|
||||
class fake_glx_display : public glx_display {
|
||||
public:
|
||||
fake_glx_display(mock_XDisplay *dpy, int major, int minor)
|
||||
{
|
||||
this->next = 0;
|
||||
this->dpy = dpy;
|
||||
this->minorVersion = minor;
|
||||
this->glXDrawHash = 0;
|
||||
|
||||
this->screens = new glx_screen *[dpy->nscreens];
|
||||
memset(this->screens, 0, sizeof(struct glx_screen *) * dpy->nscreens);
|
||||
}
|
||||
|
||||
~fake_glx_display()
|
||||
{
|
||||
for (int i = 0; i < this->dpy->nscreens; i++) {
|
||||
if (this->screens[i] != NULL)
|
||||
delete (fake_glx_screen *)this->screens[i];
|
||||
}
|
||||
|
||||
delete [] this->screens;
|
||||
}
|
||||
|
||||
void init_screen(int i, const char *ext);
|
||||
};
|
||||
|
||||
class glX_send_client_info_test : public ::testing::Test {
|
||||
public:
|
||||
glX_send_client_info_test();
|
||||
virtual ~glX_send_client_info_test();
|
||||
virtual void SetUp();
|
||||
virtual void TearDown();
|
||||
|
||||
void common_protocol_expected_false_test(unsigned major, unsigned minor,
|
||||
const char *glx_ext, bool *value);
|
||||
|
||||
void common_protocol_expected_true_test(unsigned major, unsigned minor,
|
||||
const char *glx_ext, bool *value);
|
||||
|
||||
void create_single_screen_display(unsigned major, unsigned minor,
|
||||
const char *glx_ext);
|
||||
|
||||
void destroy_display();
|
||||
|
||||
protected:
|
||||
fake_glx_display *glx_dpy;
|
||||
mock_XDisplay *display;
|
||||
};
|
||||
|
||||
void
|
||||
fake_glx_display::init_screen(int i, const char *ext)
|
||||
{
|
||||
if (this->screens[i] != NULL)
|
||||
delete this->screens[i];
|
||||
|
||||
this->screens[i] = new fake_glx_screen(this, i, ext);
|
||||
}
|
||||
/*@}*/
|
||||
|
||||
static const char ext[] = "GL_XXX_dummy";
|
||||
|
||||
static bool ClientInfo_was_sent;
|
||||
static bool SetClientInfoARB_was_sent;
|
||||
static bool SetClientInfo2ARB_was_sent;
|
||||
static xcb_connection_t *connection_used;
|
||||
static int gl_ext_length;
|
||||
static char *gl_ext_string;
|
||||
static int glx_ext_length;
|
||||
static char *glx_ext_string;
|
||||
static int num_gl_versions;
|
||||
static uint32_t *gl_versions;
|
||||
static int glx_major;
|
||||
static int glx_minor;
|
||||
|
||||
extern "C" xcb_connection_t *
|
||||
XGetXCBConnection(Display *dpy)
|
||||
{
|
||||
return (xcb_connection_t *) 0xdeadbeef;
|
||||
}
|
||||
|
||||
extern "C" xcb_void_cookie_t
|
||||
xcb_glx_client_info(xcb_connection_t *c,
|
||||
uint32_t major_version,
|
||||
uint32_t minor_version,
|
||||
uint32_t str_len,
|
||||
const char *string)
|
||||
{
|
||||
xcb_void_cookie_t cookie;
|
||||
|
||||
ClientInfo_was_sent = true;
|
||||
connection_used = c;
|
||||
|
||||
gl_ext_string = new char[str_len];
|
||||
memcpy(gl_ext_string, string, str_len);
|
||||
gl_ext_length = str_len;
|
||||
|
||||
glx_major = major_version;
|
||||
glx_minor = minor_version;
|
||||
|
||||
cookie.sequence = 0;
|
||||
return cookie;
|
||||
}
|
||||
|
||||
extern "C" xcb_void_cookie_t
|
||||
xcb_glx_set_client_info_arb(xcb_connection_t *c,
|
||||
uint32_t major_version,
|
||||
uint32_t minor_version,
|
||||
uint32_t num_versions,
|
||||
uint32_t gl_str_len,
|
||||
uint32_t glx_str_len,
|
||||
const uint32_t *versions,
|
||||
const char *gl_string,
|
||||
const char *glx_string)
|
||||
{
|
||||
xcb_void_cookie_t cookie;
|
||||
|
||||
SetClientInfoARB_was_sent = true;
|
||||
connection_used = c;
|
||||
|
||||
gl_ext_string = new char[gl_str_len];
|
||||
memcpy(gl_ext_string, gl_string, gl_str_len);
|
||||
gl_ext_length = gl_str_len;
|
||||
|
||||
glx_ext_string = new char[glx_str_len];
|
||||
memcpy(glx_ext_string, glx_string, glx_str_len);
|
||||
glx_ext_length = glx_str_len;
|
||||
|
||||
gl_versions = new uint32_t[num_versions * 2];
|
||||
memcpy(gl_versions, versions, sizeof(uint32_t) * num_versions * 2);
|
||||
num_gl_versions = num_versions;
|
||||
|
||||
glx_major = major_version;
|
||||
glx_minor = minor_version;
|
||||
|
||||
cookie.sequence = 0;
|
||||
return cookie;
|
||||
}
|
||||
|
||||
extern "C" xcb_void_cookie_t
|
||||
xcb_glx_set_client_info_2arb(xcb_connection_t *c,
|
||||
uint32_t major_version,
|
||||
uint32_t minor_version,
|
||||
uint32_t num_versions,
|
||||
uint32_t gl_str_len,
|
||||
uint32_t glx_str_len,
|
||||
const uint32_t *versions,
|
||||
const char *gl_string,
|
||||
const char *glx_string)
|
||||
{
|
||||
xcb_void_cookie_t cookie;
|
||||
|
||||
SetClientInfo2ARB_was_sent = true;
|
||||
connection_used = c;
|
||||
|
||||
gl_ext_string = new char[gl_str_len];
|
||||
memcpy(gl_ext_string, gl_string, gl_str_len);
|
||||
gl_ext_length = gl_str_len;
|
||||
|
||||
glx_ext_string = new char[glx_str_len];
|
||||
memcpy(glx_ext_string, glx_string, glx_str_len);
|
||||
glx_ext_length = glx_str_len;
|
||||
|
||||
gl_versions = new uint32_t[num_versions * 3];
|
||||
memcpy(gl_versions, versions, sizeof(uint32_t) * num_versions * 3);
|
||||
num_gl_versions = num_versions;
|
||||
|
||||
glx_major = major_version;
|
||||
glx_minor = minor_version;
|
||||
|
||||
cookie.sequence = 0;
|
||||
return cookie;
|
||||
}
|
||||
|
||||
extern "C" char *
|
||||
__glXGetClientGLExtensionString(int screen)
|
||||
{
|
||||
char *str = (char *) malloc(sizeof(ext));
|
||||
|
||||
memcpy(str, ext, sizeof(ext));
|
||||
return str;
|
||||
}
|
||||
|
||||
glX_send_client_info_test::glX_send_client_info_test()
|
||||
: glx_dpy(0), display(0)
|
||||
{
|
||||
/* empty */
|
||||
}
|
||||
|
||||
glX_send_client_info_test::~glX_send_client_info_test()
|
||||
{
|
||||
if (glx_dpy)
|
||||
delete glx_dpy;
|
||||
|
||||
if (display)
|
||||
delete display;
|
||||
}
|
||||
|
||||
void
|
||||
glX_send_client_info_test::SetUp()
|
||||
{
|
||||
ClientInfo_was_sent = false;
|
||||
SetClientInfoARB_was_sent = false;
|
||||
SetClientInfo2ARB_was_sent = false;
|
||||
connection_used = (xcb_connection_t *) ~0;
|
||||
gl_ext_length = 0;
|
||||
gl_ext_string = (char *) 0;
|
||||
glx_ext_length = 0;
|
||||
glx_ext_string = (char *) 0;
|
||||
num_gl_versions = 0;
|
||||
gl_versions = (uint32_t *) 0;
|
||||
glx_major = 0;
|
||||
glx_minor = 0;
|
||||
}
|
||||
|
||||
void
|
||||
glX_send_client_info_test::TearDown()
|
||||
{
|
||||
if (gl_ext_string)
|
||||
delete [] gl_ext_string;
|
||||
if (glx_ext_string)
|
||||
delete [] glx_ext_string;
|
||||
if (gl_versions)
|
||||
delete [] gl_versions;
|
||||
}
|
||||
|
||||
void
|
||||
glX_send_client_info_test::create_single_screen_display(unsigned major,
|
||||
unsigned minor,
|
||||
const char *glx_ext)
|
||||
{
|
||||
this->display = new mock_XDisplay(1);
|
||||
|
||||
this->glx_dpy = new fake_glx_display(this->display, major, minor);
|
||||
this->glx_dpy->init_screen(0, glx_ext);
|
||||
}
|
||||
|
||||
void
|
||||
glX_send_client_info_test::common_protocol_expected_false_test(unsigned major,
|
||||
unsigned minor,
|
||||
const char *glx_ext,
|
||||
bool *value)
|
||||
{
|
||||
create_single_screen_display(major, minor, glx_ext);
|
||||
glxSendClientInfo(this->glx_dpy, -1);
|
||||
EXPECT_FALSE(*value);
|
||||
}
|
||||
|
||||
void
|
||||
glX_send_client_info_test::common_protocol_expected_true_test(unsigned major,
|
||||
unsigned minor,
|
||||
const char *glx_ext,
|
||||
bool *value)
|
||||
{
|
||||
create_single_screen_display(major, minor, glx_ext);
|
||||
glxSendClientInfo(this->glx_dpy, -1);
|
||||
EXPECT_TRUE(*value);
|
||||
}
|
||||
|
||||
TEST_F(glX_send_client_info_test, doesnt_send_SetClientInfoARB_for_1_3)
|
||||
{
|
||||
/* The glXSetClientInfoARB protocol was added in GLX 1.4 with the
|
||||
* GLX_ARB_create_context extension. Verify that no glXSetClientInfoARB is
|
||||
* sent to a GLX server that only has GLX 1.3 regardless of the extension
|
||||
* setting.
|
||||
*/
|
||||
common_protocol_expected_false_test(1, 3,
|
||||
"GLX_ARB_create_context",
|
||||
&SetClientInfoARB_was_sent);
|
||||
}
|
||||
|
||||
TEST_F(glX_send_client_info_test, doesnt_send_SetClientInfoARB_for_1_1)
|
||||
{
|
||||
/* The glXSetClientInfoARB protocol was added in GLX 1.4 with the
|
||||
* GLX_ARB_create_context extension. Verify that no glXSetClientInfoARB is
|
||||
* sent to a GLX server that only has GLX 1.3 regardless of the extension
|
||||
* setting.
|
||||
*/
|
||||
common_protocol_expected_false_test(1, 3,
|
||||
"GLX_ARB_create_context",
|
||||
&SetClientInfoARB_was_sent);
|
||||
}
|
||||
|
||||
TEST_F(glX_send_client_info_test, doesnt_send_SetClientInfoARB_for_1_4_with_empty_extensions)
|
||||
{
|
||||
/* The glXSetClientInfoARB protocol was added in GLX 1.4 with the
|
||||
* GLX_ARB_create_context extension. Verify that no glXSetClientInfoARB is
|
||||
* sent to a GLX server that has GLX 1.4 but has an empty extension string
|
||||
* (i.e., no extensions at all).
|
||||
*/
|
||||
common_protocol_expected_false_test(1, 4,
|
||||
"",
|
||||
&SetClientInfoARB_was_sent);
|
||||
}
|
||||
|
||||
TEST_F(glX_send_client_info_test, doesnt_send_SetClientInfoARB_for_1_4_without_extension)
|
||||
{
|
||||
/* The glXSetClientInfoARB protocol was added in GLX 1.4 with the
|
||||
* GLX_ARB_create_context extension. Verify that no glXSetClientInfoARB is
|
||||
* sent to a GLX server that has GLX 1.4 but doesn't have the extension.
|
||||
*/
|
||||
common_protocol_expected_false_test(1, 4,
|
||||
"GLX_EXT_texture_from_pixmap",
|
||||
&SetClientInfoARB_was_sent);
|
||||
}
|
||||
|
||||
TEST_F(glX_send_client_info_test, doesnt_send_SetClientInfoARB_for_1_4_with_wrong_extension)
|
||||
{
|
||||
/* The glXSetClientInfoARB protocol was added in GLX 1.4 with the
|
||||
* GLX_ARB_create_context extension. Verify that no glXSetClientInfoARB is
|
||||
* sent to a GLX server that has GLX 1.4 but does not have the extension.
|
||||
*
|
||||
* This test differs from
|
||||
* doesnt_send_SetClientInfoARB_for_1_4_without_extension in that an
|
||||
* extension exists that looks like the correct extension but isn't.
|
||||
*/
|
||||
common_protocol_expected_false_test(1, 4,
|
||||
"GLX_ARB_create_context2",
|
||||
&SetClientInfoARB_was_sent);
|
||||
}
|
||||
|
||||
TEST_F(glX_send_client_info_test, doesnt_send_SetClientInfoARB_for_1_4_with_profile_extension)
|
||||
{
|
||||
/* The glXSetClientInfoARB protocol was added in GLX 1.4 with the
|
||||
* GLX_ARB_create_context extension. Verify that no glXSetClientInfoARB is
|
||||
* sent to a GLX server that has GLX 1.4 but does not have the extension.
|
||||
*
|
||||
* This test differs from
|
||||
* doesnt_send_SetClientInfoARB_for_1_4_without_extension in that an
|
||||
* extension exists that looks like the correct extension but isn't.
|
||||
*/
|
||||
common_protocol_expected_false_test(1, 4,
|
||||
"GLX_ARB_create_context_profile",
|
||||
&SetClientInfoARB_was_sent);
|
||||
}
|
||||
|
||||
TEST_F(glX_send_client_info_test, doesnt_send_SetClientInfo2ARB_for_1_3)
|
||||
{
|
||||
/* The glXSetClientInfo2ARB protocol was added in GLX 1.4 with the
|
||||
* GLX_ARB_create_context_profile extension. Verify that no
|
||||
* glXSetClientInfo2ARB is sent to a GLX server that only has GLX 1.3
|
||||
* regardless of the extension setting.
|
||||
*/
|
||||
common_protocol_expected_false_test(1, 3,
|
||||
"GLX_ARB_create_context_profile",
|
||||
&SetClientInfo2ARB_was_sent);
|
||||
}
|
||||
|
||||
TEST_F(glX_send_client_info_test, doesnt_send_SetClientInfo2ARB_for_1_1)
|
||||
{
|
||||
/* The glXSetClientInfo2ARB protocol was added in GLX 1.4 with the
|
||||
* GLX_ARB_create_context_profile extension. Verify that no
|
||||
* glXSetClientInfo2ARB is sent to a GLX server that only has GLX 1.1
|
||||
* regardless of the extension setting.
|
||||
*/
|
||||
common_protocol_expected_false_test(1, 1,
|
||||
"GLX_ARB_create_context_profile",
|
||||
&SetClientInfo2ARB_was_sent);
|
||||
}
|
||||
|
||||
TEST_F(glX_send_client_info_test, doesnt_send_SetClientInfo2ARB_for_1_4_with_empty_extensions)
|
||||
{
|
||||
/* The glXSetClientInfo2ARB protocol was added in GLX 1.4 with the
|
||||
* GLX_ARB_create_context_profile extension. Verify that no
|
||||
* glXSetClientInfo2ARB is sent to a GLX server that has GLX 1.4 but has an
|
||||
* empty extension string (i.e., no extensions at all).
|
||||
*/
|
||||
common_protocol_expected_false_test(1, 4,
|
||||
"",
|
||||
&SetClientInfo2ARB_was_sent);
|
||||
}
|
||||
|
||||
TEST_F(glX_send_client_info_test, doesnt_send_SetClientInfo2ARB_for_1_4_without_extension)
|
||||
{
|
||||
/* The glXSetClientInfo2ARB protocol was added in GLX 1.4 with the
|
||||
* GLX_ARB_create_context_profile extension. Verify that no
|
||||
* glXSetClientInfo2ARB is sent to a GLX server that has GLX 1.4 but
|
||||
* doesn't have the extension.
|
||||
*/
|
||||
common_protocol_expected_false_test(1, 4,
|
||||
"GLX_EXT_texture_from_pixmap",
|
||||
&SetClientInfo2ARB_was_sent);
|
||||
}
|
||||
|
||||
TEST_F(glX_send_client_info_test, doesnt_send_SetClientInfo2ARB_for_1_4_with_wrong_extension)
|
||||
{
|
||||
/* The glXSetClientInfo2ARB protocol was added in GLX 1.4 with the
|
||||
* GLX_ARB_create_context_profile extension. Verify that no
|
||||
* glXSetClientInfo2ARB is sent to a GLX server that has GLX 1.4 but does
|
||||
* not have the extension.
|
||||
*
|
||||
* This test differs from
|
||||
* doesnt_send_SetClientInfo2ARB_for_1_4_without_extension in that an
|
||||
* extension exists that looks like the correct extension but isn't.
|
||||
*/
|
||||
common_protocol_expected_false_test(1, 4,
|
||||
"GLX_ARB_create_context_profile2",
|
||||
&SetClientInfo2ARB_was_sent);
|
||||
}
|
||||
|
||||
TEST_F(glX_send_client_info_test, does_send_ClientInfo_for_1_1)
|
||||
{
|
||||
/* The glXClientInfo protocol was added in GLX 1.1. Verify that
|
||||
* glXClientInfo is sent to a GLX server that has GLX 1.1.
|
||||
*/
|
||||
common_protocol_expected_true_test(1, 1,
|
||||
"",
|
||||
&ClientInfo_was_sent);
|
||||
}
|
||||
|
||||
TEST_F(glX_send_client_info_test, does_send_SetClientInfoARB_for_1_4_with_extension)
|
||||
{
|
||||
/* The glXSetClientInfoARB protocol was added in GLX 1.4 with the
|
||||
* GLX_ARB_create_context extension. Verify that glXSetClientInfoARB is
|
||||
* sent to a GLX server that has GLX 1.4 and the extension.
|
||||
*/
|
||||
common_protocol_expected_true_test(1, 4,
|
||||
"GLX_ARB_create_context",
|
||||
&SetClientInfoARB_was_sent);
|
||||
}
|
||||
|
||||
TEST_F(glX_send_client_info_test, does_send_SetClientInfo2ARB_for_1_4_with_just_profile_extension)
|
||||
{
|
||||
/* The glXSetClientInfoARB protocol was added in GLX 1.4 with the
|
||||
* GLX_ARB_create_context extension. Verify that glXSetClientInfoARB is
|
||||
* sent to a GLX server that has GLX 1.4 and the extension.
|
||||
*/
|
||||
common_protocol_expected_true_test(1, 4,
|
||||
"GLX_ARB_create_context_profile",
|
||||
&SetClientInfo2ARB_was_sent);
|
||||
}
|
||||
|
||||
TEST_F(glX_send_client_info_test, does_send_SetClientInfo2ARB_for_1_4_with_both_extensions)
|
||||
{
|
||||
/* The glXSetClientInfoARB protocol was added in GLX 1.4 with the
|
||||
* GLX_ARB_create_context extension. Verify that glXSetClientInfoARB is
|
||||
* sent to a GLX server that has GLX 1.4 and the extension.
|
||||
*/
|
||||
common_protocol_expected_true_test(1, 4,
|
||||
"GLX_ARB_create_context "
|
||||
"GLX_ARB_create_context_profile",
|
||||
&SetClientInfo2ARB_was_sent);
|
||||
}
|
||||
|
||||
TEST_F(glX_send_client_info_test, does_send_SetClientInfo2ARB_for_1_4_with_both_extensions_reversed)
|
||||
{
|
||||
/* The glXSetClientInfoARB protocol was added in GLX 1.4 with the
|
||||
* GLX_ARB_create_context extension. Verify that glXSetClientInfoARB is
|
||||
* sent to a GLX server that has GLX 1.4 and the extension.
|
||||
*/
|
||||
common_protocol_expected_true_test(1, 4,
|
||||
"GLX_ARB_create_context_profile "
|
||||
"GLX_ARB_create_context",
|
||||
&SetClientInfo2ARB_was_sent);
|
||||
}
|
||||
|
||||
TEST_F(glX_send_client_info_test, uses_correct_connection)
|
||||
{
|
||||
create_single_screen_display(1, 1, "");
|
||||
glxSendClientInfo(this->glx_dpy, -1);
|
||||
EXPECT_EQ((xcb_connection_t *) 0xdeadbeef, connection_used);
|
||||
}
|
||||
|
||||
TEST_F(glX_send_client_info_test, sends_correct_gl_extension_string)
|
||||
{
|
||||
create_single_screen_display(1, 1, "");
|
||||
glxSendClientInfo(this->glx_dpy, -1);
|
||||
|
||||
ASSERT_EQ((int) sizeof(ext), gl_ext_length);
|
||||
ASSERT_NE((char *) 0, gl_ext_string);
|
||||
EXPECT_EQ(0, memcmp(gl_ext_string, ext, sizeof(ext)));
|
||||
}
|
||||
|
||||
TEST_F(glX_send_client_info_test, gl_versions_are_sane)
|
||||
{
|
||||
create_single_screen_display(1, 4, "GLX_ARB_create_context");
|
||||
glxSendClientInfo(this->glx_dpy, -1);
|
||||
|
||||
ASSERT_NE(0, num_gl_versions);
|
||||
|
||||
unsigned versions_below_3_0 = 0;
|
||||
for (int i = 0; i < num_gl_versions; i++) {
|
||||
EXPECT_LT(0u, gl_versions[i * 2]);
|
||||
EXPECT_GE(4u, gl_versions[i * 2]);
|
||||
|
||||
/* Verify that the minor version advertised with the major version makes
|
||||
* sense.
|
||||
*/
|
||||
switch (gl_versions[i * 2]) {
|
||||
case 1:
|
||||
EXPECT_GE(5u, gl_versions[i * 2 + 1]);
|
||||
versions_below_3_0++;
|
||||
break;
|
||||
case 2:
|
||||
EXPECT_GE(1u, gl_versions[i * 2 + 1]);
|
||||
versions_below_3_0++;
|
||||
break;
|
||||
case 3:
|
||||
EXPECT_GE(3u, gl_versions[i * 2 + 1]);
|
||||
break;
|
||||
case 4:
|
||||
EXPECT_GE(2u, gl_versions[i * 2 + 1]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* From the GLX_ARB_create_context spec:
|
||||
*
|
||||
* "Only the highest supported version below 3.0 should be sent, since
|
||||
* OpenGL 2.1 is backwards compatible with all earlier versions."
|
||||
*/
|
||||
EXPECT_LE(versions_below_3_0, 1u);
|
||||
}
|
||||
|
||||
TEST_F(glX_send_client_info_test, gl_versions_and_profiles_are_sane)
|
||||
{
|
||||
create_single_screen_display(1, 4, "GLX_ARB_create_context_profile");
|
||||
glxSendClientInfo(this->glx_dpy, -1);
|
||||
|
||||
ASSERT_NE(0, num_gl_versions);
|
||||
|
||||
const uint32_t all_valid_bits = GLX_CONTEXT_CORE_PROFILE_BIT_ARB
|
||||
| GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
|
||||
const uint32_t es_bit = GLX_CONTEXT_ES2_PROFILE_BIT_EXT;
|
||||
|
||||
unsigned versions_below_3_0 = 0;
|
||||
|
||||
for (int i = 0; i < num_gl_versions; i++) {
|
||||
EXPECT_LT(0u, gl_versions[i * 3]);
|
||||
EXPECT_GE(4u, gl_versions[i * 3]);
|
||||
|
||||
/* Verify that the minor version advertised with the major version makes
|
||||
* sense.
|
||||
*/
|
||||
switch (gl_versions[i * 3]) {
|
||||
case 1:
|
||||
if (gl_versions[i * 3 + 2] & es_bit) {
|
||||
EXPECT_GE(1u, gl_versions[i * 3 + 1]);
|
||||
EXPECT_EQ(es_bit, gl_versions[i * 3 + 2]);
|
||||
} else {
|
||||
EXPECT_GE(5u, gl_versions[i * 3 + 1]);
|
||||
EXPECT_EQ(0u, gl_versions[i * 3 + 2]);
|
||||
versions_below_3_0++;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (gl_versions[i * 3 + 2] & es_bit) {
|
||||
EXPECT_EQ(0u, gl_versions[i * 3 + 1]);
|
||||
EXPECT_EQ(es_bit, gl_versions[i * 3 + 2]);
|
||||
} else {
|
||||
EXPECT_GE(1u, gl_versions[i * 3 + 1]);
|
||||
EXPECT_EQ(0u, gl_versions[i * 3 + 2]);
|
||||
versions_below_3_0++;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
EXPECT_GE(3u, gl_versions[i * 3 + 1]);
|
||||
|
||||
/* Profiles were not introduced until OpenGL 3.2.
|
||||
*/
|
||||
if (gl_versions[i * 3 + 1] < 2) {
|
||||
EXPECT_EQ(0u, gl_versions[i * 3 + 2] & ~(es_bit));
|
||||
} else if (gl_versions[i * 3 + 1] == 2) {
|
||||
EXPECT_EQ(0u, gl_versions[i * 3 + 2] & ~(all_valid_bits | es_bit));
|
||||
} else {
|
||||
EXPECT_EQ(0u, gl_versions[i * 3 + 2] & ~(all_valid_bits));
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
EXPECT_GE(6u, gl_versions[i * 3 + 1]);
|
||||
EXPECT_EQ(0u, gl_versions[i * 3 + 2] & ~(all_valid_bits));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* From the GLX_ARB_create_context_profile spec:
|
||||
*
|
||||
* "Only the highest supported version below 3.0 should be sent, since
|
||||
* OpenGL 2.1 is backwards compatible with all earlier versions."
|
||||
*/
|
||||
EXPECT_LE(versions_below_3_0, 1u);
|
||||
}
|
||||
|
||||
TEST_F(glX_send_client_info_test, glx_version_is_1_4_for_1_1)
|
||||
{
|
||||
create_single_screen_display(1, 1, "");
|
||||
glxSendClientInfo(this->glx_dpy, -1);
|
||||
|
||||
EXPECT_EQ(1, glx_major);
|
||||
EXPECT_EQ(4, glx_minor);
|
||||
}
|
||||
|
||||
TEST_F(glX_send_client_info_test, glx_version_is_1_4_for_1_4)
|
||||
{
|
||||
create_single_screen_display(1, 4, "");
|
||||
glxSendClientInfo(this->glx_dpy, -1);
|
||||
|
||||
EXPECT_EQ(1, glx_major);
|
||||
EXPECT_EQ(4, glx_minor);
|
||||
}
|
||||
|
||||
TEST_F(glX_send_client_info_test, glx_version_is_1_4_for_1_4_with_ARB_create_context)
|
||||
{
|
||||
create_single_screen_display(1, 4, "GLX_ARB_create_context");
|
||||
glxSendClientInfo(this->glx_dpy, -1);
|
||||
|
||||
EXPECT_EQ(1, glx_major);
|
||||
EXPECT_EQ(4, glx_minor);
|
||||
}
|
||||
|
||||
TEST_F(glX_send_client_info_test, glx_version_is_1_4_for_1_4_with_ARB_create_context_profile)
|
||||
{
|
||||
create_single_screen_display(1, 4, "GLX_ARB_create_context_profile");
|
||||
glxSendClientInfo(this->glx_dpy, -1);
|
||||
|
||||
EXPECT_EQ(1, glx_major);
|
||||
EXPECT_EQ(4, glx_minor);
|
||||
}
|
||||
|
||||
TEST_F(glX_send_client_info_test, glx_version_is_1_4_for_1_5)
|
||||
{
|
||||
create_single_screen_display(1, 5, "");
|
||||
glxSendClientInfo(this->glx_dpy, -1);
|
||||
|
||||
EXPECT_EQ(1, glx_major);
|
||||
EXPECT_EQ(4, glx_minor);
|
||||
}
|
||||
|
||||
TEST_F(glX_send_client_info_test, glx_extensions_has_GLX_ARB_create_context)
|
||||
{
|
||||
create_single_screen_display(1, 4, "GLX_ARB_create_context");
|
||||
glxSendClientInfo(this->glx_dpy, -1);
|
||||
|
||||
ASSERT_NE(0, glx_ext_length);
|
||||
ASSERT_NE((char *) 0, glx_ext_string);
|
||||
|
||||
bool found_GLX_ARB_create_context = false;
|
||||
const char *const needle = "GLX_ARB_create_context";
|
||||
const unsigned len = strlen(needle);
|
||||
char *haystack = glx_ext_string;
|
||||
while (haystack != NULL) {
|
||||
char *match = strstr(haystack, needle);
|
||||
|
||||
if (match[len] == '\0' || match[len] == ' ') {
|
||||
found_GLX_ARB_create_context = true;
|
||||
break;
|
||||
}
|
||||
|
||||
haystack = match + len;
|
||||
}
|
||||
|
||||
EXPECT_TRUE(found_GLX_ARB_create_context);
|
||||
}
|
||||
|
||||
TEST_F(glX_send_client_info_test, glx_extensions_has_GLX_ARB_create_context_profile)
|
||||
{
|
||||
create_single_screen_display(1, 4, "GLX_ARB_create_context_profile");
|
||||
glxSendClientInfo(this->glx_dpy, -1);
|
||||
|
||||
ASSERT_NE(0, glx_ext_length);
|
||||
ASSERT_NE((char *) 0, glx_ext_string);
|
||||
|
||||
bool found_GLX_ARB_create_context_profile = false;
|
||||
const char *const needle = "GLX_ARB_create_context_profile";
|
||||
const unsigned len = strlen(needle);
|
||||
char *haystack = glx_ext_string;
|
||||
while (haystack != NULL) {
|
||||
char *match = strstr(haystack, needle);
|
||||
|
||||
if (match[len] == '\0' || match[len] == ' ') {
|
||||
found_GLX_ARB_create_context_profile = true;
|
||||
break;
|
||||
}
|
||||
|
||||
haystack = match + len;
|
||||
}
|
||||
|
||||
EXPECT_TRUE(found_GLX_ARB_create_context_profile);
|
||||
}
|
@@ -1,523 +0,0 @@
|
||||
/*
|
||||
* Copyright © 2011 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 <gtest/gtest.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "glxclient.h"
|
||||
#include "glx_error.h"
|
||||
|
||||
#include <xcb/glx.h>
|
||||
#include "mock_xdisplay.h"
|
||||
#include "fake_glx_screen.h"
|
||||
|
||||
static bool CreateContextAttribsARB_was_sent;
|
||||
static xcb_glx_create_context_attribs_arb_request_t req;
|
||||
static uint32_t sent_attribs[1024];
|
||||
static uint32_t next_id;
|
||||
|
||||
|
||||
struct glx_screen *psc;
|
||||
|
||||
extern "C" Bool
|
||||
glx_context_init(struct glx_context *gc,
|
||||
struct glx_screen *psc, struct glx_config *config)
|
||||
{
|
||||
gc->majorOpcode = 123;
|
||||
gc->psc = psc;
|
||||
gc->config = config;
|
||||
gc->isDirect = GL_TRUE;
|
||||
gc->currentContextTag = -1;
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
bool GetGLXScreenConfigs_called = false;
|
||||
|
||||
extern "C" struct glx_screen *
|
||||
GetGLXScreenConfigs(Display * dpy, int scrn)
|
||||
{
|
||||
(void) dpy;
|
||||
(void) scrn;
|
||||
|
||||
GetGLXScreenConfigs_called = true;
|
||||
return psc;
|
||||
}
|
||||
|
||||
extern "C" uint32_t
|
||||
xcb_generate_id(xcb_connection_t *c)
|
||||
{
|
||||
(void) c;
|
||||
|
||||
return next_id++;
|
||||
}
|
||||
|
||||
extern "C" xcb_void_cookie_t
|
||||
xcb_glx_create_context_attribs_arb_checked(xcb_connection_t *c,
|
||||
xcb_glx_context_t context,
|
||||
uint32_t fbconfig,
|
||||
uint32_t screen,
|
||||
uint32_t share_list,
|
||||
uint8_t is_direct,
|
||||
uint32_t num_attribs,
|
||||
const uint32_t *attribs)
|
||||
{
|
||||
(void) c;
|
||||
|
||||
CreateContextAttribsARB_was_sent = true;
|
||||
req.context = context;
|
||||
req.fbconfig = fbconfig;
|
||||
req.screen = screen;
|
||||
req.share_list = share_list;
|
||||
req.is_direct = is_direct;
|
||||
req.num_attribs = num_attribs;
|
||||
|
||||
if (num_attribs != 0 && attribs != NULL)
|
||||
memcpy(sent_attribs, attribs, num_attribs * 2 * sizeof(uint32_t));
|
||||
|
||||
xcb_void_cookie_t cookie;
|
||||
cookie.sequence = 0xbadc0de;
|
||||
|
||||
return cookie;
|
||||
}
|
||||
|
||||
extern "C" xcb_void_cookie_t
|
||||
xcb_glx_destroy_context(xcb_connection_t *c, xcb_glx_context_t context)
|
||||
{
|
||||
xcb_void_cookie_t cookie;
|
||||
cookie.sequence = 0xbadc0de;
|
||||
|
||||
return cookie;
|
||||
}
|
||||
|
||||
extern "C" xcb_generic_error_t *
|
||||
xcb_request_check(xcb_connection_t *c, xcb_void_cookie_t cookie)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
extern "C" void
|
||||
__glXSendErrorForXcb(Display * dpy, const xcb_generic_error_t *err)
|
||||
{
|
||||
}
|
||||
|
||||
extern "C" void
|
||||
__glXSendError(Display * dpy, int_fast8_t errorCode, uint_fast32_t resourceID,
|
||||
uint_fast16_t minorCode, bool coreX11error)
|
||||
{
|
||||
}
|
||||
|
||||
class glXCreateContextAttribARB_test : public ::testing::Test {
|
||||
public:
|
||||
virtual void SetUp();
|
||||
virtual void TearDown();
|
||||
|
||||
/**
|
||||
* Replace the existing screen with a direct-rendering screen
|
||||
*/
|
||||
void use_direct_rendering_screen();
|
||||
|
||||
mock_XDisplay *dpy;
|
||||
GLXContext ctx;
|
||||
struct glx_config fbc;
|
||||
};
|
||||
|
||||
void
|
||||
glXCreateContextAttribARB_test::SetUp()
|
||||
{
|
||||
CreateContextAttribsARB_was_sent = false;
|
||||
memset(&req, 0, sizeof(req));
|
||||
next_id = 99;
|
||||
fake_glx_context::contexts_allocated = 0;
|
||||
psc = new fake_glx_screen(NULL, 0, "");
|
||||
|
||||
this->dpy = new mock_XDisplay(1);
|
||||
|
||||
memset(&this->fbc, 0, sizeof(this->fbc));
|
||||
this->fbc.fbconfigID = 0xbeefcafe;
|
||||
|
||||
this->ctx = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
glXCreateContextAttribARB_test::TearDown()
|
||||
{
|
||||
if (ctx)
|
||||
delete (fake_glx_context *)ctx;
|
||||
|
||||
delete (fake_glx_screen *)psc;
|
||||
|
||||
delete this->dpy;
|
||||
}
|
||||
|
||||
void
|
||||
glXCreateContextAttribARB_test::use_direct_rendering_screen()
|
||||
{
|
||||
struct glx_screen *direct_psc =
|
||||
new fake_glx_screen_direct(psc->display,
|
||||
psc->scr,
|
||||
psc->serverGLXexts);
|
||||
|
||||
delete (fake_glx_screen *)psc;
|
||||
psc = direct_psc;
|
||||
}
|
||||
|
||||
/**
|
||||
* \name Verify detection of client-side errors
|
||||
*/
|
||||
/*@{*/
|
||||
TEST_F(glXCreateContextAttribARB_test, NULL_display_returns_None)
|
||||
{
|
||||
GLXContext ctx =
|
||||
glXCreateContextAttribsARB(NULL, (GLXFBConfig) &this->fbc, 0,
|
||||
False, NULL);
|
||||
|
||||
EXPECT_EQ(None, ctx);
|
||||
EXPECT_EQ(0, fake_glx_context::contexts_allocated);
|
||||
}
|
||||
|
||||
TEST_F(glXCreateContextAttribARB_test, NULL_screen_returns_None)
|
||||
{
|
||||
delete (fake_glx_screen *)psc;
|
||||
psc = NULL;
|
||||
|
||||
GLXContext ctx =
|
||||
glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
|
||||
False, NULL);
|
||||
|
||||
EXPECT_EQ(None, ctx);
|
||||
EXPECT_EQ(0, fake_glx_context::contexts_allocated);
|
||||
}
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* \name Verify that correct protocol bits are sent to the server.
|
||||
*/
|
||||
/*@{*/
|
||||
TEST_F(glXCreateContextAttribARB_test, does_send_protocol)
|
||||
{
|
||||
ctx = glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
|
||||
False, NULL);
|
||||
|
||||
EXPECT_TRUE(CreateContextAttribsARB_was_sent);
|
||||
}
|
||||
|
||||
TEST_F(glXCreateContextAttribARB_test, sent_correct_context)
|
||||
{
|
||||
ctx = glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
|
||||
False, NULL);
|
||||
EXPECT_EQ(99u, req.context);
|
||||
}
|
||||
|
||||
TEST_F(glXCreateContextAttribARB_test, sent_correct_fbconfig)
|
||||
{
|
||||
ctx = glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
|
||||
False, NULL);
|
||||
|
||||
EXPECT_EQ(0xbeefcafe, req.fbconfig);
|
||||
}
|
||||
|
||||
TEST_F(glXCreateContextAttribARB_test, sent_correct_share_list)
|
||||
{
|
||||
GLXContext share =
|
||||
glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
|
||||
False, NULL);
|
||||
|
||||
ASSERT_NE((GLXContext) 0, share);
|
||||
|
||||
ctx = glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, share,
|
||||
False, NULL);
|
||||
|
||||
struct glx_context *glx_ctx = (struct glx_context *) share;
|
||||
EXPECT_EQ(glx_ctx->xid, req.share_list);
|
||||
|
||||
delete (fake_glx_context *)share;
|
||||
}
|
||||
|
||||
TEST_F(glXCreateContextAttribARB_test, sent_correct_is_direct_for_indirect_screen_and_direct_set_to_true)
|
||||
{
|
||||
ctx = glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
|
||||
True, NULL);
|
||||
|
||||
EXPECT_FALSE(req.is_direct);
|
||||
}
|
||||
|
||||
TEST_F(glXCreateContextAttribARB_test, sent_correct_is_direct_for_indirect_screen_and_direct_set_to_false)
|
||||
{
|
||||
ctx = glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
|
||||
False, NULL);
|
||||
|
||||
EXPECT_FALSE(req.is_direct);
|
||||
}
|
||||
|
||||
TEST_F(glXCreateContextAttribARB_test, sent_correct_is_direct_for_direct_screen_and_direct_set_to_true)
|
||||
{
|
||||
this->use_direct_rendering_screen();
|
||||
|
||||
ctx = glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
|
||||
True, NULL);
|
||||
|
||||
EXPECT_TRUE(req.is_direct);
|
||||
}
|
||||
|
||||
TEST_F(glXCreateContextAttribARB_test, sent_correct_is_direct_for_direct_screen_and_direct_set_to_false)
|
||||
{
|
||||
this->use_direct_rendering_screen();
|
||||
|
||||
ctx = glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
|
||||
False, NULL);
|
||||
|
||||
EXPECT_FALSE(req.is_direct);
|
||||
}
|
||||
|
||||
TEST_F(glXCreateContextAttribARB_test, sent_correct_screen)
|
||||
{
|
||||
this->fbc.screen = 7;
|
||||
psc->scr = 7;
|
||||
|
||||
ctx = glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
|
||||
False, NULL);
|
||||
|
||||
EXPECT_EQ(7u, req.screen);
|
||||
}
|
||||
|
||||
TEST_F(glXCreateContextAttribARB_test, sent_correct_num_attribs)
|
||||
{
|
||||
/* Use zeros in the second half of each attribute pair to try and trick the
|
||||
* implementation into termiating the list early.
|
||||
*
|
||||
* Use non-zero in the second half of the last attribute pair to try and
|
||||
* trick the implementation into not terminating the list early enough.
|
||||
*/
|
||||
static const int attribs[] = {
|
||||
1, 0,
|
||||
2, 0,
|
||||
3, 0,
|
||||
4, 0,
|
||||
0, 6,
|
||||
0, 0
|
||||
};
|
||||
|
||||
ctx = glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
|
||||
False, attribs);
|
||||
|
||||
EXPECT_EQ(4u, req.num_attribs);
|
||||
}
|
||||
|
||||
TEST_F(glXCreateContextAttribARB_test, sent_correct_num_attribs_empty_list)
|
||||
{
|
||||
static const int attribs[] = {
|
||||
0,
|
||||
};
|
||||
|
||||
ctx = glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
|
||||
False, attribs);
|
||||
|
||||
EXPECT_EQ(0u, req.num_attribs);
|
||||
}
|
||||
|
||||
TEST_F(glXCreateContextAttribARB_test, sent_correct_num_attribs_NULL_list_pointer)
|
||||
{
|
||||
ctx = glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
|
||||
False, NULL);
|
||||
|
||||
EXPECT_EQ(0u, req.num_attribs);
|
||||
}
|
||||
|
||||
TEST_F(glXCreateContextAttribARB_test, sent_correct_attrib_list)
|
||||
{
|
||||
int attribs[] = {
|
||||
GLX_RENDER_TYPE, GLX_RGBA_TYPE,
|
||||
GLX_CONTEXT_MAJOR_VERSION_ARB, 1,
|
||||
GLX_CONTEXT_MINOR_VERSION_ARB, 2,
|
||||
0
|
||||
};
|
||||
|
||||
ctx = glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
|
||||
False, attribs);
|
||||
|
||||
for (unsigned i = 0; i < 6; i++) {
|
||||
EXPECT_EQ((uint32_t) attribs[i], sent_attribs[i]);
|
||||
}
|
||||
}
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* \name Verify details of the returned GLXContext
|
||||
*/
|
||||
/*@{*/
|
||||
TEST_F(glXCreateContextAttribARB_test, correct_context)
|
||||
{
|
||||
ctx = glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
|
||||
False, NULL);
|
||||
|
||||
/* Since the server did not return an error, the GLXContext should not be
|
||||
* NULL.
|
||||
*/
|
||||
EXPECT_NE((GLXContext)0, ctx);
|
||||
|
||||
/* It shouldn't be the XID of the context either.
|
||||
*/
|
||||
EXPECT_NE((GLXContext)99, ctx);
|
||||
}
|
||||
|
||||
TEST_F(glXCreateContextAttribARB_test, correct_context_xid)
|
||||
{
|
||||
ctx = glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
|
||||
False, NULL);
|
||||
|
||||
/* Since the server did not return an error, the GLXContext should not be
|
||||
* NULL.
|
||||
*/
|
||||
ASSERT_NE((GLXContext)0, ctx);
|
||||
|
||||
struct glx_context *glx_ctx = (struct glx_context *) ctx;
|
||||
EXPECT_EQ(99u, glx_ctx->xid);
|
||||
}
|
||||
|
||||
TEST_F(glXCreateContextAttribARB_test, correct_context_share_xid)
|
||||
{
|
||||
GLXContext first =
|
||||
glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
|
||||
False, NULL);
|
||||
|
||||
ASSERT_NE((GLXContext) 0, first);
|
||||
|
||||
GLXContext second =
|
||||
glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, first,
|
||||
False, NULL);
|
||||
|
||||
ASSERT_NE((GLXContext) 0, second);
|
||||
|
||||
struct glx_context *share = (struct glx_context *) first;
|
||||
struct glx_context *ctx = (struct glx_context *) second;
|
||||
EXPECT_EQ(share->xid, ctx->share_xid);
|
||||
|
||||
delete (fake_glx_context *)first;
|
||||
delete (fake_glx_context *)second;
|
||||
}
|
||||
|
||||
TEST_F(glXCreateContextAttribARB_test, correct_context_isDirect_for_indirect_screen_and_direct_set_to_true)
|
||||
{
|
||||
ctx = glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
|
||||
True, NULL);
|
||||
|
||||
ASSERT_NE((GLXContext) 0, ctx);
|
||||
|
||||
struct glx_context *gc = (struct glx_context *) ctx;
|
||||
|
||||
EXPECT_FALSE(gc->isDirect);
|
||||
}
|
||||
|
||||
TEST_F(glXCreateContextAttribARB_test, correct_context_isDirect_for_indirect_screen_and_direct_set_to_false)
|
||||
{
|
||||
ctx = glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
|
||||
False, NULL);
|
||||
|
||||
ASSERT_NE((GLXContext) 0, ctx);
|
||||
|
||||
struct glx_context *gc = (struct glx_context *) ctx;
|
||||
|
||||
EXPECT_FALSE(gc->isDirect);
|
||||
}
|
||||
|
||||
TEST_F(glXCreateContextAttribARB_test, correct_context_isDirect_for_direct_screen_and_direct_set_to_true)
|
||||
{
|
||||
this->use_direct_rendering_screen();
|
||||
|
||||
ctx = glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
|
||||
True, NULL);
|
||||
|
||||
ASSERT_NE((GLXContext) 0, ctx);
|
||||
|
||||
struct glx_context *gc = (struct glx_context *) ctx;
|
||||
|
||||
EXPECT_TRUE(gc->isDirect);
|
||||
}
|
||||
|
||||
TEST_F(glXCreateContextAttribARB_test, correct_context_isDirect_for_direct_screen_and_direct_set_to_false)
|
||||
{
|
||||
this->use_direct_rendering_screen();
|
||||
|
||||
ctx = glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
|
||||
False, NULL);
|
||||
|
||||
ASSERT_NE((GLXContext) 0, ctx);
|
||||
|
||||
struct glx_context *gc = (struct glx_context *) ctx;
|
||||
|
||||
EXPECT_FALSE(gc->isDirect);
|
||||
}
|
||||
|
||||
TEST_F(glXCreateContextAttribARB_test, correct_indirect_context_client_state_private)
|
||||
{
|
||||
ctx = glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
|
||||
False, NULL);
|
||||
|
||||
ASSERT_NE((GLXContext) 0, ctx);
|
||||
|
||||
struct glx_context *gc = (struct glx_context *) ctx;
|
||||
|
||||
ASSERT_FALSE(gc->isDirect);
|
||||
EXPECT_EQ((struct __GLXattributeRec *) 0xcafebabe,
|
||||
gc->client_state_private);
|
||||
}
|
||||
|
||||
TEST_F(glXCreateContextAttribARB_test, correct_indirect_context_config)
|
||||
{
|
||||
ctx = glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
|
||||
False, NULL);
|
||||
|
||||
ASSERT_NE((GLXContext) 0, ctx);
|
||||
|
||||
struct glx_context *gc = (struct glx_context *) ctx;
|
||||
|
||||
EXPECT_EQ(&this->fbc, gc->config);
|
||||
}
|
||||
|
||||
TEST_F(glXCreateContextAttribARB_test, correct_context_screen_number)
|
||||
{
|
||||
this->fbc.screen = 7;
|
||||
psc->scr = 7;
|
||||
|
||||
ctx = glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
|
||||
False, NULL);
|
||||
|
||||
ASSERT_NE((GLXContext) 0, ctx);
|
||||
|
||||
struct glx_context *gc = (struct glx_context *) ctx;
|
||||
|
||||
EXPECT_EQ(7, gc->psc->scr);
|
||||
}
|
||||
|
||||
TEST_F(glXCreateContextAttribARB_test, correct_context_screen_pointer)
|
||||
{
|
||||
ctx = glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
|
||||
False, NULL);
|
||||
|
||||
ASSERT_NE((GLXContext) 0, ctx);
|
||||
|
||||
struct glx_context *gc = (struct glx_context *) ctx;
|
||||
|
||||
EXPECT_EQ(psc, gc->psc);
|
||||
}
|
||||
/*@}*/
|
@@ -1,30 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
if [ -z "$srcdir" ]
|
||||
then
|
||||
srcdir=$(dirname "$0")
|
||||
fi
|
||||
|
||||
# extract enum definition
|
||||
dispatch_list=$(sed '/__GLXdispatchIndex/,/__GLXdispatchIndex/!d' \
|
||||
"$srcdir"/../g_glxglvnddispatchindices.h)
|
||||
|
||||
# extract values inside of enum
|
||||
dispatch_list=$(sed '1d;$d' <<< "$dispatch_list")
|
||||
|
||||
# remove indentation
|
||||
dispatch_list=$(sed 's/^\s\+//' <<< "$dispatch_list")
|
||||
|
||||
# extract function names
|
||||
dispatch_list=$(sed 's/DI_//;s/,//' <<< "$dispatch_list")
|
||||
|
||||
# same for commented functions, we want to keep them sorted too
|
||||
dispatch_list=$(sed 's#// ##;s/ implemented by [a-z]\+//' <<< "$dispatch_list")
|
||||
|
||||
# remove LAST_INDEX, as it will not be in alphabetical order
|
||||
dispatch_list=$(sed '/LAST_INDEX/d' <<< "$dispatch_list")
|
||||
|
||||
sorted=$(LC_ALL=C sort <<< "$dispatch_list")
|
||||
|
||||
test "$dispatch_list" = "$sorted"
|
@@ -1,556 +0,0 @@
|
||||
/*
|
||||
* Copyright © 2012 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 enum_sizes.cpp
|
||||
* Validate the generated code in indirect_size.c
|
||||
*
|
||||
* The functions in indirect_size.c determine how many data values are
|
||||
* associated with each enumerant that can be passed to various OpenGL
|
||||
* functions. Tests in this file probe each function in indirect_size.c with
|
||||
* each of the possible valid enums and verify that the correct size is
|
||||
* returned. Tests in this file also probe each function in indirect_size.c
|
||||
* with a larger number of \b invalid enums and verify that zero is returned.
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <GL/gl.h>
|
||||
extern "C" {
|
||||
#include "indirect_size.h"
|
||||
}
|
||||
|
||||
TEST(ValidEnumSizes, CallLists)
|
||||
{
|
||||
EXPECT_EQ(1, __glCallLists_size(GL_BYTE));
|
||||
EXPECT_EQ(1, __glCallLists_size(GL_UNSIGNED_BYTE));
|
||||
EXPECT_EQ(2, __glCallLists_size(GL_SHORT));
|
||||
EXPECT_EQ(2, __glCallLists_size(GL_UNSIGNED_SHORT));
|
||||
EXPECT_EQ(2, __glCallLists_size(GL_2_BYTES));
|
||||
EXPECT_EQ(2, __glCallLists_size(GL_HALF_FLOAT));
|
||||
EXPECT_EQ(3, __glCallLists_size(GL_3_BYTES));
|
||||
EXPECT_EQ(4, __glCallLists_size(GL_INT));
|
||||
EXPECT_EQ(4, __glCallLists_size(GL_UNSIGNED_INT));
|
||||
EXPECT_EQ(4, __glCallLists_size(GL_FLOAT));
|
||||
EXPECT_EQ(4, __glCallLists_size(GL_4_BYTES));
|
||||
}
|
||||
|
||||
TEST(InvalidEnumSizes, CallLists)
|
||||
{
|
||||
for (unsigned i = 0; i < 0x10004; i++) {
|
||||
switch (i) {
|
||||
case GL_BYTE:
|
||||
case GL_UNSIGNED_BYTE:
|
||||
case GL_SHORT:
|
||||
case GL_UNSIGNED_SHORT:
|
||||
case GL_2_BYTES:
|
||||
case GL_HALF_FLOAT:
|
||||
case GL_3_BYTES:
|
||||
case GL_INT:
|
||||
case GL_UNSIGNED_INT:
|
||||
case GL_FLOAT:
|
||||
case GL_4_BYTES:
|
||||
break;
|
||||
default:
|
||||
EXPECT_EQ(0, __glCallLists_size(i)) << "i = 0x" <<
|
||||
std::setw(4) << std::setfill('0') << std::hex << i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST(ValidEnumSizes, Fogfv)
|
||||
{
|
||||
EXPECT_EQ(1, __glFogfv_size(GL_FOG_INDEX));
|
||||
EXPECT_EQ(1, __glFogfv_size(GL_FOG_DENSITY));
|
||||
EXPECT_EQ(1, __glFogfv_size(GL_FOG_START));
|
||||
EXPECT_EQ(1, __glFogfv_size(GL_FOG_END));
|
||||
EXPECT_EQ(1, __glFogfv_size(GL_FOG_MODE));
|
||||
EXPECT_EQ(1, __glFogfv_size(GL_FOG_OFFSET_VALUE_SGIX));
|
||||
EXPECT_EQ(1, __glFogfv_size(GL_FOG_DISTANCE_MODE_NV));
|
||||
EXPECT_EQ(4, __glFogfv_size(GL_FOG_COLOR));
|
||||
}
|
||||
|
||||
TEST(InvalidEnumSizes, Fogfv)
|
||||
{
|
||||
for (unsigned i = 0; i < 0x10004; i++) {
|
||||
switch (i) {
|
||||
case GL_FOG_INDEX:
|
||||
case GL_FOG_DENSITY:
|
||||
case GL_FOG_START:
|
||||
case GL_FOG_END:
|
||||
case GL_FOG_MODE:
|
||||
case GL_FOG_OFFSET_VALUE_SGIX:
|
||||
case GL_FOG_DISTANCE_MODE_NV:
|
||||
case GL_FOG_COLOR:
|
||||
break;
|
||||
default:
|
||||
EXPECT_EQ(0, __glFogfv_size(i)) << "i = 0x" <<
|
||||
std::setw(4) << std::setfill('0') << std::hex << i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST(ValidEnumSizes, Lightfv)
|
||||
{
|
||||
EXPECT_EQ(1, __glLightfv_size(GL_SPOT_EXPONENT));
|
||||
EXPECT_EQ(1, __glLightfv_size(GL_SPOT_CUTOFF));
|
||||
EXPECT_EQ(1, __glLightfv_size(GL_CONSTANT_ATTENUATION));
|
||||
EXPECT_EQ(1, __glLightfv_size(GL_LINEAR_ATTENUATION));
|
||||
EXPECT_EQ(1, __glLightfv_size(GL_QUADRATIC_ATTENUATION));
|
||||
EXPECT_EQ(3, __glLightfv_size(GL_SPOT_DIRECTION));
|
||||
EXPECT_EQ(4, __glLightfv_size(GL_AMBIENT));
|
||||
EXPECT_EQ(4, __glLightfv_size(GL_DIFFUSE));
|
||||
EXPECT_EQ(4, __glLightfv_size(GL_SPECULAR));
|
||||
EXPECT_EQ(4, __glLightfv_size(GL_POSITION));
|
||||
}
|
||||
|
||||
TEST(InvalidEnumSizes, Lightfv)
|
||||
{
|
||||
for (unsigned i = 0; i < 0x10004; i++) {
|
||||
switch (i) {
|
||||
case GL_SPOT_EXPONENT:
|
||||
case GL_SPOT_CUTOFF:
|
||||
case GL_CONSTANT_ATTENUATION:
|
||||
case GL_LINEAR_ATTENUATION:
|
||||
case GL_QUADRATIC_ATTENUATION:
|
||||
case GL_SPOT_DIRECTION:
|
||||
case GL_AMBIENT:
|
||||
case GL_DIFFUSE:
|
||||
case GL_SPECULAR:
|
||||
case GL_POSITION:
|
||||
break;
|
||||
default:
|
||||
EXPECT_EQ(0, __glLightfv_size(i)) << "i = 0x" <<
|
||||
std::setw(4) << std::setfill('0') << std::hex << i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST(ValidEnumSizes, LightModelfv)
|
||||
{
|
||||
EXPECT_EQ(1, __glLightModelfv_size(GL_LIGHT_MODEL_LOCAL_VIEWER));
|
||||
EXPECT_EQ(1, __glLightModelfv_size(GL_LIGHT_MODEL_TWO_SIDE));
|
||||
EXPECT_EQ(1, __glLightModelfv_size(GL_LIGHT_MODEL_COLOR_CONTROL));
|
||||
EXPECT_EQ(1, __glLightModelfv_size(GL_LIGHT_MODEL_COLOR_CONTROL_EXT));
|
||||
EXPECT_EQ(4, __glLightModelfv_size(GL_LIGHT_MODEL_AMBIENT));
|
||||
}
|
||||
|
||||
TEST(InvalidEnumSizes, LightModelfv)
|
||||
{
|
||||
for (unsigned i = 0; i < 0x10004; i++) {
|
||||
switch (i) {
|
||||
case GL_LIGHT_MODEL_LOCAL_VIEWER:
|
||||
case GL_LIGHT_MODEL_TWO_SIDE:
|
||||
case GL_LIGHT_MODEL_COLOR_CONTROL:
|
||||
/* case GL_LIGHT_MODEL_COLOR_CONTROL_EXT:*/
|
||||
case GL_LIGHT_MODEL_AMBIENT:
|
||||
break;
|
||||
default:
|
||||
EXPECT_EQ(0, __glLightModelfv_size(i)) << "i = 0x" <<
|
||||
std::setw(4) << std::setfill('0') << std::hex << i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST(ValidEnumSizes, Materialfv)
|
||||
{
|
||||
EXPECT_EQ(1, __glMaterialfv_size(GL_SHININESS));
|
||||
EXPECT_EQ(3, __glMaterialfv_size(GL_COLOR_INDEXES));
|
||||
EXPECT_EQ(4, __glMaterialfv_size(GL_AMBIENT));
|
||||
EXPECT_EQ(4, __glMaterialfv_size(GL_DIFFUSE));
|
||||
EXPECT_EQ(4, __glMaterialfv_size(GL_SPECULAR));
|
||||
EXPECT_EQ(4, __glMaterialfv_size(GL_EMISSION));
|
||||
EXPECT_EQ(4, __glMaterialfv_size(GL_AMBIENT_AND_DIFFUSE));
|
||||
}
|
||||
|
||||
TEST(InvalidEnumSizes, Materialfv)
|
||||
{
|
||||
for (unsigned i = 0; i < 0x10004; i++) {
|
||||
switch (i) {
|
||||
case GL_SHININESS:
|
||||
case GL_COLOR_INDEXES:
|
||||
case GL_AMBIENT:
|
||||
case GL_DIFFUSE:
|
||||
case GL_SPECULAR:
|
||||
case GL_EMISSION:
|
||||
case GL_AMBIENT_AND_DIFFUSE:
|
||||
break;
|
||||
default:
|
||||
EXPECT_EQ(0, __glMaterialfv_size(i)) << "i = 0x" <<
|
||||
std::setw(4) << std::setfill('0') << std::hex << i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST(ValidEnumSizes, TexParameterfv)
|
||||
{
|
||||
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_MAG_FILTER));
|
||||
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_MIN_FILTER));
|
||||
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_WRAP_S));
|
||||
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_WRAP_T));
|
||||
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_PRIORITY));
|
||||
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_WRAP_R));
|
||||
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_COMPARE_FAIL_VALUE_ARB));
|
||||
EXPECT_EQ(1, __glTexParameterfv_size(GL_SHADOW_AMBIENT_SGIX));
|
||||
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_MIN_LOD));
|
||||
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_MAX_LOD));
|
||||
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_BASE_LEVEL));
|
||||
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_MAX_LEVEL));
|
||||
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_CLIPMAP_FRAME_SGIX));
|
||||
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_LOD_BIAS_S_SGIX));
|
||||
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_LOD_BIAS_T_SGIX));
|
||||
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_LOD_BIAS_R_SGIX));
|
||||
EXPECT_EQ(1, __glTexParameterfv_size(GL_GENERATE_MIPMAP));
|
||||
EXPECT_EQ(1, __glTexParameterfv_size(GL_GENERATE_MIPMAP_SGIS));
|
||||
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_COMPARE_SGIX));
|
||||
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_COMPARE_OPERATOR_SGIX));
|
||||
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_MAX_CLAMP_S_SGIX));
|
||||
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_MAX_CLAMP_T_SGIX));
|
||||
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_MAX_CLAMP_R_SGIX));
|
||||
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_MAX_ANISOTROPY_EXT));
|
||||
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_LOD_BIAS));
|
||||
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_LOD_BIAS_EXT));
|
||||
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_STORAGE_HINT_APPLE));
|
||||
EXPECT_EQ(1, __glTexParameterfv_size(GL_STORAGE_PRIVATE_APPLE));
|
||||
EXPECT_EQ(1, __glTexParameterfv_size(GL_STORAGE_CACHED_APPLE));
|
||||
EXPECT_EQ(1, __glTexParameterfv_size(GL_STORAGE_SHARED_APPLE));
|
||||
EXPECT_EQ(1, __glTexParameterfv_size(GL_DEPTH_TEXTURE_MODE));
|
||||
EXPECT_EQ(1, __glTexParameterfv_size(GL_DEPTH_TEXTURE_MODE_ARB));
|
||||
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_COMPARE_MODE));
|
||||
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_COMPARE_MODE_ARB));
|
||||
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_COMPARE_FUNC));
|
||||
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_COMPARE_FUNC_ARB));
|
||||
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_UNSIGNED_REMAP_MODE_NV));
|
||||
EXPECT_EQ(2, __glTexParameterfv_size(GL_TEXTURE_CLIPMAP_CENTER_SGIX));
|
||||
EXPECT_EQ(2, __glTexParameterfv_size(GL_TEXTURE_CLIPMAP_OFFSET_SGIX));
|
||||
EXPECT_EQ(3, __glTexParameterfv_size(GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX));
|
||||
EXPECT_EQ(4, __glTexParameterfv_size(GL_TEXTURE_BORDER_COLOR));
|
||||
EXPECT_EQ(4, __glTexParameterfv_size(GL_POST_TEXTURE_FILTER_BIAS_SGIX));
|
||||
EXPECT_EQ(4, __glTexParameterfv_size(GL_POST_TEXTURE_FILTER_SCALE_SGIX));
|
||||
}
|
||||
|
||||
TEST(InvalidEnumSizes, TexParameterfv)
|
||||
{
|
||||
for (unsigned i = 0; i < 0x10004; i++) {
|
||||
switch (i) {
|
||||
case GL_TEXTURE_MAG_FILTER:
|
||||
case GL_TEXTURE_MIN_FILTER:
|
||||
case GL_TEXTURE_WRAP_S:
|
||||
case GL_TEXTURE_WRAP_T:
|
||||
case GL_TEXTURE_PRIORITY:
|
||||
case GL_TEXTURE_WRAP_R:
|
||||
case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB:
|
||||
/* case GL_SHADOW_AMBIENT_SGIX:*/
|
||||
case GL_TEXTURE_MIN_LOD:
|
||||
case GL_TEXTURE_MAX_LOD:
|
||||
case GL_TEXTURE_BASE_LEVEL:
|
||||
case GL_TEXTURE_MAX_LEVEL:
|
||||
case GL_TEXTURE_CLIPMAP_FRAME_SGIX:
|
||||
case GL_TEXTURE_LOD_BIAS_S_SGIX:
|
||||
case GL_TEXTURE_LOD_BIAS_T_SGIX:
|
||||
case GL_TEXTURE_LOD_BIAS_R_SGIX:
|
||||
case GL_GENERATE_MIPMAP:
|
||||
/* case GL_GENERATE_MIPMAP_SGIS:*/
|
||||
case GL_TEXTURE_COMPARE_SGIX:
|
||||
case GL_TEXTURE_COMPARE_OPERATOR_SGIX:
|
||||
case GL_TEXTURE_MAX_CLAMP_S_SGIX:
|
||||
case GL_TEXTURE_MAX_CLAMP_T_SGIX:
|
||||
case GL_TEXTURE_MAX_CLAMP_R_SGIX:
|
||||
case GL_TEXTURE_MAX_ANISOTROPY_EXT:
|
||||
case GL_TEXTURE_LOD_BIAS:
|
||||
/* case GL_TEXTURE_LOD_BIAS_EXT:*/
|
||||
case GL_TEXTURE_STORAGE_HINT_APPLE:
|
||||
case GL_STORAGE_PRIVATE_APPLE:
|
||||
case GL_STORAGE_CACHED_APPLE:
|
||||
case GL_STORAGE_SHARED_APPLE:
|
||||
case GL_DEPTH_TEXTURE_MODE:
|
||||
/* case GL_DEPTH_TEXTURE_MODE_ARB:*/
|
||||
case GL_TEXTURE_COMPARE_MODE:
|
||||
/* case GL_TEXTURE_COMPARE_MODE_ARB:*/
|
||||
case GL_TEXTURE_COMPARE_FUNC:
|
||||
/* case GL_TEXTURE_COMPARE_FUNC_ARB:*/
|
||||
case GL_TEXTURE_UNSIGNED_REMAP_MODE_NV:
|
||||
case GL_TEXTURE_CLIPMAP_CENTER_SGIX:
|
||||
case GL_TEXTURE_CLIPMAP_OFFSET_SGIX:
|
||||
case GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX:
|
||||
case GL_TEXTURE_BORDER_COLOR:
|
||||
case GL_POST_TEXTURE_FILTER_BIAS_SGIX:
|
||||
case GL_POST_TEXTURE_FILTER_SCALE_SGIX:
|
||||
break;
|
||||
default:
|
||||
EXPECT_EQ(0, __glTexParameterfv_size(i)) << "i = 0x" <<
|
||||
std::setw(4) << std::setfill('0') << std::hex << i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST(ValidEnumSizes, TexEnvfv)
|
||||
{
|
||||
EXPECT_EQ(1, __glTexEnvfv_size(GL_ALPHA_SCALE));
|
||||
EXPECT_EQ(1, __glTexEnvfv_size(GL_TEXTURE_ENV_MODE));
|
||||
EXPECT_EQ(1, __glTexEnvfv_size(GL_TEXTURE_LOD_BIAS));
|
||||
EXPECT_EQ(1, __glTexEnvfv_size(GL_COMBINE_RGB));
|
||||
EXPECT_EQ(1, __glTexEnvfv_size(GL_COMBINE_ALPHA));
|
||||
EXPECT_EQ(1, __glTexEnvfv_size(GL_RGB_SCALE));
|
||||
EXPECT_EQ(1, __glTexEnvfv_size(GL_SOURCE0_RGB));
|
||||
EXPECT_EQ(1, __glTexEnvfv_size(GL_SOURCE1_RGB));
|
||||
EXPECT_EQ(1, __glTexEnvfv_size(GL_SOURCE2_RGB));
|
||||
EXPECT_EQ(1, __glTexEnvfv_size(GL_SOURCE3_RGB_NV));
|
||||
EXPECT_EQ(1, __glTexEnvfv_size(GL_SOURCE0_ALPHA));
|
||||
EXPECT_EQ(1, __glTexEnvfv_size(GL_SOURCE1_ALPHA));
|
||||
EXPECT_EQ(1, __glTexEnvfv_size(GL_SOURCE2_ALPHA));
|
||||
EXPECT_EQ(1, __glTexEnvfv_size(GL_SOURCE3_ALPHA_NV));
|
||||
EXPECT_EQ(1, __glTexEnvfv_size(GL_OPERAND0_RGB));
|
||||
EXPECT_EQ(1, __glTexEnvfv_size(GL_OPERAND1_RGB));
|
||||
EXPECT_EQ(1, __glTexEnvfv_size(GL_OPERAND2_RGB));
|
||||
EXPECT_EQ(1, __glTexEnvfv_size(GL_OPERAND3_RGB_NV));
|
||||
EXPECT_EQ(1, __glTexEnvfv_size(GL_OPERAND0_ALPHA));
|
||||
EXPECT_EQ(1, __glTexEnvfv_size(GL_OPERAND1_ALPHA));
|
||||
EXPECT_EQ(1, __glTexEnvfv_size(GL_OPERAND2_ALPHA));
|
||||
EXPECT_EQ(1, __glTexEnvfv_size(GL_OPERAND3_ALPHA_NV));
|
||||
EXPECT_EQ(1, __glTexEnvfv_size(GL_BUMP_TARGET_ATI));
|
||||
EXPECT_EQ(1, __glTexEnvfv_size(GL_COORD_REPLACE_ARB));
|
||||
EXPECT_EQ(1, __glTexEnvfv_size(GL_COORD_REPLACE_NV));
|
||||
EXPECT_EQ(4, __glTexEnvfv_size(GL_TEXTURE_ENV_COLOR));
|
||||
}
|
||||
|
||||
TEST(InvalidEnumSizes, TexEnvfv)
|
||||
{
|
||||
for (unsigned i = 0; i < 0x10004; i++) {
|
||||
switch (i) {
|
||||
case GL_ALPHA_SCALE:
|
||||
case GL_TEXTURE_ENV_MODE:
|
||||
case GL_TEXTURE_LOD_BIAS:
|
||||
case GL_COMBINE_RGB:
|
||||
case GL_COMBINE_ALPHA:
|
||||
case GL_RGB_SCALE:
|
||||
case GL_SOURCE0_RGB:
|
||||
case GL_SOURCE1_RGB:
|
||||
case GL_SOURCE2_RGB:
|
||||
case GL_SOURCE3_RGB_NV:
|
||||
case GL_SOURCE0_ALPHA:
|
||||
case GL_SOURCE1_ALPHA:
|
||||
case GL_SOURCE2_ALPHA:
|
||||
case GL_SOURCE3_ALPHA_NV:
|
||||
case GL_OPERAND0_RGB:
|
||||
case GL_OPERAND1_RGB:
|
||||
case GL_OPERAND2_RGB:
|
||||
case GL_OPERAND3_RGB_NV:
|
||||
case GL_OPERAND0_ALPHA:
|
||||
case GL_OPERAND1_ALPHA:
|
||||
case GL_OPERAND2_ALPHA:
|
||||
case GL_OPERAND3_ALPHA_NV:
|
||||
case GL_BUMP_TARGET_ATI:
|
||||
case GL_COORD_REPLACE_ARB:
|
||||
/* case GL_COORD_REPLACE_NV:*/
|
||||
case GL_TEXTURE_ENV_COLOR:
|
||||
break;
|
||||
default:
|
||||
EXPECT_EQ(0, __glTexEnvfv_size(i)) << "i = 0x" <<
|
||||
std::setw(4) << std::setfill('0') << std::hex << i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST(ValidEnumSizes, TexGendv)
|
||||
{
|
||||
EXPECT_EQ(1, __glTexGendv_size(GL_TEXTURE_GEN_MODE));
|
||||
EXPECT_EQ(4, __glTexGendv_size(GL_OBJECT_PLANE));
|
||||
EXPECT_EQ(4, __glTexGendv_size(GL_EYE_PLANE));
|
||||
}
|
||||
|
||||
TEST(InvalidEnumSizes, TexGendv)
|
||||
{
|
||||
for (unsigned i = 0; i < 0x10004; i++) {
|
||||
switch (i) {
|
||||
case GL_TEXTURE_GEN_MODE:
|
||||
case GL_OBJECT_PLANE:
|
||||
case GL_EYE_PLANE:
|
||||
break;
|
||||
default:
|
||||
EXPECT_EQ(0, __glTexGendv_size(i)) << "i = 0x" <<
|
||||
std::setw(4) << std::setfill('0') << std::hex << i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST(ValidEnumSizes, Map1d)
|
||||
{
|
||||
EXPECT_EQ(1, __glMap1d_size(GL_MAP1_INDEX));
|
||||
EXPECT_EQ(1, __glMap1d_size(GL_MAP1_TEXTURE_COORD_1));
|
||||
EXPECT_EQ(2, __glMap1d_size(GL_MAP1_TEXTURE_COORD_2));
|
||||
EXPECT_EQ(3, __glMap1d_size(GL_MAP1_NORMAL));
|
||||
EXPECT_EQ(3, __glMap1d_size(GL_MAP1_TEXTURE_COORD_3));
|
||||
EXPECT_EQ(3, __glMap1d_size(GL_MAP1_VERTEX_3));
|
||||
EXPECT_EQ(4, __glMap1d_size(GL_MAP1_COLOR_4));
|
||||
EXPECT_EQ(4, __glMap1d_size(GL_MAP1_TEXTURE_COORD_4));
|
||||
EXPECT_EQ(4, __glMap1d_size(GL_MAP1_VERTEX_4));
|
||||
}
|
||||
|
||||
TEST(InvalidEnumSizes, Map1d)
|
||||
{
|
||||
for (unsigned i = 0; i < 0x10004; i++) {
|
||||
switch (i) {
|
||||
case GL_MAP1_INDEX:
|
||||
case GL_MAP1_TEXTURE_COORD_1:
|
||||
case GL_MAP1_TEXTURE_COORD_2:
|
||||
case GL_MAP1_NORMAL:
|
||||
case GL_MAP1_TEXTURE_COORD_3:
|
||||
case GL_MAP1_VERTEX_3:
|
||||
case GL_MAP1_COLOR_4:
|
||||
case GL_MAP1_TEXTURE_COORD_4:
|
||||
case GL_MAP1_VERTEX_4:
|
||||
break;
|
||||
default:
|
||||
EXPECT_EQ(0, __glMap1d_size(i)) << "i = 0x" <<
|
||||
std::setw(4) << std::setfill('0') << std::hex << i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST(ValidEnumSizes, Map2d)
|
||||
{
|
||||
EXPECT_EQ(1, __glMap2d_size(GL_MAP2_INDEX));
|
||||
EXPECT_EQ(1, __glMap2d_size(GL_MAP2_TEXTURE_COORD_1));
|
||||
EXPECT_EQ(2, __glMap2d_size(GL_MAP2_TEXTURE_COORD_2));
|
||||
EXPECT_EQ(3, __glMap2d_size(GL_MAP2_NORMAL));
|
||||
EXPECT_EQ(3, __glMap2d_size(GL_MAP2_TEXTURE_COORD_3));
|
||||
EXPECT_EQ(3, __glMap2d_size(GL_MAP2_VERTEX_3));
|
||||
EXPECT_EQ(4, __glMap2d_size(GL_MAP2_COLOR_4));
|
||||
EXPECT_EQ(4, __glMap2d_size(GL_MAP2_TEXTURE_COORD_4));
|
||||
EXPECT_EQ(4, __glMap2d_size(GL_MAP2_VERTEX_4));
|
||||
}
|
||||
|
||||
TEST(InvalidEnumSizes, Map2d)
|
||||
{
|
||||
for (unsigned i = 0; i < 0x10004; i++) {
|
||||
switch (i) {
|
||||
case GL_MAP2_INDEX:
|
||||
case GL_MAP2_TEXTURE_COORD_1:
|
||||
case GL_MAP2_TEXTURE_COORD_2:
|
||||
case GL_MAP2_NORMAL:
|
||||
case GL_MAP2_TEXTURE_COORD_3:
|
||||
case GL_MAP2_VERTEX_3:
|
||||
case GL_MAP2_COLOR_4:
|
||||
case GL_MAP2_TEXTURE_COORD_4:
|
||||
case GL_MAP2_VERTEX_4:
|
||||
break;
|
||||
default:
|
||||
EXPECT_EQ(0, __glMap2d_size(i)) << "i = 0x" <<
|
||||
std::setw(4) << std::setfill('0') << std::hex << i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST(ValidEnumSizes, ColorTableParameterfv)
|
||||
{
|
||||
EXPECT_EQ(4, __glColorTableParameterfv_size(GL_COLOR_TABLE_SCALE));
|
||||
EXPECT_EQ(4, __glColorTableParameterfv_size(GL_COLOR_TABLE_BIAS));
|
||||
}
|
||||
|
||||
TEST(InvalidEnumSizes, ColorTableParameterfv)
|
||||
{
|
||||
for (unsigned i = 0; i < 0x10004; i++) {
|
||||
switch (i) {
|
||||
case GL_COLOR_TABLE_SCALE:
|
||||
case GL_COLOR_TABLE_BIAS:
|
||||
break;
|
||||
default:
|
||||
EXPECT_EQ(0, __glColorTableParameterfv_size(i)) << "i = 0x" <<
|
||||
std::setw(4) << std::setfill('0') << std::hex << i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST(ValidEnumSizes, ConvolutionParameterfv)
|
||||
{
|
||||
EXPECT_EQ(1, __glConvolutionParameterfv_size(GL_CONVOLUTION_BORDER_MODE));
|
||||
EXPECT_EQ(1, __glConvolutionParameterfv_size(GL_CONVOLUTION_BORDER_MODE_EXT));
|
||||
EXPECT_EQ(4, __glConvolutionParameterfv_size(GL_CONVOLUTION_FILTER_SCALE));
|
||||
EXPECT_EQ(4, __glConvolutionParameterfv_size(GL_CONVOLUTION_FILTER_SCALE_EXT));
|
||||
EXPECT_EQ(4, __glConvolutionParameterfv_size(GL_CONVOLUTION_FILTER_BIAS));
|
||||
EXPECT_EQ(4, __glConvolutionParameterfv_size(GL_CONVOLUTION_FILTER_BIAS_EXT));
|
||||
EXPECT_EQ(4, __glConvolutionParameterfv_size(GL_CONVOLUTION_BORDER_COLOR));
|
||||
EXPECT_EQ(4, __glConvolutionParameterfv_size(GL_CONVOLUTION_BORDER_COLOR_HP));
|
||||
}
|
||||
|
||||
TEST(InvalidEnumSizes, ConvolutionParameterfv)
|
||||
{
|
||||
for (unsigned i = 0; i < 0x10004; i++) {
|
||||
switch (i) {
|
||||
case GL_CONVOLUTION_BORDER_MODE:
|
||||
/* case GL_CONVOLUTION_BORDER_MODE_EXT:*/
|
||||
case GL_CONVOLUTION_FILTER_SCALE:
|
||||
/* case GL_CONVOLUTION_FILTER_SCALE_EXT:*/
|
||||
case GL_CONVOLUTION_FILTER_BIAS:
|
||||
/* case GL_CONVOLUTION_FILTER_BIAS_EXT:*/
|
||||
case GL_CONVOLUTION_BORDER_COLOR:
|
||||
/* case GL_CONVOLUTION_BORDER_COLOR_HP:*/
|
||||
break;
|
||||
default:
|
||||
EXPECT_EQ(0, __glConvolutionParameterfv_size(i)) << "i = 0x" <<
|
||||
std::setw(4) << std::setfill('0') << std::hex << i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST(ValidEnumSizes, PointParameterfv)
|
||||
{
|
||||
EXPECT_EQ(1, __glPointParameterfv_size(GL_POINT_SIZE_MIN));
|
||||
EXPECT_EQ(1, __glPointParameterfv_size(GL_POINT_SIZE_MIN_ARB));
|
||||
EXPECT_EQ(1, __glPointParameterfv_size(GL_POINT_SIZE_MIN_SGIS));
|
||||
EXPECT_EQ(1, __glPointParameterfv_size(GL_POINT_SIZE_MAX));
|
||||
EXPECT_EQ(1, __glPointParameterfv_size(GL_POINT_SIZE_MAX_ARB));
|
||||
EXPECT_EQ(1, __glPointParameterfv_size(GL_POINT_SIZE_MAX_SGIS));
|
||||
EXPECT_EQ(1, __glPointParameterfv_size(GL_POINT_FADE_THRESHOLD_SIZE));
|
||||
EXPECT_EQ(1, __glPointParameterfv_size(GL_POINT_FADE_THRESHOLD_SIZE_ARB));
|
||||
EXPECT_EQ(1, __glPointParameterfv_size(GL_POINT_FADE_THRESHOLD_SIZE_SGIS));
|
||||
EXPECT_EQ(1, __glPointParameterfv_size(GL_POINT_SPRITE_R_MODE_NV));
|
||||
EXPECT_EQ(1, __glPointParameterfv_size(GL_POINT_SPRITE_COORD_ORIGIN));
|
||||
EXPECT_EQ(3, __glPointParameterfv_size(GL_POINT_DISTANCE_ATTENUATION));
|
||||
EXPECT_EQ(3, __glPointParameterfv_size(GL_POINT_DISTANCE_ATTENUATION_ARB));
|
||||
}
|
||||
|
||||
TEST(InvalidEnumSizes, PointParameterfv)
|
||||
{
|
||||
for (unsigned i = 0; i < 0x10004; i++) {
|
||||
switch (i) {
|
||||
case GL_POINT_SIZE_MIN:
|
||||
/* case GL_POINT_SIZE_MIN_ARB:*/
|
||||
/* case GL_POINT_SIZE_MIN_SGIS:*/
|
||||
case GL_POINT_SIZE_MAX:
|
||||
/* case GL_POINT_SIZE_MAX_ARB:*/
|
||||
/* case GL_POINT_SIZE_MAX_SGIS:*/
|
||||
case GL_POINT_FADE_THRESHOLD_SIZE:
|
||||
/* case GL_POINT_FADE_THRESHOLD_SIZE_ARB:*/
|
||||
/* case GL_POINT_FADE_THRESHOLD_SIZE_SGIS:*/
|
||||
case GL_POINT_SPRITE_R_MODE_NV:
|
||||
case GL_POINT_SPRITE_COORD_ORIGIN:
|
||||
case GL_POINT_DISTANCE_ATTENUATION:
|
||||
/* case GL_POINT_DISTANCE_ATTENUATION_ARB:*/
|
||||
break;
|
||||
default:
|
||||
EXPECT_EQ(0, __glPointParameterfv_size(i)) << "i = 0x" <<
|
||||
std::setw(4) << std::setfill('0') << std::hex << i;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,101 +0,0 @@
|
||||
/*
|
||||
* Copyright © 2011 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 "fake_glx_screen.h"
|
||||
|
||||
struct glx_screen_vtable fake_glx_screen::vt = {
|
||||
indirect_create_context,
|
||||
indirect_create_context_attribs,
|
||||
NULL,
|
||||
NULL,
|
||||
};
|
||||
|
||||
struct glx_screen_vtable fake_glx_screen_direct::vt = {
|
||||
fake_glx_context_direct::create,
|
||||
fake_glx_context_direct::create_attribs,
|
||||
NULL,
|
||||
NULL,
|
||||
};
|
||||
|
||||
const struct glx_context_vtable fake_glx_context::vt = {
|
||||
fake_glx_context::destroy,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
};
|
||||
|
||||
int fake_glx_context::contexts_allocated = 0;
|
||||
|
||||
extern "C" struct glx_context *
|
||||
indirect_create_context(struct glx_screen *psc, struct glx_config *mode,
|
||||
struct glx_context *shareList, int renderType)
|
||||
{
|
||||
(void) shareList;
|
||||
(void) renderType;
|
||||
|
||||
return new fake_glx_context(psc, mode);
|
||||
}
|
||||
|
||||
extern "C" struct glx_context *
|
||||
indirect_create_context_attribs(struct glx_screen *base,
|
||||
struct glx_config *config_base,
|
||||
struct glx_context *shareList,
|
||||
unsigned num_attribs,
|
||||
const uint32_t *attribs,
|
||||
unsigned *error)
|
||||
{
|
||||
(void) num_attribs;
|
||||
(void) attribs;
|
||||
(void) error;
|
||||
|
||||
return indirect_create_context(base, config_base, shareList, 0);
|
||||
}
|
||||
|
||||
#ifdef GLX_USE_APPLEGL
|
||||
#warning Indirect GLX tests are not built
|
||||
extern "C" struct glx_context *
|
||||
applegl_create_context(struct glx_screen *base,
|
||||
struct glx_config *config_base,
|
||||
struct glx_context *shareList,
|
||||
int renderType)
|
||||
{
|
||||
return indirect_create_context(base, config_base, shareList, renderType);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* This is necessary so that we don't have to link with glxcurrent.c
|
||||
* which would require us to link with X libraries and what not.
|
||||
*/
|
||||
GLubyte dummyBuffer[__GLX_BUFFER_LIMIT_SIZE];
|
||||
struct glx_context_vtable dummyVtable;
|
||||
struct glx_context dummyContext = {
|
||||
&dummyBuffer[0],
|
||||
&dummyBuffer[0],
|
||||
&dummyBuffer[0],
|
||||
&dummyBuffer[__GLX_BUFFER_LIMIT_SIZE],
|
||||
sizeof(dummyBuffer),
|
||||
&dummyVtable
|
||||
};
|
||||
__THREAD_INITIAL_EXEC void *__glX_tls_Context = &dummyContext;
|
@@ -1,133 +0,0 @@
|
||||
/*
|
||||
* Copyright © 2011 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 "glxclient.h"
|
||||
|
||||
class fake_glx_screen : public glx_screen {
|
||||
public:
|
||||
fake_glx_screen(struct glx_display *glx_dpy, int num, const char *ext)
|
||||
{
|
||||
this->vtable = &fake_glx_screen::vt;
|
||||
this->serverGLXexts = 0;
|
||||
this->effectiveGLXexts = 0;
|
||||
this->display = 0;
|
||||
this->dpy = 0;
|
||||
this->scr = num;
|
||||
this->visuals = 0;
|
||||
this->configs = 0;
|
||||
this->force_direct_context = false;
|
||||
this->allow_invalid_glx_destroy_window = false;
|
||||
|
||||
this->display = glx_dpy;
|
||||
this->dpy = (glx_dpy != NULL) ? glx_dpy->dpy : NULL;
|
||||
|
||||
this->serverGLXexts = new char[strlen(ext) + 1];
|
||||
strcpy((char *) this->serverGLXexts, ext);
|
||||
}
|
||||
|
||||
~fake_glx_screen()
|
||||
{
|
||||
delete [] this->serverGLXexts;
|
||||
}
|
||||
|
||||
private:
|
||||
static struct glx_screen_vtable vt;
|
||||
};
|
||||
|
||||
class fake_glx_screen_direct : public fake_glx_screen {
|
||||
public:
|
||||
fake_glx_screen_direct(struct glx_display *glx_dpy, int num,
|
||||
const char *ext)
|
||||
: fake_glx_screen(glx_dpy, num, ext)
|
||||
{
|
||||
this->vtable = &fake_glx_screen_direct::vt;
|
||||
}
|
||||
|
||||
private:
|
||||
static struct glx_screen_vtable vt;
|
||||
};
|
||||
|
||||
class fake_glx_context : public glx_context {
|
||||
public:
|
||||
fake_glx_context(struct glx_screen *psc, struct glx_config *mode)
|
||||
{
|
||||
contexts_allocated++;
|
||||
|
||||
this->vtable = &fake_glx_context::vt;
|
||||
this->majorOpcode = 123;
|
||||
this->psc = psc;
|
||||
this->config = mode;
|
||||
this->isDirect = false;
|
||||
this->currentContextTag = -1;
|
||||
|
||||
this->client_state_private = (struct __GLXattributeRec *) 0xcafebabe;
|
||||
}
|
||||
|
||||
~fake_glx_context()
|
||||
{
|
||||
contexts_allocated--;
|
||||
}
|
||||
|
||||
/** Number of context that are allocated (and not freed). */
|
||||
static int contexts_allocated;
|
||||
|
||||
private:
|
||||
static const struct glx_context_vtable vt;
|
||||
|
||||
static void destroy(struct glx_context *gc)
|
||||
{
|
||||
delete gc;
|
||||
}
|
||||
};
|
||||
|
||||
class fake_glx_context_direct : public fake_glx_context {
|
||||
public:
|
||||
fake_glx_context_direct(struct glx_screen *psc, struct glx_config *mode)
|
||||
: fake_glx_context(psc, mode)
|
||||
{
|
||||
this->isDirect = True;
|
||||
}
|
||||
|
||||
static glx_context *create(struct glx_screen *psc, struct glx_config *mode,
|
||||
struct glx_context *shareList, int renderType)
|
||||
{
|
||||
(void) shareList;
|
||||
(void) renderType;
|
||||
|
||||
return new fake_glx_context_direct(psc, mode);
|
||||
}
|
||||
|
||||
static glx_context *create_attribs(struct glx_screen *psc,
|
||||
struct glx_config *mode,
|
||||
struct glx_context *shareList,
|
||||
unsigned num_attribs,
|
||||
const uint32_t *attribs,
|
||||
unsigned *error)
|
||||
{
|
||||
(void) shareList;
|
||||
(void) num_attribs;
|
||||
(void) attribs;
|
||||
|
||||
*error = 0;
|
||||
return new fake_glx_context_direct(psc, mode);
|
||||
}
|
||||
};
|
File diff suppressed because it is too large
Load Diff
@@ -1,38 +0,0 @@
|
||||
# Copyright © 2017 Intel Corporation
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
if with_shared_glapi
|
||||
files_glx_test = files(
|
||||
'clientinfo_unittest.cpp',
|
||||
'create_context_unittest.cpp',
|
||||
'enum_sizes.cpp',
|
||||
'fake_glx_screen.cpp',
|
||||
'fake_glx_screen.h',
|
||||
'indirect_api.cpp',
|
||||
'mock_xdisplay.h',
|
||||
'query_renderer_unittest.cpp',
|
||||
)
|
||||
if with_dri2
|
||||
files_glx_test += files('query_renderer_implementation_unittest.cpp')
|
||||
endif
|
||||
|
||||
test(
|
||||
'dispatch-index-check',
|
||||
files('dispatch-index-check'),
|
||||
suite : ['glx'],
|
||||
)
|
||||
test(
|
||||
'glx-test',
|
||||
executable(
|
||||
'glx-test',
|
||||
[files_glx_test, glx_indirect_size_h, main_dispatch_h],
|
||||
link_with : [libglx, libglapi, glx_gallium_link, libloader],
|
||||
include_directories : [
|
||||
inc_src, inc_include, inc_mesa, inc_mapi, inc_glx, inc_loader, inc_gallium
|
||||
],
|
||||
dependencies : [dep_libdrm, dep_glproto, dep_thread, idep_gtest]
|
||||
),
|
||||
suite : ['glx'],
|
||||
protocol : 'gtest',
|
||||
)
|
||||
endif
|
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Copyright © 2011 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 <X11/X.h>
|
||||
|
||||
class mock_XDisplay : public _XDisplay {
|
||||
public:
|
||||
mock_XDisplay(int nscreens)
|
||||
{
|
||||
memset(this, 0, sizeof(struct _XDisplay));
|
||||
this->nscreens = nscreens;
|
||||
}
|
||||
};
|
@@ -1,313 +0,0 @@
|
||||
/*
|
||||
* 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 <gtest/gtest.h>
|
||||
#include <signal.h>
|
||||
#include <setjmp.h>
|
||||
|
||||
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
|
||||
|
||||
#include "glxclient.h"
|
||||
#include "glx_error.h"
|
||||
#include "dri2.h"
|
||||
#include "mesa_interface.h"
|
||||
#include "dri2_priv.h"
|
||||
|
||||
namespace {
|
||||
struct attribute_test_vector {
|
||||
const char *glx_string;
|
||||
const char *dri_string;
|
||||
int glx_attribute;
|
||||
int dri_attribute;
|
||||
};
|
||||
}
|
||||
|
||||
#define E(g, d) { # g, # d, g, d }
|
||||
|
||||
static bool got_sigsegv;
|
||||
static jmp_buf jmp;
|
||||
|
||||
static void
|
||||
sigsegv_handler(int sig)
|
||||
{
|
||||
(void) sig;
|
||||
got_sigsegv = true;
|
||||
longjmp(jmp, 1);
|
||||
}
|
||||
|
||||
class dri2_query_renderer_string_test : public ::testing::Test {
|
||||
public:
|
||||
virtual void SetUp();
|
||||
virtual void TearDown();
|
||||
|
||||
struct sigaction sa;
|
||||
struct sigaction old_sa;
|
||||
};
|
||||
|
||||
class dri2_query_renderer_integer_test :
|
||||
public dri2_query_renderer_string_test {
|
||||
};
|
||||
|
||||
static bool queryString_called = false;
|
||||
static int queryString_attribute = -1;
|
||||
|
||||
static bool queryInteger_called = false;
|
||||
static int queryInteger_attribute = -1;
|
||||
|
||||
static int
|
||||
fake_queryInteger(__DRIscreen *screen, int attribute, unsigned int *val)
|
||||
{
|
||||
(void) screen;
|
||||
|
||||
queryInteger_attribute = attribute;
|
||||
queryInteger_called = true;
|
||||
|
||||
switch (attribute) {
|
||||
case __DRI2_RENDERER_VENDOR_ID:
|
||||
*val = ~__DRI2_RENDERER_VENDOR_ID;
|
||||
return 0;
|
||||
case __DRI2_RENDERER_DEVICE_ID:
|
||||
*val = ~__DRI2_RENDERER_DEVICE_ID;
|
||||
return 0;
|
||||
case __DRI2_RENDERER_VERSION:
|
||||
*val = ~__DRI2_RENDERER_VERSION;
|
||||
return 0;
|
||||
case __DRI2_RENDERER_ACCELERATED:
|
||||
*val = ~__DRI2_RENDERER_ACCELERATED;
|
||||
return 0;
|
||||
case __DRI2_RENDERER_VIDEO_MEMORY:
|
||||
*val = ~__DRI2_RENDERER_VIDEO_MEMORY;
|
||||
return 0;
|
||||
case __DRI2_RENDERER_UNIFIED_MEMORY_ARCHITECTURE:
|
||||
*val = ~__DRI2_RENDERER_UNIFIED_MEMORY_ARCHITECTURE;
|
||||
return 0;
|
||||
case __DRI2_RENDERER_PREFERRED_PROFILE:
|
||||
*val = ~__DRI2_RENDERER_PREFERRED_PROFILE;
|
||||
return 0;
|
||||
case __DRI2_RENDERER_OPENGL_CORE_PROFILE_VERSION:
|
||||
*val = ~__DRI2_RENDERER_OPENGL_CORE_PROFILE_VERSION;
|
||||
return 0;
|
||||
case __DRI2_RENDERER_OPENGL_COMPATIBILITY_PROFILE_VERSION:
|
||||
*val = ~__DRI2_RENDERER_OPENGL_COMPATIBILITY_PROFILE_VERSION;
|
||||
return 0;
|
||||
case __DRI2_RENDERER_OPENGL_ES_PROFILE_VERSION:
|
||||
*val = ~__DRI2_RENDERER_OPENGL_ES_PROFILE_VERSION;
|
||||
return 0;
|
||||
case __DRI2_RENDERER_OPENGL_ES2_PROFILE_VERSION:
|
||||
*val = ~__DRI2_RENDERER_OPENGL_ES2_PROFILE_VERSION;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
fake_queryString(__DRIscreen *screen, int attribute, const char **val)
|
||||
{
|
||||
(void) screen;
|
||||
|
||||
queryString_attribute = attribute;
|
||||
queryString_called = true;
|
||||
|
||||
switch (attribute) {
|
||||
case __DRI2_RENDERER_VENDOR_ID:
|
||||
*val = "__DRI2_RENDERER_VENDOR_ID";
|
||||
return 0;
|
||||
case __DRI2_RENDERER_DEVICE_ID:
|
||||
*val = "__DRI2_RENDERER_DEVICE_ID";
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static const __DRI2rendererQueryExtension rendererQueryExt = {
|
||||
{ __DRI2_RENDERER_QUERY, 1 },
|
||||
|
||||
fake_queryInteger,
|
||||
fake_queryString
|
||||
};
|
||||
|
||||
void dri2_query_renderer_string_test::SetUp()
|
||||
{
|
||||
got_sigsegv = false;
|
||||
|
||||
sa.sa_handler = sigsegv_handler;
|
||||
sigemptyset(&sa.sa_mask);
|
||||
sa.sa_flags = 0;
|
||||
sigaction(SIGSEGV, &sa, &old_sa);
|
||||
}
|
||||
|
||||
void dri2_query_renderer_string_test::TearDown()
|
||||
{
|
||||
sigaction(SIGSEGV, &old_sa, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* dri2_query_renderer_string will return an error if the rendererQuery
|
||||
* extension is not present. It will also not segfault.
|
||||
*/
|
||||
TEST_F(dri2_query_renderer_string_test, DRI2_RENDERER_QUERY_not_supported)
|
||||
{
|
||||
struct dri2_screen dsc;
|
||||
|
||||
memset(&dsc, 0, sizeof(dsc));
|
||||
|
||||
if (setjmp(jmp) == 0) {
|
||||
static const char original_value[] = "0xDEADBEEF";
|
||||
const char *value = original_value;
|
||||
const int success =
|
||||
dri2_query_renderer_string(&dsc.base,
|
||||
GLX_RENDERER_VENDOR_ID_MESA, &value);
|
||||
|
||||
EXPECT_EQ(-1, success);
|
||||
EXPECT_EQ(original_value, value);
|
||||
} else {
|
||||
EXPECT_FALSE(got_sigsegv);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* dri2_query_renderer_string will call queryString with the correct DRI2 enum
|
||||
* for each GLX attribute value.
|
||||
*
|
||||
* \note
|
||||
* This test does \b not perform any checking for invalid GLX attribute values.
|
||||
* Other unit tests verify that invalid values are filtered before
|
||||
* dri2_query_renderer_string is called.
|
||||
*/
|
||||
TEST_F(dri2_query_renderer_string_test, valid_attribute_mapping)
|
||||
{
|
||||
struct dri2_screen dsc;
|
||||
struct attribute_test_vector valid_attributes[] = {
|
||||
E(GLX_RENDERER_VENDOR_ID_MESA,
|
||||
__DRI2_RENDERER_VENDOR_ID),
|
||||
E(GLX_RENDERER_DEVICE_ID_MESA,
|
||||
__DRI2_RENDERER_DEVICE_ID),
|
||||
};
|
||||
|
||||
memset(&dsc, 0, sizeof(dsc));
|
||||
dsc.rendererQuery = &rendererQueryExt;
|
||||
|
||||
if (setjmp(jmp) == 0) {
|
||||
for (unsigned i = 0; i < ARRAY_SIZE(valid_attributes); i++) {
|
||||
static const char original_value[] = "original value";
|
||||
const char *value = original_value;
|
||||
const int success =
|
||||
dri2_query_renderer_string(&dsc.base,
|
||||
valid_attributes[i].glx_attribute,
|
||||
&value);
|
||||
|
||||
EXPECT_EQ(0, success);
|
||||
EXPECT_EQ(valid_attributes[i].dri_attribute, queryString_attribute)
|
||||
<< valid_attributes[i].glx_string;
|
||||
EXPECT_STREQ(valid_attributes[i].dri_string, value)
|
||||
<< valid_attributes[i].glx_string;
|
||||
}
|
||||
} else {
|
||||
EXPECT_FALSE(got_sigsegv);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* dri2_query_renderer_integer will return an error if the rendererQuery
|
||||
* extension is not present. It will also not segfault.
|
||||
*/
|
||||
TEST_F(dri2_query_renderer_integer_test, DRI2_RENDERER_QUERY_not_supported)
|
||||
{
|
||||
struct dri2_screen dsc;
|
||||
|
||||
memset(&dsc, 0, sizeof(dsc));
|
||||
|
||||
if (setjmp(jmp) == 0) {
|
||||
unsigned int value = 0xDEADBEEF;
|
||||
const int success =
|
||||
dri2_query_renderer_integer(&dsc.base,
|
||||
GLX_RENDERER_VENDOR_ID_MESA, &value);
|
||||
|
||||
EXPECT_EQ(-1, success);
|
||||
EXPECT_EQ(0xDEADBEEF, value);
|
||||
} else {
|
||||
EXPECT_FALSE(got_sigsegv);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* dri2_query_renderer_integer will call queryInteger with the correct DRI2 enum
|
||||
* for each GLX attribute value.
|
||||
*
|
||||
* \note
|
||||
* This test does \b not perform any checking for invalid GLX attribute values.
|
||||
* Other unit tests verify that invalid values are filtered before
|
||||
* dri2_query_renderer_integer is called.
|
||||
*/
|
||||
TEST_F(dri2_query_renderer_integer_test, valid_attribute_mapping)
|
||||
{
|
||||
struct dri2_screen dsc;
|
||||
struct attribute_test_vector valid_attributes[] = {
|
||||
E(GLX_RENDERER_VENDOR_ID_MESA,
|
||||
__DRI2_RENDERER_VENDOR_ID),
|
||||
E(GLX_RENDERER_DEVICE_ID_MESA,
|
||||
__DRI2_RENDERER_DEVICE_ID),
|
||||
E(GLX_RENDERER_VERSION_MESA,
|
||||
__DRI2_RENDERER_VERSION),
|
||||
E(GLX_RENDERER_ACCELERATED_MESA,
|
||||
__DRI2_RENDERER_ACCELERATED),
|
||||
E(GLX_RENDERER_VIDEO_MEMORY_MESA,
|
||||
__DRI2_RENDERER_VIDEO_MEMORY),
|
||||
E(GLX_RENDERER_UNIFIED_MEMORY_ARCHITECTURE_MESA,
|
||||
__DRI2_RENDERER_UNIFIED_MEMORY_ARCHITECTURE),
|
||||
E(GLX_RENDERER_PREFERRED_PROFILE_MESA,
|
||||
__DRI2_RENDERER_PREFERRED_PROFILE),
|
||||
E(GLX_RENDERER_OPENGL_CORE_PROFILE_VERSION_MESA,
|
||||
__DRI2_RENDERER_OPENGL_CORE_PROFILE_VERSION),
|
||||
E(GLX_RENDERER_OPENGL_COMPATIBILITY_PROFILE_VERSION_MESA,
|
||||
__DRI2_RENDERER_OPENGL_COMPATIBILITY_PROFILE_VERSION),
|
||||
E(GLX_RENDERER_OPENGL_ES_PROFILE_VERSION_MESA,
|
||||
__DRI2_RENDERER_OPENGL_ES_PROFILE_VERSION),
|
||||
E(GLX_RENDERER_OPENGL_ES2_PROFILE_VERSION_MESA,
|
||||
__DRI2_RENDERER_OPENGL_ES2_PROFILE_VERSION),
|
||||
};
|
||||
|
||||
memset(&dsc, 0, sizeof(dsc));
|
||||
dsc.rendererQuery = &rendererQueryExt;
|
||||
|
||||
if (setjmp(jmp) == 0) {
|
||||
for (unsigned i = 0; i < ARRAY_SIZE(valid_attributes); i++) {
|
||||
unsigned int value = 0xDEADBEEF;
|
||||
const int success =
|
||||
dri2_query_renderer_integer(&dsc.base,
|
||||
valid_attributes[i].glx_attribute,
|
||||
&value);
|
||||
|
||||
EXPECT_EQ(0, success);
|
||||
EXPECT_EQ(valid_attributes[i].dri_attribute, queryInteger_attribute)
|
||||
<< valid_attributes[i].glx_string;
|
||||
EXPECT_EQ((unsigned int) ~valid_attributes[i].dri_attribute, value)
|
||||
<< valid_attributes[i].glx_string;
|
||||
}
|
||||
} else {
|
||||
EXPECT_FALSE(got_sigsegv);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* GLX_DIRECT_RENDERING */
|
@@ -1,436 +0,0 @@
|
||||
/*
|
||||
* 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 <gtest/gtest.h>
|
||||
#include <signal.h>
|
||||
#include <setjmp.h>
|
||||
|
||||
#include "glxclient.h"
|
||||
#include "glx_error.h"
|
||||
|
||||
extern bool GetGLXScreenConfigs_called;
|
||||
extern struct glx_screen *psc;
|
||||
|
||||
struct attribute_test_vector {
|
||||
const char *string;
|
||||
int value;
|
||||
};
|
||||
|
||||
#define E(x) { # x, x }
|
||||
|
||||
|
||||
|
||||
static bool got_sigsegv;
|
||||
static jmp_buf jmp;
|
||||
|
||||
static void
|
||||
sigsegv_handler(int sig)
|
||||
{
|
||||
(void) sig;
|
||||
got_sigsegv = true;
|
||||
longjmp(jmp, 1);
|
||||
}
|
||||
|
||||
static bool query_renderer_string_called = false;
|
||||
static bool query_renderer_integer_called = false;
|
||||
|
||||
static int
|
||||
fake_query_renderer_integer(struct glx_screen *psc, int attribute,
|
||||
unsigned int *value)
|
||||
{
|
||||
(void) psc;
|
||||
(void) attribute;
|
||||
(void) value;
|
||||
|
||||
query_renderer_integer_called = true;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
fake_query_renderer_string(struct glx_screen *psc, int attribute,
|
||||
const char **value)
|
||||
{
|
||||
(void) psc;
|
||||
(void) attribute;
|
||||
(void) value;
|
||||
|
||||
query_renderer_string_called = true;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct glx_screen_vtable fake_vtable = {
|
||||
NULL,
|
||||
NULL,
|
||||
fake_query_renderer_integer,
|
||||
fake_query_renderer_string
|
||||
};
|
||||
|
||||
class query_renderer_string_test : public ::testing::Test {
|
||||
public:
|
||||
virtual void SetUp();
|
||||
virtual void TearDown();
|
||||
|
||||
struct glx_screen scr;
|
||||
struct sigaction sa;
|
||||
struct sigaction old_sa;
|
||||
Display dpy;
|
||||
};
|
||||
|
||||
class query_renderer_integer_test : public query_renderer_string_test {
|
||||
};
|
||||
|
||||
void query_renderer_string_test::SetUp()
|
||||
{
|
||||
memset(&scr, 0, sizeof(scr));
|
||||
scr.vtable = &fake_vtable;
|
||||
psc = &scr;
|
||||
|
||||
got_sigsegv = false;
|
||||
|
||||
sa.sa_handler = sigsegv_handler;
|
||||
sigemptyset(&sa.sa_mask);
|
||||
sa.sa_flags = 0;
|
||||
sigaction(SIGSEGV, &sa, &old_sa);
|
||||
}
|
||||
|
||||
void query_renderer_string_test::TearDown()
|
||||
{
|
||||
sigaction(SIGSEGV, &old_sa, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* glXQueryRendererStringMESA will return \c NULL if the query_render_string
|
||||
* vtable entry is \c NULL. It will also not segfault.
|
||||
*/
|
||||
TEST_F(query_renderer_string_test, null_query_render_string)
|
||||
{
|
||||
struct glx_screen_vtable vtable = {
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
scr.vtable = &vtable;
|
||||
|
||||
if (setjmp(jmp) == 0) {
|
||||
const char *str =
|
||||
glXQueryRendererStringMESA(&dpy, 0, 0, GLX_RENDERER_VENDOR_ID_MESA);
|
||||
EXPECT_EQ((char *)0, str);
|
||||
} else {
|
||||
EXPECT_FALSE(got_sigsegv);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* glXQueryRendererStringMESA will not call the screen query_render_string
|
||||
* function with an invalid GLX enum value, and it will return NULL.
|
||||
*/
|
||||
TEST_F(query_renderer_string_test, invalid_attribute)
|
||||
{
|
||||
static const attribute_test_vector invalid_attributes[] = {
|
||||
/* These values are just plain invalid for use with this extension.
|
||||
*/
|
||||
E(0),
|
||||
E(GLX_VENDOR),
|
||||
E(GLX_VERSION),
|
||||
E(GLX_EXTENSIONS),
|
||||
E(GLX_RENDERER_VENDOR_ID_MESA + 0x10000),
|
||||
E(GLX_RENDERER_DEVICE_ID_MESA + 0x10000),
|
||||
|
||||
/* These enums are part of the extension, but they are not allowed for
|
||||
* the string query.
|
||||
*/
|
||||
E(GLX_RENDERER_VERSION_MESA),
|
||||
E(GLX_RENDERER_ACCELERATED_MESA),
|
||||
E(GLX_RENDERER_VIDEO_MEMORY_MESA),
|
||||
E(GLX_RENDERER_UNIFIED_MEMORY_ARCHITECTURE_MESA),
|
||||
E(GLX_RENDERER_PREFERRED_PROFILE_MESA),
|
||||
E(GLX_RENDERER_OPENGL_CORE_PROFILE_VERSION_MESA),
|
||||
E(GLX_RENDERER_OPENGL_COMPATIBILITY_PROFILE_VERSION_MESA),
|
||||
E(GLX_RENDERER_OPENGL_ES_PROFILE_VERSION_MESA),
|
||||
E(GLX_RENDERER_OPENGL_ES2_PROFILE_VERSION_MESA),
|
||||
};
|
||||
|
||||
for (unsigned i = 0; i < ARRAY_SIZE(invalid_attributes); i++) {
|
||||
query_renderer_integer_called = false;
|
||||
query_renderer_string_called = false;
|
||||
|
||||
const char *str =
|
||||
glXQueryRendererStringMESA(&dpy, 0, 0, invalid_attributes[i].value);
|
||||
EXPECT_EQ((char *)0, str) << invalid_attributes[i].string;
|
||||
EXPECT_FALSE(query_renderer_integer_called)
|
||||
<< invalid_attributes[i].string;
|
||||
EXPECT_FALSE(query_renderer_string_called)
|
||||
<< invalid_attributes[i].string;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* glXQueryRendererStringMESA will not call GetGLXScreenConfigs if the display
|
||||
* pointer is \c NULL. It will also not segfault.
|
||||
*/
|
||||
TEST_F(query_renderer_string_test, null_display_pointer)
|
||||
{
|
||||
if (setjmp(jmp) == 0) {
|
||||
GetGLXScreenConfigs_called = false;
|
||||
|
||||
const char *str =
|
||||
glXQueryRendererStringMESA(NULL, 0, 0, GLX_RENDERER_VENDOR_ID_MESA);
|
||||
EXPECT_EQ((char *)0, str);
|
||||
EXPECT_FALSE(GetGLXScreenConfigs_called);
|
||||
} else {
|
||||
EXPECT_FALSE(got_sigsegv);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* glXQueryRendererStringMESA will return error if GetGLXScreenConfigs returns
|
||||
* NULL. It will also not segfault.
|
||||
*/
|
||||
TEST_F(query_renderer_string_test, null_screen_pointer)
|
||||
{
|
||||
psc = NULL;
|
||||
|
||||
if (setjmp(jmp) == 0) {
|
||||
GetGLXScreenConfigs_called = false;
|
||||
|
||||
const char *str =
|
||||
glXQueryRendererStringMESA(&dpy, 0, 0, GLX_RENDERER_VENDOR_ID_MESA);
|
||||
EXPECT_EQ((char *)0, str);
|
||||
EXPECT_TRUE(GetGLXScreenConfigs_called);
|
||||
} else {
|
||||
EXPECT_FALSE(got_sigsegv);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* glXQueryRendererStringMESA will not call the screen query_render_string
|
||||
* function if the renderer is invalid, and it will return NULL.
|
||||
*/
|
||||
TEST_F(query_renderer_string_test, invalid_renderer_index)
|
||||
{
|
||||
static const int invalid_renderer_indices[] = {
|
||||
-1,
|
||||
1,
|
||||
999,
|
||||
};
|
||||
|
||||
if (setjmp(jmp) == 0) {
|
||||
for (unsigned i = 0; i < ARRAY_SIZE(invalid_renderer_indices); i++) {
|
||||
const char *str =
|
||||
glXQueryRendererStringMESA(&dpy, 0,
|
||||
invalid_renderer_indices[i],
|
||||
GLX_RENDERER_VENDOR_ID_MESA);
|
||||
EXPECT_EQ((char *)0, str) << invalid_renderer_indices[i];
|
||||
EXPECT_FALSE(query_renderer_integer_called)
|
||||
<< invalid_renderer_indices[i];
|
||||
EXPECT_FALSE(query_renderer_string_called)
|
||||
<< invalid_renderer_indices[i];
|
||||
}
|
||||
} else {
|
||||
EXPECT_FALSE(got_sigsegv);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* glXQueryCurrentRendererStringMESA will return error if there is no context
|
||||
* current. It will also not segfault.
|
||||
*/
|
||||
TEST_F(query_renderer_string_test, no_current_context)
|
||||
{
|
||||
if (setjmp(jmp) == 0) {
|
||||
const char *str =
|
||||
glXQueryCurrentRendererStringMESA(GLX_RENDERER_VENDOR_ID_MESA);
|
||||
EXPECT_EQ((char *)0, str);
|
||||
} else {
|
||||
EXPECT_FALSE(got_sigsegv);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* glXQueryCurrentRendererIntegerMESA will return \c NULL if the
|
||||
* query_render_string vtable entry is \c NULL. It will also not segfault.
|
||||
*/
|
||||
TEST_F(query_renderer_integer_test, null_query_render_string)
|
||||
{
|
||||
struct glx_screen_vtable vtable = {
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
scr.vtable = &vtable;
|
||||
|
||||
if (setjmp(jmp) == 0) {
|
||||
unsigned value = 0xDEADBEEF;
|
||||
Bool success = glXQueryRendererIntegerMESA(&dpy, 0, 0,
|
||||
GLX_RENDERER_VENDOR_ID_MESA,
|
||||
&value);
|
||||
EXPECT_FALSE(success);
|
||||
EXPECT_EQ(0xDEADBEEF, value);
|
||||
} else {
|
||||
EXPECT_FALSE(got_sigsegv);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* glXQueryCurrentRendererIntegerMESA will not call the screen
|
||||
* query_render_string function with an invalid GLX enum value, and it will
|
||||
* return NULL.
|
||||
*/
|
||||
TEST_F(query_renderer_integer_test, invalid_attribute)
|
||||
{
|
||||
static const attribute_test_vector invalid_attributes[] = {
|
||||
/* These values are just plain invalid for use with this extension.
|
||||
*/
|
||||
E(0),
|
||||
E(GLX_VENDOR),
|
||||
E(GLX_VERSION),
|
||||
E(GLX_EXTENSIONS),
|
||||
E(GLX_RENDERER_VENDOR_ID_MESA + 0x10000),
|
||||
E(GLX_RENDERER_DEVICE_ID_MESA + 0x10000),
|
||||
E(GLX_RENDERER_VERSION_MESA + 0x10000),
|
||||
E(GLX_RENDERER_ACCELERATED_MESA + 0x10000),
|
||||
E(GLX_RENDERER_VIDEO_MEMORY_MESA + 0x10000),
|
||||
E(GLX_RENDERER_UNIFIED_MEMORY_ARCHITECTURE_MESA + 0x10000),
|
||||
E(GLX_RENDERER_PREFERRED_PROFILE_MESA + 0x10000),
|
||||
E(GLX_RENDERER_OPENGL_CORE_PROFILE_VERSION_MESA + 0x10000),
|
||||
E(GLX_RENDERER_OPENGL_COMPATIBILITY_PROFILE_VERSION_MESA + 0x10000),
|
||||
E(GLX_RENDERER_OPENGL_ES_PROFILE_VERSION_MESA + 0x10000),
|
||||
E(GLX_RENDERER_OPENGL_ES2_PROFILE_VERSION_MESA + 0x10000),
|
||||
};
|
||||
|
||||
for (unsigned i = 0; i < ARRAY_SIZE(invalid_attributes); i++) {
|
||||
query_renderer_integer_called = false;
|
||||
query_renderer_string_called = false;
|
||||
|
||||
unsigned value = 0xDEADBEEF;
|
||||
Bool success =
|
||||
glXQueryRendererIntegerMESA(&dpy, 0, 0,
|
||||
invalid_attributes[i].value,
|
||||
&value);
|
||||
EXPECT_FALSE(success) << invalid_attributes[i].string;
|
||||
EXPECT_EQ(0xDEADBEEF, value) << invalid_attributes[i].string;
|
||||
EXPECT_FALSE(query_renderer_integer_called)
|
||||
<< invalid_attributes[i].string;
|
||||
EXPECT_FALSE(query_renderer_string_called)
|
||||
<< invalid_attributes[i].string;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* glXQueryCurrentRendererIntegerMESA will not call GetGLXScreenConfigs if the
|
||||
* display pointer is \c NULL. It will also not segfault.
|
||||
*/
|
||||
TEST_F(query_renderer_integer_test, null_display_pointer)
|
||||
{
|
||||
if (setjmp(jmp) == 0) {
|
||||
GetGLXScreenConfigs_called = false;
|
||||
|
||||
unsigned value = 0xDEADBEEF;
|
||||
Bool success =
|
||||
glXQueryRendererIntegerMESA(NULL, 0, 0, GLX_RENDERER_VENDOR_ID_MESA,
|
||||
&value);
|
||||
EXPECT_FALSE(success);
|
||||
EXPECT_EQ(0xDEADBEEF, value);
|
||||
EXPECT_FALSE(GetGLXScreenConfigs_called);
|
||||
} else {
|
||||
EXPECT_FALSE(got_sigsegv);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* glXQueryCurrentRendererIntegerMESA will return error if GetGLXScreenConfigs
|
||||
* returns NULL. It will also not segfault.
|
||||
*/
|
||||
TEST_F(query_renderer_integer_test, null_screen_pointer)
|
||||
{
|
||||
psc = NULL;
|
||||
|
||||
if (setjmp(jmp) == 0) {
|
||||
GetGLXScreenConfigs_called = false;
|
||||
|
||||
unsigned value = 0xDEADBEEF;
|
||||
Bool success =
|
||||
glXQueryRendererIntegerMESA(&dpy, 0, 0, GLX_RENDERER_VENDOR_ID_MESA,
|
||||
&value);
|
||||
EXPECT_FALSE(success);
|
||||
EXPECT_EQ(0xDEADBEEF, value);
|
||||
EXPECT_TRUE(GetGLXScreenConfigs_called);
|
||||
} else {
|
||||
EXPECT_FALSE(got_sigsegv);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* glXQueryRendererIntegerMESA will not call the screen query_render_integer
|
||||
* function if the renderer is invalid, and it will return NULL.
|
||||
*/
|
||||
TEST_F(query_renderer_integer_test, invalid_renderer_index)
|
||||
{
|
||||
static const int invalid_renderer_indices[] = {
|
||||
-1,
|
||||
1,
|
||||
999,
|
||||
};
|
||||
|
||||
if (setjmp(jmp) == 0) {
|
||||
for (unsigned i = 0; i < ARRAY_SIZE(invalid_renderer_indices); i++) {
|
||||
unsigned value = 0xDEADBEEF;
|
||||
Bool success =
|
||||
glXQueryRendererIntegerMESA(&dpy, 0,
|
||||
invalid_renderer_indices[i],
|
||||
GLX_RENDERER_VENDOR_ID_MESA,
|
||||
&value);
|
||||
EXPECT_FALSE(success) << invalid_renderer_indices[i];
|
||||
EXPECT_EQ(0xDEADBEEF, value) << invalid_renderer_indices[i];
|
||||
EXPECT_FALSE(query_renderer_integer_called)
|
||||
<< invalid_renderer_indices[i];
|
||||
EXPECT_FALSE(query_renderer_string_called)
|
||||
<< invalid_renderer_indices[i];
|
||||
}
|
||||
} else {
|
||||
EXPECT_FALSE(got_sigsegv);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* glXQueryCurrentRendererIntegerMESA will return error if there is no context
|
||||
* current. It will also not segfault.
|
||||
*/
|
||||
TEST_F(query_renderer_integer_test, no_current_context)
|
||||
{
|
||||
if (setjmp(jmp) == 0) {
|
||||
unsigned value = 0xDEADBEEF;
|
||||
Bool success =
|
||||
glXQueryCurrentRendererIntegerMESA(GLX_RENDERER_VENDOR_ID_MESA,
|
||||
&value);
|
||||
EXPECT_FALSE(success);
|
||||
EXPECT_EQ(0xDEADBEEF, value);
|
||||
} else {
|
||||
EXPECT_FALSE(got_sigsegv);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user