[tests] Add make current subtests
This implements a test app, testglxmakecurrent, which verifies the
correctness of the API library's GL dispatching when a vendor's context
is current in one or more threads.
This test spawns a given number of threads each with their own separate
context and window, and has each thread make current to its given
context. The thread then calls some core GL functions and
(to-be-implemented) a GL extension function, glMakeCurrentTestResults(),
which returns the number of times each core GL function was called.
The test then compares glMakeCurrentTestResults()'s result (which should
match up with the vendor library's call count) to the application's call
count and fails if there is a mismatch.
The test is designed to only require pthreads if multiple threads are
used. This verifies that the API library's single-threaded fake pthread
wrapper functions work properly.
Add testglxmc{basic,late,loop,threads}.sh scripts, which run the
testglxmakecurrent test with different arguments for ordering of
glXGetProcAddress(), number of threads, and number of iterations.
Isolate helper functions for window creation/destruction to a separate
test_utils.c source file which will be used by later tests.
2013-08-12 22:12:10 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2013, NVIDIA CORPORATION.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and/or associated documentation files (the
|
|
|
|
* "Materials"), to deal in the Materials without restriction, including
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
* distribute, sublicense, and/or sell copies of the Materials, and to
|
|
|
|
* permit persons to whom the Materials are furnished to do so, subject to
|
|
|
|
* the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included
|
|
|
|
* unaltered in all copies or substantial portions of the Materials.
|
|
|
|
* Any additions, deletions, or changes to the original source files
|
|
|
|
* must be clearly indicated in accompanying documentation.
|
|
|
|
*
|
|
|
|
* THE MATERIALS ARE 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
|
|
|
|
* MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <GL/glx.h>
|
|
|
|
#include <GL/gl.h>
|
|
|
|
#include <dlfcn.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <getopt.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
#include "utils_misc.h"
|
|
|
|
#include "test_utils.h"
|
|
|
|
#include "glvnd_pthread.h"
|
|
|
|
|
2013-08-12 22:12:10 +02:00
|
|
|
// For glMakeCurrentTestResults()
|
2016-10-05 18:42:23 +02:00
|
|
|
#include "dummy/GLX_dummy.h"
|
[tests] Add make current subtests
This implements a test app, testglxmakecurrent, which verifies the
correctness of the API library's GL dispatching when a vendor's context
is current in one or more threads.
This test spawns a given number of threads each with their own separate
context and window, and has each thread make current to its given
context. The thread then calls some core GL functions and
(to-be-implemented) a GL extension function, glMakeCurrentTestResults(),
which returns the number of times each core GL function was called.
The test then compares glMakeCurrentTestResults()'s result (which should
match up with the vendor library's call count) to the application's call
count and fails if there is a mismatch.
The test is designed to only require pthreads if multiple threads are
used. This verifies that the API library's single-threaded fake pthread
wrapper functions work properly.
Add testglxmc{basic,late,loop,threads}.sh scripts, which run the
testglxmakecurrent test with different arguments for ordering of
glXGetProcAddress(), number of threads, and number of iterations.
Isolate helper functions for window creation/destruction to a separate
test_utils.c source file which will be used by later tests.
2013-08-12 22:12:10 +02:00
|
|
|
|
|
|
|
typedef struct TestOptionsRec {
|
|
|
|
int iterations;
|
|
|
|
int threads;
|
|
|
|
} TestOptions;
|
|
|
|
|
|
|
|
static void print_help(void)
|
|
|
|
{
|
|
|
|
const char *help_string =
|
|
|
|
"Options: \n"
|
|
|
|
" -h, --help Print this help message.\n"
|
|
|
|
" -i<N>, --iterations=<N> Run N make current iterations in each thread \n"
|
2019-09-05 21:13:30 +02:00
|
|
|
" -t<N>, --threads=<N> Run with N threads.\n";
|
[tests] Add make current subtests
This implements a test app, testglxmakecurrent, which verifies the
correctness of the API library's GL dispatching when a vendor's context
is current in one or more threads.
This test spawns a given number of threads each with their own separate
context and window, and has each thread make current to its given
context. The thread then calls some core GL functions and
(to-be-implemented) a GL extension function, glMakeCurrentTestResults(),
which returns the number of times each core GL function was called.
The test then compares glMakeCurrentTestResults()'s result (which should
match up with the vendor library's call count) to the application's call
count and fails if there is a mismatch.
The test is designed to only require pthreads if multiple threads are
used. This verifies that the API library's single-threaded fake pthread
wrapper functions work properly.
Add testglxmc{basic,late,loop,threads}.sh scripts, which run the
testglxmakecurrent test with different arguments for ordering of
glXGetProcAddress(), number of threads, and number of iterations.
Isolate helper functions for window creation/destruction to a separate
test_utils.c source file which will be used by later tests.
2013-08-12 22:12:10 +02:00
|
|
|
printf("%s", help_string);
|
|
|
|
}
|
|
|
|
|
|
|
|
void init_options(int argc, char **argv, TestOptions *t)
|
|
|
|
{
|
|
|
|
int c;
|
|
|
|
|
|
|
|
static struct option long_options[] = {
|
|
|
|
{ "help", no_argument, NULL, 'h'},
|
|
|
|
{ "iterations", required_argument, NULL, 'i'},
|
|
|
|
{ "threads", required_argument, NULL, 't'},
|
|
|
|
{ NULL, no_argument, NULL, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
// Initialize defaults
|
|
|
|
t->iterations = 1;
|
|
|
|
t->threads = 1;
|
|
|
|
|
|
|
|
do {
|
2019-09-05 21:13:30 +02:00
|
|
|
c = getopt_long(argc, argv, "hi:t:", long_options, NULL);
|
[tests] Add make current subtests
This implements a test app, testglxmakecurrent, which verifies the
correctness of the API library's GL dispatching when a vendor's context
is current in one or more threads.
This test spawns a given number of threads each with their own separate
context and window, and has each thread make current to its given
context. The thread then calls some core GL functions and
(to-be-implemented) a GL extension function, glMakeCurrentTestResults(),
which returns the number of times each core GL function was called.
The test then compares glMakeCurrentTestResults()'s result (which should
match up with the vendor library's call count) to the application's call
count and fails if there is a mismatch.
The test is designed to only require pthreads if multiple threads are
used. This verifies that the API library's single-threaded fake pthread
wrapper functions work properly.
Add testglxmc{basic,late,loop,threads}.sh scripts, which run the
testglxmakecurrent test with different arguments for ordering of
glXGetProcAddress(), number of threads, and number of iterations.
Isolate helper functions for window creation/destruction to a separate
test_utils.c source file which will be used by later tests.
2013-08-12 22:12:10 +02:00
|
|
|
switch (c) {
|
|
|
|
case -1:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
case 'h':
|
|
|
|
print_help();
|
|
|
|
exit(0);
|
|
|
|
break;
|
|
|
|
case 'i':
|
|
|
|
t->iterations = atoi(optarg);
|
|
|
|
if (t->iterations < 1) {
|
|
|
|
printError("1 or more iterations required!\n");
|
|
|
|
print_help();
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 't':
|
|
|
|
t->threads = atoi(optarg);
|
|
|
|
if (t->threads < 1) {
|
|
|
|
printError("1 or more threads required!\n");
|
|
|
|
print_help();
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while (c != -1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void *MakeCurrentThread(void *arg)
|
|
|
|
{
|
|
|
|
struct window_info wi;
|
2019-09-05 21:13:30 +02:00
|
|
|
PFNGLXMAKECURRENTTESTRESULTSPROC pMakeCurrentTestResults = NULL;
|
[tests] Add make current subtests
This implements a test app, testglxmakecurrent, which verifies the
correctness of the API library's GL dispatching when a vendor's context
is current in one or more threads.
This test spawns a given number of threads each with their own separate
context and window, and has each thread make current to its given
context. The thread then calls some core GL functions and
(to-be-implemented) a GL extension function, glMakeCurrentTestResults(),
which returns the number of times each core GL function was called.
The test then compares glMakeCurrentTestResults()'s result (which should
match up with the vendor library's call count) to the application's call
count and fails if there is a mismatch.
The test is designed to only require pthreads if multiple threads are
used. This verifies that the API library's single-threaded fake pthread
wrapper functions work properly.
Add testglxmc{basic,late,loop,threads}.sh scripts, which run the
testglxmakecurrent test with different arguments for ordering of
glXGetProcAddress(), number of threads, and number of iterations.
Isolate helper functions for window creation/destruction to a separate
test_utils.c source file which will be used by later tests.
2013-08-12 22:12:10 +02:00
|
|
|
GLXContext ctx = NULL;
|
|
|
|
const GLfloat v[] = { 0, 0, 0 };
|
2020-11-19 20:31:17 +01:00
|
|
|
GLboolean saw;
|
|
|
|
GLContextCounts contextCounts = {};
|
[tests] Add make current subtests
This implements a test app, testglxmakecurrent, which verifies the
correctness of the API library's GL dispatching when a vendor's context
is current in one or more threads.
This test spawns a given number of threads each with their own separate
context and window, and has each thread make current to its given
context. The thread then calls some core GL functions and
(to-be-implemented) a GL extension function, glMakeCurrentTestResults(),
which returns the number of times each core GL function was called.
The test then compares glMakeCurrentTestResults()'s result (which should
match up with the vendor library's call count) to the application's call
count and fails if there is a mismatch.
The test is designed to only require pthreads if multiple threads are
used. This verifies that the API library's single-threaded fake pthread
wrapper functions work properly.
Add testglxmc{basic,late,loop,threads}.sh scripts, which run the
testglxmakecurrent test with different arguments for ordering of
glXGetProcAddress(), number of threads, and number of iterations.
Isolate helper functions for window creation/destruction to a separate
test_utils.c source file which will be used by later tests.
2013-08-12 22:12:10 +02:00
|
|
|
GLint BeginCount = 0;
|
|
|
|
GLint EndCount = 0;
|
|
|
|
GLint Vertex3fvCount = 0;
|
|
|
|
int i;
|
|
|
|
intptr_t ret = GL_FALSE;
|
|
|
|
const TestOptions *t = (const TestOptions *)arg;
|
|
|
|
Display *dpy;
|
2016-03-29 23:12:40 +02:00
|
|
|
GLboolean success;
|
[tests] Add make current subtests
This implements a test app, testglxmakecurrent, which verifies the
correctness of the API library's GL dispatching when a vendor's context
is current in one or more threads.
This test spawns a given number of threads each with their own separate
context and window, and has each thread make current to its given
context. The thread then calls some core GL functions and
(to-be-implemented) a GL extension function, glMakeCurrentTestResults(),
which returns the number of times each core GL function was called.
The test then compares glMakeCurrentTestResults()'s result (which should
match up with the vendor library's call count) to the application's call
count and fails if there is a mismatch.
The test is designed to only require pthreads if multiple threads are
used. This verifies that the API library's single-threaded fake pthread
wrapper functions work properly.
Add testglxmc{basic,late,loop,threads}.sh scripts, which run the
testglxmakecurrent test with different arguments for ordering of
glXGetProcAddress(), number of threads, and number of iterations.
Isolate helper functions for window creation/destruction to a separate
test_utils.c source file which will be used by later tests.
2013-08-12 22:12:10 +02:00
|
|
|
|
2013-12-04 03:27:39 +01:00
|
|
|
memset(&wi, 0, sizeof(wi));
|
|
|
|
|
[tests] Add make current subtests
This implements a test app, testglxmakecurrent, which verifies the
correctness of the API library's GL dispatching when a vendor's context
is current in one or more threads.
This test spawns a given number of threads each with their own separate
context and window, and has each thread make current to its given
context. The thread then calls some core GL functions and
(to-be-implemented) a GL extension function, glMakeCurrentTestResults(),
which returns the number of times each core GL function was called.
The test then compares glMakeCurrentTestResults()'s result (which should
match up with the vendor library's call count) to the application's call
count and fails if there is a mismatch.
The test is designed to only require pthreads if multiple threads are
used. This verifies that the API library's single-threaded fake pthread
wrapper functions work properly.
Add testglxmc{basic,late,loop,threads}.sh scripts, which run the
testglxmakecurrent test with different arguments for ordering of
glXGetProcAddress(), number of threads, and number of iterations.
Isolate helper functions for window creation/destruction to a separate
test_utils.c source file which will be used by later tests.
2013-08-12 22:12:10 +02:00
|
|
|
dpy = XOpenDisplay(NULL);
|
|
|
|
if (!dpy) {
|
|
|
|
printError("No display! Please re-test with a running X server\n"
|
|
|
|
"and the DISPLAY environment variable set appropriately.\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2019-09-05 21:13:30 +02:00
|
|
|
// Make sure that libGLX has loaded the vendor library.
|
|
|
|
glXGetClientString(dpy, GLX_EXTENSIONS);
|
|
|
|
|
[tests] Add make current subtests
This implements a test app, testglxmakecurrent, which verifies the
correctness of the API library's GL dispatching when a vendor's context
is current in one or more threads.
This test spawns a given number of threads each with their own separate
context and window, and has each thread make current to its given
context. The thread then calls some core GL functions and
(to-be-implemented) a GL extension function, glMakeCurrentTestResults(),
which returns the number of times each core GL function was called.
The test then compares glMakeCurrentTestResults()'s result (which should
match up with the vendor library's call count) to the application's call
count and fails if there is a mismatch.
The test is designed to only require pthreads if multiple threads are
used. This verifies that the API library's single-threaded fake pthread
wrapper functions work properly.
Add testglxmc{basic,late,loop,threads}.sh scripts, which run the
testglxmakecurrent test with different arguments for ordering of
glXGetProcAddress(), number of threads, and number of iterations.
Isolate helper functions for window creation/destruction to a separate
test_utils.c source file which will be used by later tests.
2013-08-12 22:12:10 +02:00
|
|
|
// Test the robustness of GetProcAddress() by calling this separately for
|
|
|
|
// each thread.
|
2019-09-05 21:13:30 +02:00
|
|
|
pMakeCurrentTestResults = (PFNGLXMAKECURRENTTESTRESULTSPROC)
|
|
|
|
glXGetProcAddress((const GLubyte *) "glXMakeCurrentTestResults");
|
|
|
|
if (pMakeCurrentTestResults == NULL) {
|
|
|
|
printError("Failed to get glXMakeCurrentTestResults() function!\n");
|
|
|
|
goto fail;
|
2013-08-12 22:12:10 +02:00
|
|
|
}
|
[tests] Add make current subtests
This implements a test app, testglxmakecurrent, which verifies the
correctness of the API library's GL dispatching when a vendor's context
is current in one or more threads.
This test spawns a given number of threads each with their own separate
context and window, and has each thread make current to its given
context. The thread then calls some core GL functions and
(to-be-implemented) a GL extension function, glMakeCurrentTestResults(),
which returns the number of times each core GL function was called.
The test then compares glMakeCurrentTestResults()'s result (which should
match up with the vendor library's call count) to the application's call
count and fails if there is a mismatch.
The test is designed to only require pthreads if multiple threads are
used. This verifies that the API library's single-threaded fake pthread
wrapper functions work properly.
Add testglxmc{basic,late,loop,threads}.sh scripts, which run the
testglxmakecurrent test with different arguments for ordering of
glXGetProcAddress(), number of threads, and number of iterations.
Isolate helper functions for window creation/destruction to a separate
test_utils.c source file which will be used by later tests.
2013-08-12 22:12:10 +02:00
|
|
|
|
2017-12-06 20:41:20 +01:00
|
|
|
success = testUtilsCreateWindow(dpy, &wi, 0);
|
2016-03-29 23:12:40 +02:00
|
|
|
if (!success) {
|
[tests] Add make current subtests
This implements a test app, testglxmakecurrent, which verifies the
correctness of the API library's GL dispatching when a vendor's context
is current in one or more threads.
This test spawns a given number of threads each with their own separate
context and window, and has each thread make current to its given
context. The thread then calls some core GL functions and
(to-be-implemented) a GL extension function, glMakeCurrentTestResults(),
which returns the number of times each core GL function was called.
The test then compares glMakeCurrentTestResults()'s result (which should
match up with the vendor library's call count) to the application's call
count and fails if there is a mismatch.
The test is designed to only require pthreads if multiple threads are
used. This verifies that the API library's single-threaded fake pthread
wrapper functions work properly.
Add testglxmc{basic,late,loop,threads}.sh scripts, which run the
testglxmakecurrent test with different arguments for ordering of
glXGetProcAddress(), number of threads, and number of iterations.
Isolate helper functions for window creation/destruction to a separate
test_utils.c source file which will be used by later tests.
2013-08-12 22:12:10 +02:00
|
|
|
printError("Failed to create window!\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2017-12-06 20:41:20 +01:00
|
|
|
ctx = glXCreateContext(dpy, wi.visinfo, NULL, True);
|
[tests] Add make current subtests
This implements a test app, testglxmakecurrent, which verifies the
correctness of the API library's GL dispatching when a vendor's context
is current in one or more threads.
This test spawns a given number of threads each with their own separate
context and window, and has each thread make current to its given
context. The thread then calls some core GL functions and
(to-be-implemented) a GL extension function, glMakeCurrentTestResults(),
which returns the number of times each core GL function was called.
The test then compares glMakeCurrentTestResults()'s result (which should
match up with the vendor library's call count) to the application's call
count and fails if there is a mismatch.
The test is designed to only require pthreads if multiple threads are
used. This verifies that the API library's single-threaded fake pthread
wrapper functions work properly.
Add testglxmc{basic,late,loop,threads}.sh scripts, which run the
testglxmakecurrent test with different arguments for ordering of
glXGetProcAddress(), number of threads, and number of iterations.
Isolate helper functions for window creation/destruction to a separate
test_utils.c source file which will be used by later tests.
2013-08-12 22:12:10 +02:00
|
|
|
if (!ctx) {
|
|
|
|
printError("Failed to create a context!\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < t->iterations; i++) {
|
|
|
|
|
2016-03-29 23:12:40 +02:00
|
|
|
if (!glXMakeContextCurrent(dpy, wi.draw, wi.draw, ctx)) {
|
[tests] Add make current subtests
This implements a test app, testglxmakecurrent, which verifies the
correctness of the API library's GL dispatching when a vendor's context
is current in one or more threads.
This test spawns a given number of threads each with their own separate
context and window, and has each thread make current to its given
context. The thread then calls some core GL functions and
(to-be-implemented) a GL extension function, glMakeCurrentTestResults(),
which returns the number of times each core GL function was called.
The test then compares glMakeCurrentTestResults()'s result (which should
match up with the vendor library's call count) to the application's call
count and fails if there is a mismatch.
The test is designed to only require pthreads if multiple threads are
used. This verifies that the API library's single-threaded fake pthread
wrapper functions work properly.
Add testglxmc{basic,late,loop,threads}.sh scripts, which run the
testglxmakecurrent test with different arguments for ordering of
glXGetProcAddress(), number of threads, and number of iterations.
Isolate helper functions for window creation/destruction to a separate
test_utils.c source file which will be used by later tests.
2013-08-12 22:12:10 +02:00
|
|
|
printError("Failed to make current!\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
glBegin(GL_TRIANGLES); BeginCount++;
|
|
|
|
glVertex3fv(v); Vertex3fvCount++;
|
|
|
|
glVertex3fv(v); Vertex3fvCount++;
|
|
|
|
glVertex3fv(v); Vertex3fvCount++;
|
|
|
|
glEnd(); EndCount++;
|
|
|
|
|
2020-11-19 20:31:17 +01:00
|
|
|
// Make a call to glXMakeCurrentTestResults() to get the function contextCounts.
|
|
|
|
saw = GL_FALSE;
|
|
|
|
memset(&contextCounts, 0, sizeof(contextCounts));
|
|
|
|
pMakeCurrentTestResults(&saw, &contextCounts);
|
2013-08-12 22:12:10 +02:00
|
|
|
|
2020-11-19 20:31:17 +01:00
|
|
|
if (!saw) {
|
2019-09-05 21:13:30 +02:00
|
|
|
printError("Failed to dispatch glXMakeCurrentTestResults()!\n");
|
2013-08-12 22:12:10 +02:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2020-11-19 20:31:17 +01:00
|
|
|
// Verify we have the right function contextCounts
|
|
|
|
if ((contextCounts.beginCount != BeginCount) ||
|
|
|
|
(contextCounts.vertex3fvCount != Vertex3fvCount) ||
|
|
|
|
(contextCounts.endCount != EndCount)) {
|
|
|
|
printError("Mismatch of reported function call contextCounts "
|
2013-08-12 22:12:10 +02:00
|
|
|
"between the application and vendor library!\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
[tests] Add make current subtests
This implements a test app, testglxmakecurrent, which verifies the
correctness of the API library's GL dispatching when a vendor's context
is current in one or more threads.
This test spawns a given number of threads each with their own separate
context and window, and has each thread make current to its given
context. The thread then calls some core GL functions and
(to-be-implemented) a GL extension function, glMakeCurrentTestResults(),
which returns the number of times each core GL function was called.
The test then compares glMakeCurrentTestResults()'s result (which should
match up with the vendor library's call count) to the application's call
count and fails if there is a mismatch.
The test is designed to only require pthreads if multiple threads are
used. This verifies that the API library's single-threaded fake pthread
wrapper functions work properly.
Add testglxmc{basic,late,loop,threads}.sh scripts, which run the
testglxmakecurrent test with different arguments for ordering of
glXGetProcAddress(), number of threads, and number of iterations.
Isolate helper functions for window creation/destruction to a separate
test_utils.c source file which will be used by later tests.
2013-08-12 22:12:10 +02:00
|
|
|
|
|
|
|
if (!glXMakeContextCurrent(dpy, None, None, NULL)) {
|
|
|
|
printError("Failed to lose current!\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Try calling functions here. These should dispatch to NOP stubs
|
|
|
|
// (hence the call to glVertex3fv shouldn't crash).
|
|
|
|
glBegin(GL_TRIANGLES);
|
|
|
|
glVertex3fv(NULL);
|
|
|
|
glEnd();
|
|
|
|
|
2019-09-05 21:13:30 +02:00
|
|
|
// Similarly the call to the dynamic function glXMakeCurrentTestResults()
|
2013-08-12 22:12:10 +02:00
|
|
|
// should be a no-op.
|
2020-11-19 20:31:17 +01:00
|
|
|
saw = GL_FALSE;
|
|
|
|
pMakeCurrentTestResults(&saw, &contextCounts);
|
|
|
|
if (saw) {
|
2019-09-05 21:13:30 +02:00
|
|
|
printError("Dynamic function glXMakeCurrentTestResults() dispatched "
|
2013-08-12 22:12:10 +02:00
|
|
|
"to vendor library even though no context was current!\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
[tests] Add make current subtests
This implements a test app, testglxmakecurrent, which verifies the
correctness of the API library's GL dispatching when a vendor's context
is current in one or more threads.
This test spawns a given number of threads each with their own separate
context and window, and has each thread make current to its given
context. The thread then calls some core GL functions and
(to-be-implemented) a GL extension function, glMakeCurrentTestResults(),
which returns the number of times each core GL function was called.
The test then compares glMakeCurrentTestResults()'s result (which should
match up with the vendor library's call count) to the application's call
count and fails if there is a mismatch.
The test is designed to only require pthreads if multiple threads are
used. This verifies that the API library's single-threaded fake pthread
wrapper functions work properly.
Add testglxmc{basic,late,loop,threads}.sh scripts, which run the
testglxmakecurrent test with different arguments for ordering of
glXGetProcAddress(), number of threads, and number of iterations.
Isolate helper functions for window creation/destruction to a separate
test_utils.c source file which will be used by later tests.
2013-08-12 22:12:10 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// Success!
|
|
|
|
ret = GL_TRUE;
|
|
|
|
|
|
|
|
fail:
|
2020-11-19 20:38:01 +01:00
|
|
|
if (dpy != NULL) {
|
|
|
|
if (ctx) {
|
|
|
|
glXDestroyContext(dpy, ctx);
|
|
|
|
}
|
|
|
|
testUtilsDestroyWindow(dpy, &wi);
|
|
|
|
XCloseDisplay(dpy);
|
[tests] Add make current subtests
This implements a test app, testglxmakecurrent, which verifies the
correctness of the API library's GL dispatching when a vendor's context
is current in one or more threads.
This test spawns a given number of threads each with their own separate
context and window, and has each thread make current to its given
context. The thread then calls some core GL functions and
(to-be-implemented) a GL extension function, glMakeCurrentTestResults(),
which returns the number of times each core GL function was called.
The test then compares glMakeCurrentTestResults()'s result (which should
match up with the vendor library's call count) to the application's call
count and fails if there is a mismatch.
The test is designed to only require pthreads if multiple threads are
used. This verifies that the API library's single-threaded fake pthread
wrapper functions work properly.
Add testglxmc{basic,late,loop,threads}.sh scripts, which run the
testglxmakecurrent test with different arguments for ordering of
glXGetProcAddress(), number of threads, and number of iterations.
Isolate helper functions for window creation/destruction to a separate
test_utils.c source file which will be used by later tests.
2013-08-12 22:12:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return (void *)ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Try creating a context, making current to it, and calling GL functions
|
|
|
|
* while the context is current.
|
|
|
|
*/
|
|
|
|
TestOptions t;
|
|
|
|
int i;
|
|
|
|
void *ret;
|
2016-03-29 23:12:40 +02:00
|
|
|
int all_ret = 0;
|
[tests] Add make current subtests
This implements a test app, testglxmakecurrent, which verifies the
correctness of the API library's GL dispatching when a vendor's context
is current in one or more threads.
This test spawns a given number of threads each with their own separate
context and window, and has each thread make current to its given
context. The thread then calls some core GL functions and
(to-be-implemented) a GL extension function, glMakeCurrentTestResults(),
which returns the number of times each core GL function was called.
The test then compares glMakeCurrentTestResults()'s result (which should
match up with the vendor library's call count) to the application's call
count and fails if there is a mismatch.
The test is designed to only require pthreads if multiple threads are
used. This verifies that the API library's single-threaded fake pthread
wrapper functions work properly.
Add testglxmc{basic,late,loop,threads}.sh scripts, which run the
testglxmakecurrent test with different arguments for ordering of
glXGetProcAddress(), number of threads, and number of iterations.
Isolate helper functions for window creation/destruction to a separate
test_utils.c source file which will be used by later tests.
2013-08-12 22:12:10 +02:00
|
|
|
|
|
|
|
init_options(argc, argv, &t);
|
|
|
|
|
2016-03-29 23:12:40 +02:00
|
|
|
if (t.threads > 1) {
|
[tests] Add make current subtests
This implements a test app, testglxmakecurrent, which verifies the
correctness of the API library's GL dispatching when a vendor's context
is current in one or more threads.
This test spawns a given number of threads each with their own separate
context and window, and has each thread make current to its given
context. The thread then calls some core GL functions and
(to-be-implemented) a GL extension function, glMakeCurrentTestResults(),
which returns the number of times each core GL function was called.
The test then compares glMakeCurrentTestResults()'s result (which should
match up with the vendor library's call count) to the application's call
count and fails if there is a mismatch.
The test is designed to only require pthreads if multiple threads are
used. This verifies that the API library's single-threaded fake pthread
wrapper functions work properly.
Add testglxmc{basic,late,loop,threads}.sh scripts, which run the
testglxmakecurrent test with different arguments for ordering of
glXGetProcAddress(), number of threads, and number of iterations.
Isolate helper functions for window creation/destruction to a separate
test_utils.c source file which will be used by later tests.
2013-08-12 22:12:10 +02:00
|
|
|
XInitThreads();
|
|
|
|
|
2016-02-23 00:16:59 +01:00
|
|
|
glvndSetupPthreads();
|
2014-01-24 04:43:54 +01:00
|
|
|
|
2016-02-23 00:16:59 +01:00
|
|
|
if (__glvndPthreadFuncs.is_singlethreaded) {
|
[tests] Add make current subtests
This implements a test app, testglxmakecurrent, which verifies the
correctness of the API library's GL dispatching when a vendor's context
is current in one or more threads.
This test spawns a given number of threads each with their own separate
context and window, and has each thread make current to its given
context. The thread then calls some core GL functions and
(to-be-implemented) a GL extension function, glMakeCurrentTestResults(),
which returns the number of times each core GL function was called.
The test then compares glMakeCurrentTestResults()'s result (which should
match up with the vendor library's call count) to the application's call
count and fails if there is a mismatch.
The test is designed to only require pthreads if multiple threads are
used. This verifies that the API library's single-threaded fake pthread
wrapper functions work properly.
Add testglxmc{basic,late,loop,threads}.sh scripts, which run the
testglxmakecurrent test with different arguments for ordering of
glXGetProcAddress(), number of threads, and number of iterations.
Isolate helper functions for window creation/destruction to a separate
test_utils.c source file which will be used by later tests.
2013-08-12 22:12:10 +02:00
|
|
|
exit(1);
|
|
|
|
}
|
2016-03-29 23:12:40 +02:00
|
|
|
}
|
[tests] Add make current subtests
This implements a test app, testglxmakecurrent, which verifies the
correctness of the API library's GL dispatching when a vendor's context
is current in one or more threads.
This test spawns a given number of threads each with their own separate
context and window, and has each thread make current to its given
context. The thread then calls some core GL functions and
(to-be-implemented) a GL extension function, glMakeCurrentTestResults(),
which returns the number of times each core GL function was called.
The test then compares glMakeCurrentTestResults()'s result (which should
match up with the vendor library's call count) to the application's call
count and fails if there is a mismatch.
The test is designed to only require pthreads if multiple threads are
used. This verifies that the API library's single-threaded fake pthread
wrapper functions work properly.
Add testglxmc{basic,late,loop,threads}.sh scripts, which run the
testglxmakecurrent test with different arguments for ordering of
glXGetProcAddress(), number of threads, and number of iterations.
Isolate helper functions for window creation/destruction to a separate
test_utils.c source file which will be used by later tests.
2013-08-12 22:12:10 +02:00
|
|
|
|
2017-12-06 20:41:20 +01:00
|
|
|
if (t.threads == 1) {
|
|
|
|
ret = MakeCurrentThread((void *)&t);
|
|
|
|
if (!ret) {
|
|
|
|
all_ret = 1;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
glvnd_thread_t *threads = malloc(t.threads * sizeof(glvnd_thread_t));
|
|
|
|
|
|
|
|
for (i = 0; i < t.threads; i++) {
|
|
|
|
if (__glvndPthreadFuncs.create(&threads[i], NULL, MakeCurrentThread, (void *)&t)
|
|
|
|
!= 0) {
|
|
|
|
printError("Error in pthread_create(): %s\n", strerror(errno));
|
|
|
|
exit(1);
|
2016-03-29 23:12:40 +02:00
|
|
|
}
|
2017-12-06 20:41:20 +01:00
|
|
|
}
|
2016-03-29 23:12:40 +02:00
|
|
|
|
2017-12-06 20:41:20 +01:00
|
|
|
for (i = 0; i < t.threads; i++) {
|
|
|
|
if (__glvndPthreadFuncs.join(threads[i], &ret) != 0) {
|
|
|
|
printError("Error in pthread_join(): %s\n", strerror(errno));
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
if (!ret) {
|
|
|
|
all_ret = 1;
|
2016-03-29 23:12:40 +02:00
|
|
|
}
|
[tests] Add make current subtests
This implements a test app, testglxmakecurrent, which verifies the
correctness of the API library's GL dispatching when a vendor's context
is current in one or more threads.
This test spawns a given number of threads each with their own separate
context and window, and has each thread make current to its given
context. The thread then calls some core GL functions and
(to-be-implemented) a GL extension function, glMakeCurrentTestResults(),
which returns the number of times each core GL function was called.
The test then compares glMakeCurrentTestResults()'s result (which should
match up with the vendor library's call count) to the application's call
count and fails if there is a mismatch.
The test is designed to only require pthreads if multiple threads are
used. This verifies that the API library's single-threaded fake pthread
wrapper functions work properly.
Add testglxmc{basic,late,loop,threads}.sh scripts, which run the
testglxmakecurrent test with different arguments for ordering of
glXGetProcAddress(), number of threads, and number of iterations.
Isolate helper functions for window creation/destruction to a separate
test_utils.c source file which will be used by later tests.
2013-08-12 22:12:10 +02:00
|
|
|
}
|
2020-11-19 20:39:30 +01:00
|
|
|
free(threads);
|
[tests] Add make current subtests
This implements a test app, testglxmakecurrent, which verifies the
correctness of the API library's GL dispatching when a vendor's context
is current in one or more threads.
This test spawns a given number of threads each with their own separate
context and window, and has each thread make current to its given
context. The thread then calls some core GL functions and
(to-be-implemented) a GL extension function, glMakeCurrentTestResults(),
which returns the number of times each core GL function was called.
The test then compares glMakeCurrentTestResults()'s result (which should
match up with the vendor library's call count) to the application's call
count and fails if there is a mismatch.
The test is designed to only require pthreads if multiple threads are
used. This verifies that the API library's single-threaded fake pthread
wrapper functions work properly.
Add testglxmc{basic,late,loop,threads}.sh scripts, which run the
testglxmakecurrent test with different arguments for ordering of
glXGetProcAddress(), number of threads, and number of iterations.
Isolate helper functions for window creation/destruction to a separate
test_utils.c source file which will be used by later tests.
2013-08-12 22:12:10 +02:00
|
|
|
}
|
2016-03-29 23:12:40 +02:00
|
|
|
return all_ret;
|
[tests] Add make current subtests
This implements a test app, testglxmakecurrent, which verifies the
correctness of the API library's GL dispatching when a vendor's context
is current in one or more threads.
This test spawns a given number of threads each with their own separate
context and window, and has each thread make current to its given
context. The thread then calls some core GL functions and
(to-be-implemented) a GL extension function, glMakeCurrentTestResults(),
which returns the number of times each core GL function was called.
The test then compares glMakeCurrentTestResults()'s result (which should
match up with the vendor library's call count) to the application's call
count and fails if there is a mismatch.
The test is designed to only require pthreads if multiple threads are
used. This verifies that the API library's single-threaded fake pthread
wrapper functions work properly.
Add testglxmc{basic,late,loop,threads}.sh scripts, which run the
testglxmakecurrent test with different arguments for ordering of
glXGetProcAddress(), number of threads, and number of iterations.
Isolate helper functions for window creation/destruction to a separate
test_utils.c source file which will be used by later tests.
2013-08-12 22:12:10 +02:00
|
|
|
}
|