[PATCH v2 xserver 03/10] tests: Convert test/xi2/ to single binary

Mihail Konev k.mvc at ya.ru
Mon Jan 2 18:50:23 UTC 2017


Instead of multiple test binaries, use a single one which executes
a test depending on the command-line argument being passed.

For testsuite, emulate multiple binaries with shell scripts
that pass an appropriate argument.

Speeds up partial rebuild, as each linking takes a noticeable
amount of time, and all of them have to be done for verification
purposes.

Signed-off-by: Mihail Konev <k.mvc at ya.ru>
---
 test/xi2/.gitignore                      |  1 +
 test/xi2/Makefile.am                     | 87 +++++++++++++++-----------------
 test/xi2/common.sh                       |  3 ++
 test/xi2/protocol-common.h               | 12 +++++
 test/xi2/protocol-eventconvert.c         |  2 +-
 test/xi2/protocol-xigetclientpointer.c   |  2 +-
 test/xi2/protocol-xigetselectedevents.c  |  2 +-
 test/xi2/protocol-xipassivegrabdevice.c  |  2 +-
 test/xi2/protocol-xiquerydevice.c        |  2 +-
 test/xi2/protocol-xiquerypointer.c       |  2 +-
 test/xi2/protocol-xiqueryversion.c       |  2 +-
 test/xi2/protocol-xiselectevents.c       |  2 +-
 test/xi2/protocol-xisetclientpointer.c   |  2 +-
 test/xi2/protocol-xiwarppointer.c        |  2 +-
 test/xi2/protocol_eventconvert.sh        |  2 +
 test/xi2/protocol_xigetclientpointer.sh  |  2 +
 test/xi2/protocol_xigetselectedevents.sh |  2 +
 test/xi2/protocol_xipassivegrabdevice.sh |  2 +
 test/xi2/protocol_xiquerydevice.sh       |  2 +
 test/xi2/protocol_xiquerypointer.sh      |  2 +
 test/xi2/protocol_xiqueryversion.sh      |  2 +
 test/xi2/protocol_xiselectevents.sh      |  2 +
 test/xi2/protocol_xisetclientpointer.sh  |  2 +
 test/xi2/protocol_xiwarppointer.sh       |  2 +
 test/xi2/tests.c                         | 24 +++++++++
 test/xi2/xi2.c                           |  2 +-
 test/xi2/xi2.sh                          |  2 +
 27 files changed, 115 insertions(+), 56 deletions(-)
 create mode 100644 test/xi2/common.sh
 create mode 100755 test/xi2/protocol_eventconvert.sh
 create mode 100755 test/xi2/protocol_xigetclientpointer.sh
 create mode 100755 test/xi2/protocol_xigetselectedevents.sh
 create mode 100755 test/xi2/protocol_xipassivegrabdevice.sh
 create mode 100755 test/xi2/protocol_xiquerydevice.sh
 create mode 100755 test/xi2/protocol_xiquerypointer.sh
 create mode 100755 test/xi2/protocol_xiqueryversion.sh
 create mode 100755 test/xi2/protocol_xiselectevents.sh
 create mode 100755 test/xi2/protocol_xisetclientpointer.sh
 create mode 100755 test/xi2/protocol_xiwarppointer.sh
 create mode 100644 test/xi2/tests.c
 create mode 100755 test/xi2/xi2.sh

diff --git a/test/xi2/.gitignore b/test/xi2/.gitignore
index 817aa7b6b83b..53a2d8936272 100644
--- a/test/xi2/.gitignore
+++ b/test/xi2/.gitignore
@@ -9,3 +9,4 @@ protocol-xiselectevents
 protocol-xisetclientpointer
 protocol-xiwarppointer
 xi2
+tests
diff --git a/test/xi2/Makefile.am b/test/xi2/Makefile.am
index 6b9679872b48..1b81eca0ad5e 100644
--- a/test/xi2/Makefile.am
+++ b/test/xi2/Makefile.am
@@ -1,20 +1,24 @@
 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=$(noinst_PROGRAMS)
-TESTS_ENVIRONMENT = $(XORG_MALLOC_DEBUG_ENV)
+TESTS = \
+	protocol_xiqueryversion.sh \
+	protocol_xiquerydevice.sh \
+	protocol_xiselectevents.sh \
+	protocol_xigetselectedevents.sh \
+	protocol_xisetclientpointer.sh \
+	protocol_xigetclientpointer.sh \
+	protocol_xipassivegrabdevice.sh \
+	protocol_xiquerypointer.sh \
+	protocol_xiwarppointer.sh \
+	protocol_eventconvert.sh \
+	xi2.sh
+
+TESTS_ENVIRONMENT = \
+	$(XORG_MALLOC_DEBUG_ENV) \
+	srcdir=$(srcdir) \
+	$()
 
 AM_CFLAGS = $(DIX_CFLAGS) @XORG_CFLAGS@
 AM_CPPFLAGS = @XORG_INCS@
@@ -26,39 +30,32 @@ if SPECIAL_DTRACE_OBJECTS
 TEST_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_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 = \
