2 * Copyright © 2011 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 /** @file glx-make-current-bad-context.c
26 * Test that glXMakeCurrent() with a bad context correctly returns
30 #include "piglit-util-gl.h"
31 #include "piglit-glx-util.h"
33 int piglit_width
= 50, piglit_height
= 50;
35 bool found_badvalue
= false;
36 int expect_badvalue(Display
*dpy
, XErrorEvent
*e
)
38 if (e
->error_code
== BadValue
)
39 found_badvalue
= true;
45 main(int argc
, char **argv
)
51 int (*old_handler
)(Display
*, XErrorEvent
*);
61 GLXFBConfig config
, *configs
;
64 for(i
= 1; i
< argc
; ++i
) {
65 if (!strcmp(argv
[i
], "-auto"))
68 fprintf(stderr
, "Unknown option: %s\n", argv
[i
]);
71 dpy
= XOpenDisplay(NULL
);
73 fprintf(stderr
, "couldn't open display\n");
74 piglit_report_result(PIGLIT_FAIL
);
76 visinfo
= piglit_get_glx_visual(dpy
);
77 win
= piglit_get_glx_window(dpy
, visinfo
);
79 configs
= glXChooseFBConfig(dpy
, DefaultScreen(dpy
),
85 old_handler
= XSetErrorHandler(expect_badvalue
);
86 ctx
= glXCreateNewContext(dpy
, config
, 0x1010, NULL
, True
);
88 XSetErrorHandler(old_handler
);
90 if (!found_badvalue
) {
91 printf("Failed to get BadValue from glXCreateContext().\n");
92 piglit_report_result(PIGLIT_FAIL
);
96 glXMakeCurrent(dpy
, win
, ctx
);
97 piglit_report_result(PIGLIT_PASS
);
99 piglit_report_result(PIGLIT_SKIP
);