[PATCH xserver 3/6] tests: Convert test/xi2/ to single binary

Peter Hutterer peter.hutterer at who-t.net
Mon Jan 9 03:29:17 UTC 2017


On Wed, Jan 04, 2017 at 11:31:41AM +0500, Mihail Konev wrote:
> Part of refactoring the tests into a single binary,
> to make partial rebuild slightly faster and less verbose.
> 
> Signed-off-by: Mihail Konev <k.mvc at ya.ru>
> ---
>  test/tests.h                            | 19 ++++++++
>  test/xi2/.gitignore                     | 12 +----
>  test/xi2/Makefile.am                    | 84 +++++++++++++--------------------
>  test/xi2/protocol-common.c              |  4 ++
>  test/xi2/protocol-eventconvert.c        |  2 +-
>  test/xi2/protocol-xigetclientpointer.c  |  2 +-
>  test/xi2/protocol-xigetselectedevents.c |  4 +-
>  test/xi2/protocol-xipassivegrabdevice.c |  9 +++-
>  test/xi2/protocol-xiquerydevice.c       |  2 +-
>  test/xi2/protocol-xiquerypointer.c      |  2 +-
>  test/xi2/protocol-xiqueryversion.c      |  2 +-
>  test/xi2/protocol-xiselectevents.c      |  9 +++-
>  test/xi2/protocol-xisetclientpointer.c  |  2 +-
>  test/xi2/protocol-xiwarppointer.c       |  2 +-
>  test/xi2/tests.c                        | 21 +++++++++
>  test/xi2/xi2.c                          |  2 +-
>  16 files changed, 106 insertions(+), 72 deletions(-)
>  create mode 100644 test/xi2/tests.c
> 
> diff --git a/test/tests.h b/test/tests.h
> index 8a42aa0da592..0b673ee7ae79 100644
> --- a/test/tests.h
> +++ b/test/tests.h
> @@ -3,5 +3,24 @@
>  
>  int protocol_xchangedevicecontrol_test(void);
>  
> +int protocol_xiqueryversion_test(void);
> +int protocol_xiquerydevice_test(void);
> +int protocol_xiselectevents_test(void);
> +int protocol_xigetselectedevents_test(void);
> +int protocol_xisetclientpointer_test(void);
> +int protocol_xigetclientpointer_test(void);
> +int protocol_xipassivegrabdevice_test(void);
> +int protocol_xiquerypointer_test(void);
> +int protocol_xiwarppointer_test(void);
> +int protocol_eventconvert_test(void);
> +int xi2_test(void);
> +
> +#ifndef INSIDE_PROTOCOL_COMMON
> +
> +extern int enable_XISetEventMask_wrap;
> +extern int enable_GrabButton_wrap;
> +
> +#endif /* INSIDE_PROTOCOL_COMMON */

something tells me this woudl be nicer solved by just having a header that
applies to all tests vs a header that applies to the protocol-common bits
only. Would be nice as follow-up.

Unfortunately, this breaks make check.

_XSERVTransSocketUNIXCreateListener: ...SocketCreateListener() failed
_XSERVTransMakeAllCOTSServerListeners: server already running
XTEST_DIR must be set to the directory of the xtest repository.
SKIP scripts/xephyr-glamor-piglit.sh (exit status: 77)

1/6 still passes it but 2/6 doesn't build, so it's one of those two patches.
Please fix this and re-send the series (with a v3 subjectprefix). Test suite
failures really shouldn't happen during a test suite refactoring, that's the
one time all the attention is on the test suite ;)

Cheers,
   Peter

