/* Compile with cc -o testcase testcase.c -lX11 -lXext */ #include #include #include #include #include #include #include extern int _XDefaultError(Display *dpy, XErrorEvent *event); static int myXErrorCallback(Display *dpy, XErrorEvent *event) { if (event->error_code == BadValue) { printf("TEST PASSED: illegal call returned BadValue\n"); XCloseDisplay(dpy); exit(0); } else if (event->error_code == BadAlloc) { printf("TEST PASSED: illegal call returned BadAlloc\n"); XCloseDisplay(dpy); exit(0); } else { return _XDefaultError(dpy, event); } } static int testXeviGetVisualInfo(Display *dpy, int opcode, int n_visual) { xEVIGetVisualInfoReq *req; xEVIGetVisualInfoReply rep; GetReq(EVIGetVisualInfo, req); req->reqType = opcode; req->xeviReqType = X_EVIGetVisualInfo; req->n_visual = n_visual; printf("Testing EVIGetVisualInfo...\n"); _XReply(dpy, (xReply *)&rep, 0, xFalse); } int main(int argc, char **argv) { int testno; int result = 0; Display *dpy; int major, minor, opcode; int n_visual = 0x40000000; if (argc == 2) { n_visual = strtol(argv[1], NULL, 0); } dpy = XOpenDisplay(NULL); if (dpy == NULL) { fprintf(stderr, "Can't open display %s\n", XDisplayName(NULL)); exit(1); } if (XQueryExtension(dpy, EVINAME, &opcode, &major, &minor) != 1) { printf("%s Extension NOT present on display - cannot test\n", EVINAME); return 1; } XSync(dpy, False); XSetErrorHandler(myXErrorCallback); testXeviGetVisualInfo(dpy, opcode, n_visual); XSync(dpy, False); XCloseDisplay(dpy); printf("TEST FAILED: No error messages recieved!\n"); }