diff options
author | Robert Ellison <[email protected]> | 2009-08-07 12:23:19 -0600 |
---|---|---|
committer | Robert Ellison <[email protected]> | 2009-08-07 12:23:19 -0600 |
commit | 2caec748ad2361a55d53f98b1d332548e6baf65e (patch) | |
tree | 9a97994cfb8cb7f22afc4df2591055992bbb6666 /progs/tests | |
parent | 99d5139078654f2728aa42aca31811308e29a589 (diff) |
tests: have getprocaddress return a return code
These minor changes allow getprocaddress to return an error code
in the case of test failure. This allows the program to be integrated
into the piglit test suite.
Diffstat (limited to 'progs/tests')
-rw-r--r-- | progs/tests/getprocaddress.c | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/progs/tests/getprocaddress.c b/progs/tests/getprocaddress.c index 7de581a64dd..a09ea58e1da 100644 --- a/progs/tests/getprocaddress.c +++ b/progs/tests/getprocaddress.c @@ -3507,7 +3507,10 @@ extension_supported(const char *haystack, const char *needle) } -static void +/* Run all the known extension function tests, if the extension is supported. + * Return a count of how many failed. + */ +static int check_functions( const char *extensions ) { struct name_test_pair *entry; @@ -3629,11 +3632,19 @@ check_functions( const char *extensions ) printf("Total: %d pass %d fail %d untested %d unsupported %d total\n", totalPass, totalFail, totalUntested, totalUnsupported, totalPass + totalFail + totalUntested + totalUnsupported); + + return totalFail; } +/* Return an error code */ +#define ERROR_NONE 0 +#define ERROR_NO_VISUAL 1 +#define ERROR_NO_CONTEXT 2 +#define ERROR_NO_MAKECURRENT 3 +#define ERROR_FAILED 4 -static void +static int print_screen_info(Display *dpy, int scrnum, Bool allowDirect) { Window win; @@ -3659,6 +3670,7 @@ print_screen_info(Display *dpy, int scrnum, Bool allowDirect) GLXContext ctx; XVisualInfo *visinfo; int width = 100, height = 100; + int failures; root = RootWindow(dpy, scrnum); @@ -3667,7 +3679,7 @@ print_screen_info(Display *dpy, int scrnum, Bool allowDirect) visinfo = glXChooseVisual(dpy, scrnum, attribDouble); if (!visinfo) { fprintf(stderr, "Error: couldn't find RGB GLX visual\n"); - return; + return ERROR_NO_VISUAL; } } @@ -3684,26 +3696,29 @@ print_screen_info(Display *dpy, int scrnum, Bool allowDirect) if (!ctx) { fprintf(stderr, "Error: glXCreateContext failed\n"); XDestroyWindow(dpy, win); - return; + return ERROR_NO_CONTEXT; } - if (glXMakeCurrent(dpy, win, ctx)) { - check_functions( (const char *) glGetString(GL_EXTENSIONS) ); - } - else { + if (!glXMakeCurrent(dpy, win, ctx)) { fprintf(stderr, "Error: glXMakeCurrent failed\n"); + glXDestroyContext(dpy, ctx); + XDestroyWindow(dpy, win); + return ERROR_NO_MAKECURRENT; } + failures = check_functions( (const char *) glGetString(GL_EXTENSIONS) ); glXDestroyContext(dpy, ctx); XDestroyWindow(dpy, win); -} + return (failures == 0 ? ERROR_NONE : ERROR_FAILED); +} int main(int argc, char *argv[]) { char *displayName = NULL; Display *dpy; + int returnCode; dpy = XOpenDisplay(displayName); if (!dpy) { @@ -3711,9 +3726,9 @@ main(int argc, char *argv[]) return -1; } - print_screen_info(dpy, 0, GL_TRUE); + returnCode = print_screen_info(dpy, 0, GL_TRUE); XCloseDisplay(dpy); - return 0; + return returnCode; } |