[PATCH xserver 02/10] tests: Convert test/xi1/ to single binary

Mihail Konev k.mvc at ya.ru
Fri Dec 30 08:30:53 UTC 2016


While there is no functional change, it prepares for joining
makefiles under test/ into a single one.

Signed-off-by: Mihail Konev <k.mvc at ya.ru>
---
 test/xi1/Makefile.am                      | 38 +++++++++++++++++++------------
 test/xi1/common.sh                        |  3 +++
 test/xi1/protocol-xchangedevicecontrol.c  |  3 ++-
 test/xi1/protocol_xchangedevicecontrol.sh |  2 ++
 test/xi1/tests.c                          | 13 +++++++++++
 test/xi1/tests.h                          |  7 ++++++
 6 files changed, 50 insertions(+), 16 deletions(-)
 create mode 100644 test/xi1/common.sh
 create mode 100755 test/xi1/protocol_xchangedevicecontrol.sh
 create mode 100644 test/xi1/tests.c
 create mode 100644 test/xi1/tests.h

diff --git a/test/xi1/Makefile.am b/test/xi1/Makefile.am
index 813241c0aeed..a53b3f7b0230 100644
--- a/test/xi1/Makefile.am
+++ b/test/xi1/Makefile.am
@@ -1,26 +1,34 @@
 if ENABLE_UNIT_TESTS
 if HAVE_LD_WRAP
-noinst_PROGRAMS =  \
-	protocol-xchangedevicecontrol
+noinst_PROGRAMS = tests
 
-TESTS=$(noinst_PROGRAMS)
-TESTS_ENVIRONMENT = $(XORG_MALLOC_DEBUG_ENV)
+TESTS = \
+	protocol_xchangedevicecontrol.sh \
+	$()
 
-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_LDFLAGS= -Wl,-wrap,dixLookupWindow -Wl,-wrap,dixLookupClient
+TESTS_ENVIRONMENT = \
+	$(XORG_MALLOC_DEBUG_ENV) \
+	srcdir=$(srcdir) \
+	$()
 
-if SPECIAL_DTRACE_OBJECTS
-TEST_LDADD += $(OS_LIB) $(DIX_LIB)
-endif
+tests_CFLAGS = $(DIX_CFLAGS) @XORG_CFLAGS@
+tests_CPPFLAGS = @XORG_INCS@ -I$(srcdir)/../xi2
+tests_LDFLAGS = \
+	-Wl,-wrap,dixLookupWindow \
+	-Wl,-wrap,dixLookupClient \
+	-Wl,-wrap,WriteToClient \
+	$()
 
-protocol_xchangedevicecontrol_LDADD=$(TEST_LDADD)
+tests_LDADD =../libxservertest.la $(XORG_SYS_LIBS) $(XSERVER_SYS_LIBS) $(GLX_SYS_LIBS)
 
-protocol_xchangedevicecontrol_LDFLAGS=$(COMMON_LDFLAGS) -Wl,-wrap,WriteToClient
+tests_SOURCES = \
+	$(srcdir)/../xi2/protocol-common.c \
+	protocol-xchangedevicecontrol.c \
+	tests.c
 
-protocol_xchangedevicecontrol_SOURCES=$(COMMON_SOURCES) protocol-xchangedevicecontrol.c
+if SPECIAL_DTRACE_OBJECTS
+tests_LDADD += $(OS_LIB) $(DIX_LIB)
+endif
 
 else
 # Print that xi1-tests were skipped (exit code 77 for automake test harness)
diff --git a/test/xi1/common.sh b/test/xi1/common.sh
new file mode 100644
index 000000000000..892028d9a585
--- /dev/null
+++ b/test/xi1/common.sh
@@ -0,0 +1,3 @@
+testname=${0%.sh}
+testname=${testname##*/}
+exec ./tests "$testname"
diff --git a/test/xi1/protocol-xchangedevicecontrol.c b/test/xi1/protocol-xchangedevicecontrol.c
index 64d2ca29bb95..0e4ce2a38093 100644
--- a/test/xi1/protocol-xchangedevicecontrol.c
+++ b/test/xi1/protocol-xchangedevicecontrol.c
@@ -36,6 +36,7 @@
 #include "chgdctl.h"
 
 #include "protocol-common.h"
+#include "tests.h"
 
 ClientRec client_window;
 static ClientRec client_request;
@@ -113,7 +114,7 @@ test_ChangeDeviceControl(void)
 }
 
 int
-main(int argc, char **argv)
+protocol_xchangedevicecontrol_test(void)
 {
     init_simple();
 
diff --git a/test/xi1/protocol_xchangedevicecontrol.sh b/test/xi1/protocol_xchangedevicecontrol.sh
new file mode 100755
index 000000000000..dd9106615e6a
--- /dev/null
+++ b/test/xi1/protocol_xchangedevicecontrol.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+. $srcdir/common.sh
diff --git a/test/xi1/tests.c b/test/xi1/tests.c
new file mode 100644
index 000000000000..eee5bba191a7
--- /dev/null
+++ b/test/xi1/tests.c
@@ -0,0 +1,13 @@
+#include <string.h>
+#include "tests.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_xchangedevicecontrol);
+
+    return 1;
+}
diff --git a/test/xi1/tests.h b/test/xi1/tests.h
new file mode 100644
index 000000000000..8a42aa0da592
--- /dev/null
+++ b/test/xi1/tests.h
@@ -0,0 +1,7 @@
+#ifndef TESTS_H
+#define TESTS_H
+
+int protocol_xchangedevicecontrol_test(void);
+
+#endif /* TESTS_H */
+
-- 
2.9.2



More information about the xorg-devel mailing list