> +
>  #endif /* TESTS_H */
>  
> diff --git a/test/xi2/.gitignore b/test/xi2/.gitignore
> index 817aa7b6b83b..2b29f27645f8 100644
> --- a/test/xi2/.gitignore
> +++ b/test/xi2/.gitignore
> @@ -1,11 +1 @@
> -protocol-eventconvert
> -protocol-xigetclientpointer
> -protocol-xigetselectedevents
> -protocol-xipassivegrabdevice
> -protocol-xiquerydevice
> -protocol-xiquerypointer
> -protocol-xiqueryversion
> -protocol-xiselectevents
> -protocol-xisetclientpointer
> -protocol-xiwarppointer
> -xi2
> +tests
> diff --git a/test/xi2/Makefile.am b/test/xi2/Makefile.am
> index 6b9679872b48..a7f9831a93cd 100644
> --- a/test/xi2/Makefile.am
> +++ b/test/xi2/Makefile.am
> @@ -1,64 +1,48 @@
>  if ENABLE_UNIT_TESTS
>  if HAVE_LD_WRAP
> -noinst_PROGRAMS =  \
> -	protocol-xiqueryversion \
> -	protocol-xiquerydevice \
> -	protocol-xiselectevents \
> -	protocol-xigetselectedevents \
> -        protocol-xisetclientpointer \
> -        protocol-xigetclientpointer \
> -        protocol-xipassivegrabdevice \
> -        protocol-xiquerypointer \
> -        protocol-xiwarppointer \
> -        protocol-eventconvert \
> -        xi2
> +noinst_PROGRAMS = tests
> +
> +TESTS = tests
>  
> -TESTS=$(noinst_PROGRAMS)
>  TESTS_ENVIRONMENT = $(XORG_MALLOC_DEBUG_ENV)
>  
> -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_LDFLAGS= -Wl,-wrap,dixLookupWindow -Wl,-wrap,dixLookupClient
> +tests_CFLAGS = $(DIX_CFLAGS) @XORG_CFLAGS@
> +
> +tests_CPPFLAGS = \
> +	@XORG_INCS@ \
> +	-I$(srcdir)/..
> +
> +tests_LDADD = ../libxservertest.la $(XORG_SYS_LIBS) $(XSERVER_SYS_LIBS) $(GLX_SYS_LIBS)
>  
>  if SPECIAL_DTRACE_OBJECTS
> -TEST_LDADD += $(OS_LIB) $(DIX_LIB)
> +tests_LDADD += $(OS_LIB) $(DIX_LIB)
>  endif
>  
> -protocol_xiqueryversion_LDADD=$(TEST_LDADD)
> -protocol_xiquerydevice_LDADD=$(TEST_LDADD)
> -protocol_xiselectevents_LDADD=$(TEST_LDADD)
> -protocol_xigetselectedevents_LDADD=$(TEST_LDADD)
> -protocol_xisetclientpointer_LDADD=$(TEST_LDADD)
> -protocol_xigetclientpointer_LDADD=$(TEST_LDADD)
> -protocol_xiquerypointer_LDADD=$(TEST_LDADD)
> -protocol_xipassivegrabdevice_LDADD=$(TEST_LDADD)
> -protocol_xiwarppointer_LDADD=$(TEST_LDADD)
> -protocol_eventconvert_LDADD=$(TEST_LDADD)
> -xi2_LDADD=$(TEST_LDADD)
> +tests_LDFLAGS = \
> +        -Wl,-wrap,WriteToClient \
> +        -Wl,-wrap,dixLookupWindow \
> +        -Wl,-wrap,XISetEventMask \
> +        -Wl,-wrap,AddResource \
> +        -Wl,-wrap,GrabButton \
> +        -Wl,-wrap,dixLookupClient \
> +        $()
>  
> -protocol_xiqueryversion_LDFLAGS=$(COMMON_LDFLAGS) -Wl,-wrap,WriteToClient
> -protocol_xiquerydevice_LDFLAGS=$(COMMON_LDFLAGS) -Wl,-wrap,WriteToClient
> -protocol_xiselectevents_LDFLAGS=$(COMMON_LDFLAGS) -Wl,-wrap,XISetEventMask
> -protocol_xigetselectedevents_LDFLAGS=$(COMMON_LDFLAGS) -Wl,-wrap,WriteToClient -Wl,-wrap,AddResource
> -protocol_xisetclientpointer_LDFLAGS=$(COMMON_LDFLAGS) -Wl,-wrap,dixLookupClient
> -protocol_xigetclientpointer_LDFLAGS=$(COMMON_LDFLAGS) -Wl,-wrap,WriteToClient -Wl,-wrap,dixLookupClient
> -protocol_xipassivegrabdevice_LDFLAGS=$(COMMON_LDFLAGS) -Wl,-wrap,WriteToClient -Wl,-wrap,GrabButton
> -protocol_xiquerypointer_LDFLAGS=$(COMMON_LDFLAGS) -Wl,-wrap,WriteToClient
> -protocol_xiwarppointer_LDFLAGS=$(COMMON_LDFLAGS) -Wl,-wrap,WriteToClient
> -xi2_LDFLAGS=$(COMMON_LDFLAGS)
> +tests_SOURCES = \
> +	$(srcdir)/../tests-common.c \
> +	protocol-common.c \
> +	protocol-xiqueryversion.c \
> +	protocol-xiquerydevice.c \
> +	protocol-xiselectevents.c \
> +	protocol-xigetselectedevents.c \
> +	protocol-xisetclientpointer.c \
> +	protocol-xigetclientpointer.c \
> +	protocol-xiquerypointer.c \
> +	protocol-xipassivegrabdevice.c \
> +	protocol-xiwarppointer.c \
> +	protocol-eventconvert.c \
> +	xi2.c \
> +	tests.c
>  
> -protocol_xiqueryversion_SOURCES=$(COMMON_SOURCES) protocol-xiqueryversion.c
> -protocol_xiquerydevice_SOURCES=$(COMMON_SOURCES) protocol-xiquerydevice.c
> -protocol_xiselectevents_SOURCES=$(COMMON_SOURCES) protocol-xiselectevents.c
> -protocol_xigetselectedevents_SOURCES=$(COMMON_SOURCES) protocol-xigetselectedevents.c
> -protocol_xisetclientpointer_SOURCES=$(COMMON_SOURCES) protocol-xisetclientpointer.c
> -protocol_xigetclientpointer_SOURCES=$(COMMON_SOURCES) protocol-xigetclientpointer.c
> -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 d30593a13af9..b91692f551ca 100644
> --- a/test/xi2/protocol-common.c
> +++ b/test/xi2/protocol-common.c
> @@ -34,6 +34,7 @@
>  #include "syncsrv.h"
>  #include <X11/extensions/XI2.h>
>  
> +#define INSIDE_PROTOCOL_COMMON
>  #include "protocol-common.h"

