2 * Copyright © 2013 Intel Corporation
4 * Permission to use, copy, modify, distribute, and sell this software and
5 * its documentation for any purpose is hereby granted without fee, provided
6 * that the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name of the copyright holders not be used in
9 * advertising or publicity pertaining to distribution of the software
10 * without specific, written prior permission. The copyright holders make
11 * no representations about the suitability of this software for any
12 * purpose. It is provided "as is" without express or implied warranty.
14 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
15 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
17 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
18 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
19 * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
20 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 * Author: Tiago Vignatti
24 * xwayland-test: the idea is to guarantee that XWayland infrastructure in
25 * general works with Weston.
28 #include "weston-test-runner.h"
42 dri2_open(xcb_connection_t *c, xcb_screen_t *screen)
44 xcb_dri2_connect_cookie_t cookie;
45 xcb_dri2_connect_reply_t *reply;
46 xcb_dri2_authenticate_cookie_t cookie_auth;
47 xcb_dri2_authenticate_reply_t *reply_auth;
48 char *driver, *device;
52 cookie = xcb_dri2_connect(c, screen->root, XCB_DRI2_DRIVER_TYPE_DRI);
53 reply = xcb_dri2_connect_reply(c, cookie, 0);
56 driver = strndup(xcb_dri2_connect_driver_name (reply),
57 xcb_dri2_connect_driver_name_length (reply));
58 device = strndup(xcb_dri2_connect_device_name (reply),
59 xcb_dri2_connect_device_name_length (reply));
61 fd = open(device, O_RDWR);
62 printf ("Trying connect to %s driver on %s\n", driver, device);
69 drmGetMagic(fd, &magic);
71 cookie_auth = xcb_dri2_authenticate(c, screen->root, magic);
72 reply_auth = xcb_dri2_authenticate_reply(c, cookie_auth, 0);
86 c = xcb_connect (NULL, NULL);
88 printf("failed to get X11 connection\n");
92 screen = xcb_setup_roots_iterator(xcb_get_setup(c)).data;
94 win = xcb_generate_id(c);
95 xcb_create_window(c, XCB_COPY_FROM_PARENT, win, screen->root,
96 0, 0, 150, 150, 1, XCB_WINDOW_CLASS_INPUT_OUTPUT,
97 screen->root_visual, 0, NULL);
99 xcb_change_property (c, XCB_PROP_MODE_REPLACE, win,
100 XCB_ATOM_WM_NAME, XCB_ATOM_STRING, 8,
102 xcb_map_window(c, win);
105 fd = dri2_open(c, screen);
109 xcb_destroy_window(c, win);
115 * Ideally, the X Window Manager (XWM) and Weston Wayland compositor shouldn't
116 * be in the same process because they are using two different protocol
117 * streams in which one does not interface with the other. Probably the
118 * biggest problem with such architecture are the potentials dead locks that
119 * it may occur. So hypothetically, an X client might issue an X11 blocking
120 * request via X (DRI2Authenticate) which in turn sends a Wayland blocking
121 * request for Weston process it. X is blocked. At the same time, XWM might be
122 * trying to process an XChangeProperty, so it requests a blocking X11 call to
123 * the X server (xcb_get_property_reply -> xcb_wait_for_reply) which therefore
124 * will blocks there. It's a deadlock situation and this test is trying to
128 check_dri2_authenticate(void)
132 /* TODO: explain why num_tests times */
134 for (i = 0; i < num_tests; i++)
135 assert(create_window() == 0);
138 TEST(xwayland_client_test)
140 check_dri2_authenticate();