+	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 \
+	protocol-common.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/common.sh b/test/xi2/common.sh
new file mode 100644
index 000000000000..892028d9a585
--- /dev/null
+++ b/test/xi2/common.sh
@@ -0,0 +1,3 @@
+testname=${0%.sh}
+testname=${testname##*/}
+exec ./tests "$testname"
diff --git a/test/xi2/protocol-common.h b/test/xi2/protocol-common.h
index f8504787f790..ba6cf565262c 100644
--- a/test/xi2/protocol-common.h
+++ b/test/xi2/protocol-common.h
@@ -152,4 +152,16 @@ Bool __wrap_AddResource(XID id, RESTYPE type, void *value);
 int __wrap_dixLookupClient(ClientPtr *c, XID id, ClientPtr client, Mask access);
 int __real_dixLookupClient(ClientPtr *c, XID id, ClientPtr client, Mask access);
 
+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);
+
 #endif                          /* PROTOCOL_COMMON_H */
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..4fe7b7cb24fb 100644
--- a/test/xi2/protocol-xigetselectedevents.c
+++ b/test/xi2/protocol-xigetselectedevents.c
@@ -206,7 +206,7 @@ test_XIGetSelectedEvents(void)
 }
 
 int
-main(int argc, char **argv)
+protocol_xigetselectedevents_test(void)
 {
     init_simple();
 
diff --git a/test/xi2/protocol-xipassivegrabdevice.c b/test/xi2/protocol-xipassivegrabdevice.c
index 29ef4322c8fd..f6aead4f7bed 100644
--- a/test/xi2/protocol-xipassivegrabdevice.c
+++ b/test/xi2/protocol-xipassivegrabdevice.c
@@ -238,7 +238,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..bc6745860798 100644
--- a/test/xi2/protocol-xiselectevents.c
+++ b/test/xi2/protocol-xiselectevents.c
@@ -324,7 +324,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/protocol_eventconvert.sh b/test/xi2/protocol_eventconvert.sh
new file mode 100755
index 000000000000..dd9106615e6a
--- /dev/null
+++ b/test/xi2/protocol_eventconvert.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+. $srcdir/common.sh
diff --git a/test/xi2/protocol_xigetclientpointer.sh b/test/xi2/protocol_xigetclientpointer.sh
new file mode 100755
index 000000000000..dd9106615e6a
--- /dev/null
+++ b/test/xi2/protocol_xigetclientpointer.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+. $srcdir/common.sh
diff --git a/test/xi2/protocol_xigetselectedevents.sh b/test/xi2/protocol_xigetselectedevents.sh
new file mode 100755
index 000000000000..dd9106615e6a
--- /dev/null
+++ b/test/xi2/protocol_xigetselectedevents.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+. $srcdir/common.sh
diff --git a/test/xi2/protocol_xipassivegrabdevice.sh b/test/xi2/protocol_xipassivegrabdevice.sh
new file mode 100755
index 000000000000..dd9106615e6a
--- /dev/null
+++ b/test/xi2/protocol_xipassivegrabdevice.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+. $srcdir/common.sh
diff --git a/test/xi2/protocol_xiquerydevice.sh b/test/xi2/protocol_xiquerydevice.sh
new file mode 100755
index 000000000000..dd9106615e6a
--- /dev/null
+++ b/test/xi2/protocol_xiquerydevice.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+. $srcdir/common.sh
diff --git a/test/xi2/protocol_xiquerypointer.sh b/test/xi2/protocol_xiquerypointer.sh
new file mode 100755
index 000000000000..dd9106615e6a
--- /dev/null
+++ b/test/xi2/protocol_xiquerypointer.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+. $srcdir/common.sh
diff --git a/test/xi2/protocol_xiqueryversion.sh b/test/xi2/protocol_xiqueryversion.sh
new file mode 100755
index 000000000000..dd9106615e6a
--- /dev/null
+++ b/test/xi2/protocol_xiqueryversion.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+. $srcdir/common.sh
diff --git a/test/xi2/protocol_xiselectevents.sh b/test/xi2/protocol_xiselectevents.sh
new file mode 100755
index 000000000000..dd9106615e6a
--- /dev/null
+++ b/test/xi2/protocol_xiselectevents.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+. $srcdir/common.sh
diff --git a/test/xi2/protocol_xisetclientpointer.sh b/test/xi2/protocol_xisetclientpointer.sh
new file mode 100755
index 000000000000..dd9106615e6a
--- /dev/null
+++ b/test/xi2/protocol_xisetclientpointer.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+. $srcdir/common.sh
diff --git a/test/xi2/protocol_xiwarppointer.sh b/test/xi2/protocol_xiwarppointer.sh
new file mode 100755
index 000000000000..dd9106615e6a
--- /dev/null
+++ b/test/xi2/protocol_xiwarppointer.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+. $srcdir/common.sh
diff --git a/test/xi2/tests.c b/test/xi2/tests.c
new file mode 100644
index 000000000000..0c20c1e62187
--- /dev/null
+++ b/test/xi2/tests.c
@@ -0,0 +1,24 @@
+#include <string.h>
+
+#include "protocol-common.h"
+
+int main(int argc, char **argv) {
+    if (argc < 2) { return 1; }
+
+#define try_command(func) \
+    if (strcmp(argv[1], #func) == 0) { return func ## _test (); };
+
+    try_command(protocol_xiqueryversion);
+    try_command(protocol_xiquerydevice);
+    try_command(protocol_xiselectevents);
+    try_command(protocol_xigetselectedevents);
+    try_command(protocol_xisetclientpointer);
+    try_command(protocol_xigetclientpointer);
+    try_command(protocol_xipassivegrabdevice);
+    try_command(protocol_xiquerypointer);
+    try_command(protocol_xiwarppointer);
+    try_command(protocol_eventconvert);
+    try_command(xi2);
+
+    return 1;
+}
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();
 
diff --git a/test/xi2/xi2.sh b/test/xi2/xi2.sh
new file mode 100755
index 000000000000..dd9106615e6a
--- /dev/null
+++ b/test/xi2/xi2.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+. $srcdir/common.sh
-- 
2.9.2



More information about the xorg-devel mailing list