this seems odd: we have a #define here but the only thing it does is declare
two externs at the bottom of the header file. Can't we just move those
extern int here? Skips the ifdefs and makes the code cleaner.

>  
>  struct devices devices;
> @@ -44,6 +45,9 @@ static ClientRec server_client;
>  
>  void *global_userdata;
>  
> +int enable_GrabButton_wrap = 1;
> +int enable_XISetEventMask_wrap = 1;
> +
>  static void
>  fake_init_sprite(DeviceIntPtr dev)
>  {
> diff --git a/test/xi2/protocol-eventconvert.c b/test/xi2/protocol-eventconvert.c
> index ff30bdc352c1..8d19d53399a1 100644
> --- a/test/xi2/protocol-eventconvert.c
> +++ b/test/xi2/protocol-eventconvert.c
> @@ -1202,7 +1202,7 @@ test_convert_XIBarrierEvent(void)
>  }
>  
>  int
> -main(int argc, char **argv)
> +protocol_eventconvert_test(void)
>  {
>      test_convert_XIRawEvent();
>      test_convert_XIFocusEvent();
> diff --git a/test/xi2/protocol-xigetclientpointer.c b/test/xi2/protocol-xigetclientpointer.c
> index 394f9f703078..f0c27b933015 100644
> --- a/test/xi2/protocol-xigetclientpointer.c
> +++ b/test/xi2/protocol-xigetclientpointer.c
> @@ -142,7 +142,7 @@ test_XIGetClientPointer(void)
>  }
>  
>  int
> -main(int argc, char **argv)
> +protocol_xigetclientpointer_test(void)
>  {
>      init_simple();
>      client_window = init_client(0, NULL);
> diff --git a/test/xi2/protocol-xigetselectedevents.c b/test/xi2/protocol-xigetselectedevents.c
> index c4fae39f545e..3a7f3641f53d 100644
> --- a/test/xi2/protocol-xigetselectedevents.c
> +++ b/test/xi2/protocol-xigetselectedevents.c
> @@ -206,9 +206,11 @@ test_XIGetSelectedEvents(void)
>  }
>  
>  int
> -main(int argc, char **argv)
> +protocol_xigetselectedevents_test(void)
>  {
>      init_simple();
> +    enable_GrabButton_wrap = 0;
> +    enable_XISetEventMask_wrap = 0;
>  
>      test_XIGetSelectedEvents();
>  
> diff --git a/test/xi2/protocol-xipassivegrabdevice.c b/test/xi2/protocol-xipassivegrabdevice.c
> index 29ef4322c8fd..db7e6abf760f 100644
> --- a/test/xi2/protocol-xipassivegrabdevice.c
> +++ b/test/xi2/protocol-xipassivegrabdevice.c
> @@ -55,6 +55,10 @@ int __wrap_GrabButton(ClientPtr client, DeviceIntPtr dev,
>                        DeviceIntPtr modifier_device, int button,
>                        GrabParameters *param, enum InputLevel grabtype,
>                        GrabMask *mask);
> +int __real_GrabButton(ClientPtr client, DeviceIntPtr dev,
> +                      DeviceIntPtr modifier_device, int button,
> +                      GrabParameters *param, enum InputLevel grabtype,
> +                      GrabMask *mask);
>  static void reply_XIPassiveGrabDevice_data(ClientPtr client, int len,
>                                             char *data, void *closure);
>  
> @@ -64,6 +68,9 @@ __wrap_GrabButton(ClientPtr client, DeviceIntPtr dev,
>                    GrabParameters *param, enum InputLevel grabtype,
>                    GrabMask *mask)
>  {
> +    if (!enable_GrabButton_wrap)
> +        __real_GrabButton(client, dev, modifier_device, button, param, grabtype, mask);
> +
>      /* Fail every odd modifier */
>      if (param->modifiers % 2)
>          return BadAccess;
> @@ -238,7 +245,7 @@ test_XIPassiveGrabDevice(void)
>  }
>  
>  int
> -main(int argc, char **argv)
> +protocol_xipassivegrabdevice_test(void)
>  {
>      init_simple();
>  
> diff --git a/test/xi2/protocol-xiquerydevice.c b/test/xi2/protocol-xiquerydevice.c
> index a07da0442387..a068038fd386 100644
> --- a/test/xi2/protocol-xiquerydevice.c
> +++ b/test/xi2/protocol-xiquerydevice.c
> @@ -335,7 +335,7 @@ test_XIQueryDevice(void)
>  }
>  
>  int
> -main(int argc, char **argv)
> +protocol_xiquerydevice_test(void)
>  {
>      init_simple();
>  
> diff --git a/test/xi2/protocol-xiquerypointer.c b/test/xi2/protocol-xiquerypointer.c
> index 9d3f945627dd..ed75d791016f 100644
> --- a/test/xi2/protocol-xiquerypointer.c
> +++ b/test/xi2/protocol-xiquerypointer.c
> @@ -190,7 +190,7 @@ test_XIQueryPointer(void)
>  }
>  
>  int
> -main(int argc, char **argv)
> +protocol_xiquerypointer_test(void)
>  {
>      init_simple();
>  
> diff --git a/test/xi2/protocol-xiqueryversion.c b/test/xi2/protocol-xiqueryversion.c
> index efee156c42fb..3ce758faaee2 100644
> --- a/test/xi2/protocol-xiqueryversion.c
> +++ b/test/xi2/protocol-xiqueryversion.c
> @@ -288,7 +288,7 @@ test_XIQueryVersion_multiple(void)
>  }
>  
>  int
> -main(int argc, char **argv)
> +protocol_xiqueryversion_test(void)
>  {
>      init_simple();
>  
> diff --git a/test/xi2/protocol-xiselectevents.c b/test/xi2/protocol-xiselectevents.c
> index 575a06611bd8..686e7d394fc4 100644
> --- a/test/xi2/protocol-xiselectevents.c
> +++ b/test/xi2/protocol-xiselectevents.c
> @@ -65,9 +65,16 @@ static unsigned char *data[4096 * 20];  /* the request data buffer */
>  ClientRec client_window;
>  
>  int
> +__real_XISetEventMask(DeviceIntPtr dev, WindowPtr win, int len,
> +                      unsigned char *mask);
> +
> +int
>  __wrap_XISetEventMask(DeviceIntPtr dev, WindowPtr win, int len,
>                        unsigned char *mask)
>  {
> +    if (!enable_XISetEventMask_wrap)
> +        return __real_XISetEventMask(dev, win, len, mask);
> +
>      return Success;
>  }
>  
> @@ -324,7 +331,7 @@ test_XISelectEvents(void)
>  }
>  
>  int
> -main(int argc, char **argv)
> +protocol_xiselectevents_test(void)
>  {
>      init_simple();
>  
> diff --git a/test/xi2/protocol-xisetclientpointer.c b/test/xi2/protocol-xisetclientpointer.c
> index bd6267d59633..6584bb9cc43a 100644
> --- a/test/xi2/protocol-xisetclientpointer.c
> +++ b/test/xi2/protocol-xisetclientpointer.c
> @@ -122,7 +122,7 @@ test_XISetClientPointer(void)
>  }
>  
>  int
> -main(int argc, char **argv)
> +protocol_xisetclientpointer_test(void)
>  {
>      init_simple();
>      client_window = init_client(0, NULL);
> diff --git a/test/xi2/protocol-xiwarppointer.c b/test/xi2/protocol-xiwarppointer.c
> index 8483aacd4708..8484d54e54d7 100644
> --- a/test/xi2/protocol-xiwarppointer.c
> +++ b/test/xi2/protocol-xiwarppointer.c
> @@ -186,7 +186,7 @@ test_XIWarpPointer(void)
>  }
>  
>  int
> -main(int argc, char **argv)
> +protocol_xiwarppointer_test(void)
>  {
>      init_simple();
>      screen.SetCursorPosition = ScreenSetCursorPosition;
> diff --git a/test/xi2/tests.c b/test/xi2/tests.c
> new file mode 100644
> index 000000000000..559fb23ed1d4
> --- /dev/null
> +++ b/test/xi2/tests.c
> @@ -0,0 +1,21 @@
> +#include "tests.h"
> +#include "tests-common.h"
> +#include "protocol-common.h"
> +
> +int
> +main(int argc, char **argv)
> +{
> +    run_test(protocol_xiqueryversion_test);
> +    run_test(protocol_xiquerydevice_test);
> +    run_test(protocol_xiselectevents_test);
> +    run_test(protocol_xigetselectedevents_test);
> +    run_test(protocol_xisetclientpointer_test);
> +    run_test(protocol_xigetclientpointer_test);
> +    run_test(protocol_xipassivegrabdevice_test);
> +    run_test(protocol_xiquerypointer_test);
> +    run_test(protocol_xiwarppointer_test);
> +    run_test(protocol_eventconvert_test);
> +    run_test(xi2_test);
> +
> +    return 0;
> +}
> diff --git a/test/xi2/xi2.c b/test/xi2/xi2.c
> index 070d641af4a8..6ed4c7f4fb9d 100644
> --- a/test/xi2/xi2.c
> +++ b/test/xi2/xi2.c
> @@ -137,7 +137,7 @@ xi2mask_test(void)
>  }
>  
>  int
> -main(int argc, char **argv)
> +xi2_test(void)
>  {
>      xi2mask_test();
>  
> -- 
> 2.9.2
> 


More information about the xorg-devel mailing list