summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMihail Konev <k.mvc@ya.ru>2017-01-12 13:21:07 +0500
committerAdam Jackson <ajax@redhat.com>2017-01-12 15:01:19 -0500
commitff66bca3e8797db709e03572d296358dc4b95653 (patch)
treee7e3eaa4e1d7773ac50b0b21994afe4ab5b63c2c /test
parent45546219e117c1b6129fd9f9be2ce5b592486feb (diff)
tests: Refactor wraps into protocol-common.c
Part of refactoring the tests into a single binary, to make partial rebuild slightly faster and less verbose. Prepares for joining test/xi2/protocol-* into a single binary. Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Mihail Konev <k.mvc@ya.ru>
Diffstat (limited to 'test')
-rw-r--r--test/xi1/Makefile.am3
-rw-r--r--test/xi1/protocol-xchangedevicecontrol.c1
-rw-r--r--test/xi2/Makefile.am22
-rw-r--r--test/xi2/protocol-common.c37
-rw-r--r--test/xi2/protocol-eventconvert.c2
-rw-r--r--test/xi2/protocol-xigetclientpointer.c17
-rw-r--r--test/xi2/protocol-xigetselectedevents.c20
-rw-r--r--test/xi2/protocol-xipassivegrabdevice.c16
-rw-r--r--test/xi2/protocol-xiquerydevice.c2
-rw-r--r--test/xi2/protocol-xiquerypointer.c21
-rw-r--r--test/xi2/protocol-xiqueryversion.c2
-rw-r--r--test/xi2/protocol-xiselectevents.c22
-rw-r--r--test/xi2/protocol-xisetclientpointer.c17
-rw-r--r--test/xi2/protocol-xiwarppointer.c20
-rw-r--r--test/xi2/xi2.c4
15 files changed, 70 insertions, 136 deletions
diff --git a/test/xi1/Makefile.am b/test/xi1/Makefile.am
index 907fa7aea..b7060e7d4 100644
--- a/test/xi1/Makefile.am
+++ b/test/xi1/Makefile.am
@@ -10,6 +10,7 @@ AM_CFLAGS = $(DIX_CFLAGS) @XORG_CFLAGS@
AM_CPPFLAGS = @XORG_INCS@ -I$(srcdir)/../xi2
TEST_LDADD=../libxservertest.la $(XORG_SYS_LIBS) $(XSERVER_SYS_LIBS) $(GLX_SYS_LIBS)
COMMON_SOURCES=$(srcdir)/../xi2/protocol-common.c
+COMMON_LD_FLAGS = -Wl,-wrap,dixLookupWindow -Wl,-wrap,dixLookupClient
if SPECIAL_DTRACE_OBJECTS
TEST_LDADD += $(OS_LIB) $(DIX_LIB)
@@ -17,7 +18,7 @@ endif
protocol_xchangedevicecontrol_LDADD=$(TEST_LDADD)
-protocol_xchangedevicecontrol_LDFLAGS=$(AM_LDFLAGS) -Wl,-wrap,WriteToClient
+protocol_xchangedevicecontrol_LDFLAGS=$(COMMON_LD_FLAGS) -Wl,-wrap,WriteToClient
protocol_xchangedevicecontrol_SOURCES=$(COMMON_SOURCES) protocol-xchangedevicecontrol.c
diff --git a/test/xi1/protocol-xchangedevicecontrol.c b/test/xi1/protocol-xchangedevicecontrol.c
index 8e638b218..64d2ca29b 100644
--- a/test/xi1/protocol-xchangedevicecontrol.c
+++ b/test/xi1/protocol-xchangedevicecontrol.c
@@ -37,6 +37,7 @@
#include "protocol-common.h"
+ClientRec client_window;
static ClientRec client_request;
static void
diff --git a/test/xi2/Makefile.am b/test/xi2/Makefile.am
index bfddfef13..9231e92db 100644
--- a/test/xi2/Makefile.am
+++ b/test/xi2/Makefile.am
@@ -20,6 +20,7 @@ AM_CFLAGS = $(DIX_CFLAGS) @XORG_CFLAGS@
AM_CPPFLAGS = @XORG_INCS@
TEST_LDADD=../libxservertest.la $(XORG_SYS_LIBS) $(XSERVER_SYS_LIBS) $(GLX_SYS_LIBS)
COMMON_SOURCES=protocol-common.h protocol-common.c
+COMMON_LD_FLAGS= -Wl,-wrap,dixLookupWindow -Wl,-wrap,dixLookupClient
if SPECIAL_DTRACE_OBJECTS
TEST_LDADD += $(OS_LIB) $(DIX_LIB)
@@ -37,16 +38,16 @@ protocol_xiwarppointer_LDADD=$(TEST_LDADD)
protocol_eventconvert_LDADD=$(TEST_LDADD)
xi2_LDADD=$(TEST_LDADD)
-protocol_xiqueryversion_LDFLAGS=$(AM_LDFLAGS) -Wl,-wrap,WriteToClient
-protocol_xiquerydevice_LDFLAGS=$(AM_LDFLAGS) -Wl,-wrap,WriteToClient
-protocol_xiselectevents_LDFLAGS=$(AM_LDFLAGS) -Wl,-wrap,dixLookupWindow -Wl,-wrap,XISetEventMask
-protocol_xigetselectedevents_LDFLAGS=$(AM_LDFLAGS) -Wl,-wrap,WriteToClient -Wl,-wrap,dixLookupWindow -Wl,-wrap,AddResource
-protocol_xisetclientpointer_LDFLAGS=$(AM_LDFLAGS) -Wl,-wrap,dixLookupClient
-protocol_xigetclientpointer_LDFLAGS=$(AM_LDFLAGS) -Wl,-wrap,WriteToClient -Wl,-wrap,dixLookupClient
-protocol_xipassivegrabdevice_LDFLAGS=$(AM_LDFLAGS) -Wl,-wrap,GrabButton -Wl,-wrap,dixLookupWindow -Wl,-wrap,WriteToClient
-protocol_xiquerypointer_LDFLAGS=$(AM_LDFLAGS) -Wl,-wrap,WriteToClient -Wl,-wrap,dixLookupWindow
-protocol_xiwarppointer_LDFLAGS=$(AM_LDFLAGS) -Wl,-wrap,WriteToClient -Wl,-wrap,dixLookupWindow
-xi2_LDFLAGS=$(AM_LDFLAGS)
+protocol_xiqueryversion_LDFLAGS=$(COMMON_LD_FLAGS) -Wl,-wrap,WriteToClient
+protocol_xiquerydevice_LDFLAGS=$(COMMON_LD_FLAGS) -Wl,-wrap,WriteToClient
+protocol_xiselectevents_LDFLAGS=$(COMMON_LD_FLAGS) -Wl,-wrap,XISetEventMask
+protocol_xigetselectedevents_LDFLAGS=$(COMMON_LD_FLAGS) -Wl,-wrap,WriteToClient -Wl,-wrap,AddResource
+protocol_xisetclientpointer_LDFLAGS=$(COMMON_LD_FLAGS) -Wl,-wrap,dixLookupClient
+protocol_xigetclientpointer_LDFLAGS=$(COMMON_LD_FLAGS) -Wl,-wrap,WriteToClient -Wl,-wrap,dixLookupClient
+protocol_xipassivegrabdevice_LDFLAGS=$(COMMON_LD_FLAGS) -Wl,-wrap,WriteToClient -Wl,-wrap,GrabButton
+protocol_xiquerypointer_LDFLAGS=$(COMMON_LD_FLAGS) -Wl,-wrap,WriteToClient
+protocol_xiwarppointer_LDFLAGS=$(COMMON_LD_FLAGS) -Wl,-wrap,WriteToClient
+xi2_LDFLAGS=$(COMMON_LD_FLAGS)
protocol_xiqueryversion_SOURCES=$(COMMON_SOURCES) protocol-xiqueryversion.c
protocol_xiquerydevice_SOURCES=$(COMMON_SOURCES) protocol-xiquerydevice.c
@@ -57,6 +58,7 @@ protocol_xigetclientpointer_SOURCES=$(COMMON_SOURCES) protocol-xigetclientpointe
protocol_xiquerypointer_SOURCES=$(COMMON_SOURCES) protocol-xiquerypointer.c
protocol_xipassivegrabdevice_SOURCES=$(COMMON_SOURCES) protocol-xipassivegrabdevice.c
protocol_xiwarppointer_SOURCES=$(COMMON_SOURCES) protocol-xiwarppointer.c
+xi2_SOURCES=$(COMMON_SOURCES) xi2.c
else
# Print that xi2-tests were skipped (exit code 77 for automake test harness)
TESTS = xi2-tests
diff --git a/test/xi2/protocol-common.c b/test/xi2/protocol-common.c
index 9265ba390..d30593a13 100644
--- a/test/xi2/protocol-common.c
+++ b/test/xi2/protocol-common.c
@@ -284,3 +284,40 @@ __wrap_WriteToClient(ClientPtr client, int len, void *data)
(*reply_handler) (client, len, data, global_userdata);
}
+
+/* dixLookupWindow requires a lot of setup not necessary for this test.
+ * Simple wrapper that returns either one of the fake root window or the
+ * fake client window. If the requested ID is neither of those wanted,
+ * return whatever the real dixLookupWindow does.
+ */
+int
+__wrap_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access)
+{
+ if (id == root.drawable.id) {
+ *win = &root;
+ return Success;
+ }
+ else if (id == window.drawable.id) {
+ *win = &window;
+ return Success;
+ }
+
+ return __real_dixLookupWindow(win, id, client, access);
+}
+
+extern ClientRec client_window;
+
+int
+__wrap_dixLookupClient(ClientPtr *pClient, XID rid, ClientPtr client,
+ Mask access)
+{
+ if (rid == ROOT_WINDOW_ID)
+ return BadWindow;
+
+ if (rid == CLIENT_WINDOW_ID) {
+ *pClient = &client_window;
+ return Success;
+ }
+
+ return __real_dixLookupClient(pClient, rid, client, access);
+}
diff --git a/test/xi2/protocol-eventconvert.c b/test/xi2/protocol-eventconvert.c
index aea380ed5..ff30bdc35 100644
--- a/test/xi2/protocol-eventconvert.c
+++ b/test/xi2/protocol-eventconvert.c
@@ -33,6 +33,8 @@
#include "inpututils.h"
#include <X11/extensions/XI2proto.h>
+#include "protocol-common.h"
+
static void
test_values_XIRawEvent(RawDeviceEvent *in, xXIRawEvent * out, BOOL swap)
{
diff --git a/test/xi2/protocol-xigetclientpointer.c b/test/xi2/protocol-xigetclientpointer.c
index 570c53e06..394f9f703 100644
--- a/test/xi2/protocol-xigetclientpointer.c
+++ b/test/xi2/protocol-xigetclientpointer.c
@@ -46,24 +46,9 @@ struct {
int win;
} test_data;
-static ClientRec client_window;
+ClientRec client_window;
static ClientRec client_request;
-int
-__wrap_dixLookupClient(ClientPtr *pClient, XID rid, ClientPtr client,
- Mask access)
-{
- if (rid == ROOT_WINDOW_ID)
- return BadWindow;
-
- if (rid == CLIENT_WINDOW_ID) {
- *pClient = &client_window;
- return Success;
- }
-
- return __real_dixLookupClient(pClient, rid, client, access);
-}
-
static void
reply_XIGetClientPointer(ClientPtr client, int len, char *data, void *userdata)
{
diff --git a/test/xi2/protocol-xigetselectedevents.c b/test/xi2/protocol-xigetselectedevents.c
index bedc217b1..c4fae39f5 100644
--- a/test/xi2/protocol-xigetselectedevents.c
+++ b/test/xi2/protocol-xigetselectedevents.c
@@ -60,25 +60,7 @@ struct {
int mask_len;
} test_data;
-/* dixLookupWindow requires a lot of setup not necessary for this test.
- * Simple wrapper that returns either one of the fake root window or the
- * fake client window. If the requested ID is neither of those wanted,
- * return whatever the real dixLookupWindow does.
- */
-int
-__wrap_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access)
-{
- if (id == root.drawable.id) {
- *win = &root;
- return Success;
- }
- else if (id == window.drawable.id) {
- *win = &window;
- return Success;
- }
-
- return __real_dixLookupWindow(win, id, client, access);
-}
+ClientRec client_window;
/* AddResource is called from XISetSEventMask, we don't need this */
Bool
diff --git a/test/xi2/protocol-xipassivegrabdevice.c b/test/xi2/protocol-xipassivegrabdevice.c
index 95d8ebf2b..29ef4322c 100644
--- a/test/xi2/protocol-xipassivegrabdevice.c
+++ b/test/xi2/protocol-xipassivegrabdevice.c
@@ -41,6 +41,7 @@
#include "protocol-common.h"
+ClientRec client_window;
static ClientRec client_request;
#define N_MODS 7
@@ -58,21 +59,6 @@ static void reply_XIPassiveGrabDevice_data(ClientPtr client, int len,
char *data, void *closure);
int
-__wrap_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access)
-{
- if (id == root.drawable.id) {
- *win = &root;
- return Success;
- }
- else if (id == window.drawable.id) {
- *win = &window;
- return Success;
- }
-
- return __real_dixLookupWindow(win, id, client, access);
-}
-
-int
__wrap_GrabButton(ClientPtr client, DeviceIntPtr dev,
DeviceIntPtr modifier_device, int button,
GrabParameters *param, enum InputLevel grabtype,
diff --git a/test/xi2/protocol-xiquerydevice.c b/test/xi2/protocol-xiquerydevice.c
index deef1f180..a07da0442 100644
--- a/test/xi2/protocol-xiquerydevice.c
+++ b/test/xi2/protocol-xiquerydevice.c
@@ -54,6 +54,8 @@ struct test_data {
int num_devices_in_reply;
};
+ClientRec client_window;
+
static void reply_XIQueryDevice_data(ClientPtr client, int len, char *data,
void *closure);
static void reply_XIQueryDevice(ClientPtr client, int len, char *data,
diff --git a/test/xi2/protocol-xiquerypointer.c b/test/xi2/protocol-xiquerypointer.c
index 2bf18fadc..9d3f94562 100644
--- a/test/xi2/protocol-xiquerypointer.c
+++ b/test/xi2/protocol-xiquerypointer.c
@@ -41,6 +41,7 @@
#include "protocol-common.h"
+ClientRec client_window;
static ClientRec client_request;
static void reply_XIQueryPointer_data(ClientPtr client, int len,
char *data, void *closure);
@@ -50,26 +51,6 @@ static struct {
WindowPtr win;
} test_data;
-/* dixLookupWindow requires a lot of setup not necessary for this test.
- * Simple wrapper that returns either one of the fake root window or the
- * fake client window. If the requested ID is neither of those wanted,
- * return whatever the real dixLookupWindow does.
- */
-int
-__wrap_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access)
-{
- if (id == root.drawable.id) {
- *win = &root;
- return Success;
- }
- else if (id == window.drawable.id) {
- *win = &window;
- return Success;
- }
-
- return __real_dixLookupWindow(win, id, client, access);
-}
-
static void
reply_XIQueryPointer(ClientPtr client, int len, char *data, void *closure)
{
diff --git a/test/xi2/protocol-xiqueryversion.c b/test/xi2/protocol-xiqueryversion.c
index 3749b3041..efee156c4 100644
--- a/test/xi2/protocol-xiqueryversion.c
+++ b/test/xi2/protocol-xiqueryversion.c
@@ -58,6 +58,8 @@ struct test_data {
int minor_expected;
};
+ClientRec client_window;
+
static void
reply_XIQueryVersion(ClientPtr client, int len, char *data, void *closure)
{
diff --git a/test/xi2/protocol-xiselectevents.c b/test/xi2/protocol-xiselectevents.c
index 183746f98..575a06611 100644
--- a/test/xi2/protocol-xiselectevents.c
+++ b/test/xi2/protocol-xiselectevents.c
@@ -62,6 +62,8 @@
static unsigned char *data[4096 * 20]; /* the request data buffer */
+ClientRec client_window;
+
int
__wrap_XISetEventMask(DeviceIntPtr dev, WindowPtr win, int len,
unsigned char *mask)
@@ -69,26 +71,6 @@ __wrap_XISetEventMask(DeviceIntPtr dev, WindowPtr win, int len,
return Success;
}
-/* dixLookupWindow requires a lot of setup not necessary for this test.
- * Simple wrapper that returns either one of the fake root window or the
- * fake client window. If the requested ID is neither of those wanted,
- * return whatever the real dixLookupWindow does.
- */
-int
-__wrap_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access)
-{
- if (id == root.drawable.id) {
- *win = &root;
- return Success;
- }
- else if (id == window.drawable.id) {
- *win = &window;
- return Success;
- }
-
- return __real_dixLookupWindow(win, id, client, access);
-}
-
static void
request_XISelectEvent(xXISelectEventsReq * req, int error)
{
diff --git a/test/xi2/protocol-xisetclientpointer.c b/test/xi2/protocol-xisetclientpointer.c
index 90f1b94c3..bd6267d59 100644
--- a/test/xi2/protocol-xisetclientpointer.c
+++ b/test/xi2/protocol-xisetclientpointer.c
@@ -48,24 +48,9 @@
#include "protocol-common.h"
-static ClientRec client_window;
+ClientRec client_window;
static ClientRec client_request;
-int
-__wrap_dixLookupClient(ClientPtr *pClient, XID rid, ClientPtr client,
- Mask access)
-{
- if (rid == ROOT_WINDOW_ID)
- return BadWindow;
-
- if (rid == CLIENT_WINDOW_ID) {
- *pClient = &client_window;
- return Success;
- }
-
- return __real_dixLookupClient(pClient, rid, client, access);
-}
-
static void
request_XISetClientPointer(xXISetClientPointerReq * req, int error)
{
diff --git a/test/xi2/protocol-xiwarppointer.c b/test/xi2/protocol-xiwarppointer.c
index 3aaaae6f9..8483aacd4 100644
--- a/test/xi2/protocol-xiwarppointer.c
+++ b/test/xi2/protocol-xiwarppointer.c
@@ -44,25 +44,7 @@
static int expected_x = SPRITE_X;
static int expected_y = SPRITE_Y;
-/* dixLookupWindow requires a lot of setup not necessary for this test.
- * Simple wrapper that returns either one of the fake root window or the
- * fake client window. If the requested ID is neither of those wanted,
- * return whatever the real dixLookupWindow does.
- */
-int
-__wrap_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access)
-{
- if (id == root.drawable.id) {
- *win = &root;
- return Success;
- }
- else if (id == window.drawable.id) {
- *win = &window;
- return Success;
- }
-
- return __real_dixLookupWindow(win, id, client, access);
-}
+ClientRec client_window;
/**
* This function overrides the one in the screen rec.
diff --git a/test/xi2/xi2.c b/test/xi2/xi2.c
index 1cdad1dbd..070d641af 100644
--- a/test/xi2/xi2.c
+++ b/test/xi2/xi2.c
@@ -30,6 +30,10 @@
#include "inputstr.h"
#include "assert.h"
+#include "protocol-common.h"
+
+ClientRec client_window;
+
static void
xi2mask_test(void)
{