From c20597919cd35b513e7a8eb2fa59cb0cec900606 Mon Sep 17 00:00:00 2001
From: Simon McVittie <smcv@debian.org>
Date: Mon, 22 Jan 2018 17:52:55 +0000
Subject: [PATCH] Move tests for dbus-gmain to dbus-gmain/tests/

Use dbus-run-session to run the only one that can be used as an
automated test right now.

Signed-off-by: Simon McVittie <smcv@debian.org>
---
 configure.ac                                  |  5 +-
 dbus-gmain/Makefile.am                        | 59 ++++++++++++++++++-
 {test/core => dbus-gmain/tests}/30574.c       |  2 +-
 .../tests}/test-thread-client.c               |  0
 .../tests}/test-thread-server.c               |  0
 {test/core => dbus-gmain/tests}/test-thread.h |  0
 {test/lib => dbus-gmain/tests}/util.c         |  0
 {test/lib => dbus-gmain/tests}/util.h         |  0
 test/Makefile.am                              |  4 +-
 test/core/Makefile.am                         | 38 +-----------
 test/core/peer-on-bus.c                       |  2 +-
 test/core/registrations.c                     |  2 +-
 test/core/run-test.sh                         |  1 -
 test/core/test-dbus-glib.c                    |  2 +-
 test/core/test-variant-recursion.c            |  2 +-
 test/interfaces/Makefile.am                   |  2 +-
 test/interfaces/test-client.c                 |  2 +-
 test/lib/Makefile.am                          | 19 ------
 18 files changed, 73 insertions(+), 67 deletions(-)
 rename {test/core => dbus-gmain/tests}/30574.c (99%)
 rename {test/core => dbus-gmain/tests}/test-thread-client.c (100%)
 rename {test/core => dbus-gmain/tests}/test-thread-server.c (100%)
 rename {test/core => dbus-gmain/tests}/test-thread.h (100%)
 rename {test/lib => dbus-gmain/tests}/util.c (100%)
 rename {test/lib => dbus-gmain/tests}/util.h (100%)
 delete mode 100644 test/lib/Makefile.am

diff --git a/configure.ac b/configure.ac
index 2cdee951..bd97d74c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -278,6 +278,10 @@ DBUS_GLIB_TOOL_LIBS="$XML_LIBS"
 AC_SUBST(DBUS_GLIB_TOOL_CFLAGS)
 AC_SUBST(DBUS_GLIB_TOOL_LIBS)
 
+AC_ARG_VAR([DBUS_RUN_SESSION],
+  [The dbus-run-session tool from dbus 1.8 or later])
+AC_PATH_PROG([DBUS_RUN_SESSION], [dbus-run-session], [dbus-run-session])
+
 ### gtk-doc Documentation
 GTK_DOC_CHECK([1.14], [--flavour no-tmpl])
 
@@ -297,7 +301,6 @@ test/interfaces/Makefile
 test/data/valid-service-files/debug-glib.service
 test/data/valid-service-files/debug-echo.service
 test/data/valid-service-files/interfaces-test.service
-test/lib/Makefile
 tools/Makefile
 dbus-glib-1.pc
 dbus-glib-1-uninstalled.pc
diff --git a/dbus-gmain/Makefile.am b/dbus-gmain/Makefile.am
index 4b4291e2..1863a1fb 100644
--- a/dbus-gmain/Makefile.am
+++ b/dbus-gmain/Makefile.am
@@ -5,7 +5,10 @@ AM_CPPFLAGS = \
 	$(DBUS_GLIB_CFLAGS) \
 	$(NULL)
 
-noinst_LTLIBRARIES = libdbus-gmain.la
+noinst_LTLIBRARIES = \
+	libdbus-gmain.la \
+	tests/libtest.la \
+	$(NULL)
 
 libdbus_gmain_la_SOURCES = \
 	dbus-gmain.c \
@@ -14,3 +17,57 @@ libdbus_gmain_la_SOURCES = \
 
 libdbus_gmain_la_LIBADD = $(DBUS_LIBS) $(DBUS_GLIB_LIBS)
 libdbus_gmain_la_LDFLAGS = -no-undefined
+
+tests_libtest_la_SOURCES = \
+	tests/util.c \
+	tests/util.h \
+	$(NULL)
+
+tests_libtest_la_LIBADD = $(DBUS_LIBS) $(DBUS_GLIB_LIBS)
+tests_libtest_la_LDFLAGS = -no-undefined
+
+TESTS = \
+	tests/test-30574 \
+	$(NULL)
+
+noinst_PROGRAMS = \
+	tests/test-30574 \
+	tests/test-thread-server \
+	tests/test-thread-client \
+	$(NULL)
+
+tests_test_thread_server_SOURCES = \
+	tests/test-thread-server.c \
+	tests/test-thread.h \
+	$(NULL)
+tests_test_thread_server_LDADD = \
+	libdbus-gmain.la \
+	tests/libtest.la \
+	$(DBUS_GLIB_THREADS_LIBS) \
+	$(DBUS_GLIB_LIBS) \
+	$(DBUS_LIBS) \
+	$(NULL)
+
+tests_test_thread_client_SOURCES = \
+	tests/test-thread-client.c \
+	tests/test-thread.h \
+	$(NULL)
+tests_test_thread_client_LDADD = \
+	libdbus-gmain.la \
+	tests/libtest.la \
+	$(DBUS_GLIB_THREADS_LIBS) \
+	$(DBUS_GLIB_LIBS) \
+	$(DBUS_LIBS) \
+	$(NULL)
+
+tests_test_30574_SOURCES = \
+	tests/30574.c \
+	$(NULL)
+tests_test_30574_LDADD = \
+	libdbus-gmain.la \
+	tests/libtest.la \
+	$(DBUS_GLIB_LIBS) \
+	$(DBUS_LIBS) \
+	$(NULL)
+
+LOG_COMPILER = $(DBUS_RUN_SESSION) --
diff --git a/test/core/30574.c b/dbus-gmain/tests/30574.c
similarity index 99%
rename from test/core/30574.c
rename to dbus-gmain/tests/30574.c
index 6fa1c88d..3c7e1094 100644
--- a/test/core/30574.c
+++ b/dbus-gmain/tests/30574.c
@@ -5,7 +5,7 @@
 #include <dbus/dbus.h>
 #include <glib.h>
 #include <dbus-gmain/dbus-gmain.h>
-#include "test/lib/util.h"
+#include "util.h"
 
 DBusConnection *bus;
 GMainContext *main_context;
diff --git a/test/core/test-thread-client.c b/dbus-gmain/tests/test-thread-client.c
similarity index 100%
rename from test/core/test-thread-client.c
rename to dbus-gmain/tests/test-thread-client.c
diff --git a/test/core/test-thread-server.c b/dbus-gmain/tests/test-thread-server.c
similarity index 100%
rename from test/core/test-thread-server.c
rename to dbus-gmain/tests/test-thread-server.c
diff --git a/test/core/test-thread.h b/dbus-gmain/tests/test-thread.h
similarity index 100%
rename from test/core/test-thread.h
rename to dbus-gmain/tests/test-thread.h
diff --git a/test/lib/util.c b/dbus-gmain/tests/util.c
similarity index 100%
rename from test/lib/util.c
rename to dbus-gmain/tests/util.c
diff --git a/test/lib/util.h b/dbus-gmain/tests/util.h
similarity index 100%
rename from test/lib/util.h
rename to dbus-gmain/tests/util.h
diff --git a/test/Makefile.am b/test/Makefile.am
index 14c5abf4..e538f2d3 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1,5 +1,5 @@
-SUBDIRS = lib . core interfaces
-DIST_SUBDIRS = lib core interfaces
+SUBDIRS = . core interfaces
+DIST_SUBDIRS = core interfaces
 
 AM_CPPFLAGS = \
 	-I$(top_srcdir)				\
diff --git a/test/core/Makefile.am b/test/core/Makefile.am
index 1381e739..314ff401 100644
--- a/test/core/Makefile.am
+++ b/test/core/Makefile.am
@@ -12,7 +12,7 @@ LDADD = \
 	$(DBUS_GLIB_LIBS) \
 	$(DBUS_LIBS) \
 	$(top_builddir)/dbus/libdbus-glib-1.la \
-	$(top_builddir)/test/lib/libtest.la \
+	$(top_builddir)/dbus-gmain/tests/libtest.la \
 	$(NULL)
 
 tool_ldadd = \
@@ -55,42 +55,17 @@ EXTRA_DIST = \
 
 if DBUS_BUILD_TESTS
 
-THREAD_APPS=test-thread-server test-thread-client test-profile
-
-test_thread_server_SOURCES=				\
-	test-thread-server.c				\
-	test-thread.h
-test_thread_server_LDADD = \
-	$(DBUS_GLIB_THREADS_LIBS) \
-	$(DBUS_GLIB_LIBS) \
-	$(DBUS_LIBS) \
-	$(top_builddir)/dbus-gmain/libdbus-gmain.la \
-	$(top_builddir)/test/lib/libtest.la \
-	$(NULL)
-
-test_thread_client_SOURCES=				\
-	test-thread-client.c				\
-	test-thread.h
-test_thread_client_LDADD = \
-	$(DBUS_GLIB_THREADS_LIBS) \
-	$(DBUS_GLIB_LIBS) \
-	$(DBUS_LIBS) \
-	$(top_builddir)/dbus-gmain/libdbus-gmain.la \
-	$(top_builddir)/test/lib/libtest.la \
-	$(NULL)
-
 ## we use noinst_PROGRAMS not check_PROGRAMS for TESTS so that we
 ## build even when not doing "make check"
 noinst_PROGRAMS = \
 	test-dbus-glib \
 	test-error-mapping \
 	test-service-glib \
-	$(THREAD_APPS) \
+	test-profile \
 	manual/test-invalid-usage \
 	peer-server \
 	peer-client \
 	test-types \
-	test-30574 \
 	test-private \
 	test-peer-on-bus \
 	test-proxy-noc \
@@ -109,15 +84,6 @@ manual_test_invalid_usage_SOURCES = \
 	my-object.h \
 	$(NULL)
 
-test_30574_SOURCES = \
-	30574.c
-test_30574_LDADD = \
-	$(DBUS_GLIB_LIBS) \
-	$(DBUS_LIBS) \
-	$(top_builddir)/dbus-gmain/libdbus-gmain.la \
-	$(top_builddir)/test/lib/libtest.la \
-	$(NULL)
-
 test_private_SOURCES = \
 	my-object.c \
 	my-object.h \
diff --git a/test/core/peer-on-bus.c b/test/core/peer-on-bus.c
index 50a15b5d..a1eb231b 100644
--- a/test/core/peer-on-bus.c
+++ b/test/core/peer-on-bus.c
@@ -40,7 +40,7 @@
 #include <dbus/dbus-glib.h>
 #include <dbus/dbus-glib-lowlevel.h>
 
-#include "test/lib/util.h"
+#include "dbus-gmain/tests/util.h"
 
 GMainLoop *loop = NULL;
 
diff --git a/test/core/registrations.c b/test/core/registrations.c
index 29afb306..0eea4683 100644
--- a/test/core/registrations.c
+++ b/test/core/registrations.c
@@ -42,7 +42,7 @@
 
 #include "my-object.h"
 
-#include "test/lib/util.h"
+#include "dbus-gmain/tests/util.h"
 
 GMainLoop *loop = NULL;
 
diff --git a/test/core/run-test.sh b/test/core/run-test.sh
index fe4dc21d..fe0d3f8b 100755
--- a/test/core/run-test.sh
+++ b/test/core/run-test.sh
@@ -49,7 +49,6 @@ else
   ${DBUS_TOP_BUILDDIR}/libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/test/core/test-dbus-glib || die "test-dbus-glib failed"
   ${DBUS_TOP_BUILDDIR}/libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/test/core/test-variant-recursion || die "test-variant-recursion failed"
   ${DBUS_TOP_BUILDDIR}/libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/test/core/test-gvariant || die "test-gvariant failed"
-  ${DBUS_TOP_BUILDDIR}/libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/test/core/test-30574 || die "test-30574 failed"
   ${DBUS_TOP_BUILDDIR}/libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/test/core/test-private || die "test-private failed"
   ${DBUS_TOP_BUILDDIR}/libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/test/core/test-error-mapping || die "test-error-mapping failed"
   ${DBUS_TOP_BUILDDIR}/libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/test/core/test-peer-on-bus || die "test-peer-on-bus failed"
diff --git a/test/core/test-dbus-glib.c b/test/core/test-dbus-glib.c
index cd5506e3..1ae2ec79 100644
--- a/test/core/test-dbus-glib.c
+++ b/test/core/test-dbus-glib.c
@@ -38,7 +38,7 @@
 #include <glib.h>
 #include <glib-object.h>
 #include "my-object.h"
-#include "test/lib/util.h"
+#include "dbus-gmain/tests/util.h"
 
 GMainLoop *loop = NULL;
 
diff --git a/test/core/test-variant-recursion.c b/test/core/test-variant-recursion.c
index dfb8e120..507ea4d2 100644
--- a/test/core/test-variant-recursion.c
+++ b/test/core/test-variant-recursion.c
@@ -11,7 +11,7 @@
 #include <dbus/dbus-glib.h>
 #include <dbus/dbus-glib-lowlevel.h>
 
-#include "test/lib/util.h"
+#include "dbus-gmain/tests/util.h"
 
 static gboolean
 make_recursive_stringify_call (int recursion_depth, 
diff --git a/test/interfaces/Makefile.am b/test/interfaces/Makefile.am
index 6171a545..fa5ae33d 100644
--- a/test/interfaces/Makefile.am
+++ b/test/interfaces/Makefile.am
@@ -9,7 +9,7 @@ AM_CPPFLAGS = \
 LDADD = $(DBUS_GLIB_LIBS) \
 	$(top_builddir)/dbus/libdbus-glib-1.la \
 	$(top_builddir)/dbus/libdbus-gtool.la \
-	$(top_builddir)/test/lib/libtest.la \
+	$(top_builddir)/dbus-gmain/tests/libtest.la \
 	$(NULL)
 
 ## note that TESTS has special meaning (stuff to use in make check)
diff --git a/test/interfaces/test-client.c b/test/interfaces/test-client.c
index dcd21a52..c3348e46 100644
--- a/test/interfaces/test-client.c
+++ b/test/interfaces/test-client.c
@@ -13,7 +13,7 @@
 #include "test-dup-prop-a-bindings.h"
 #include "test-dup-prop-b-bindings.h"
 
-#include "test/lib/util.h"
+#include "dbus-gmain/tests/util.h"
 
 #define TEST_NAMESPACE "org.freedesktop.DBus.GLib.Test.Interfaces"
 #define TEST_OBJECT_PATH "/org/freedesktop/DBus/GLib/Test/Interfaces"
diff --git a/test/lib/Makefile.am b/test/lib/Makefile.am
deleted file mode 100644
index 8a2670bc..00000000
--- a/test/lib/Makefile.am
+++ /dev/null
@@ -1,19 +0,0 @@
-AM_CPPFLAGS = \
-	-I$(top_srcdir) \
-	-I$(top_builddir) \
-	$(DBUS_CFLAGS) \
-	$(DBUS_GLIB_CFLAGS) \
-	$(NULL)
-
-noinst_LTLIBRARIES = libtest.la
-
-libtest_la_SOURCES = \
-	util.c \
-	util.h \
-	$(NULL)
-
-libtest_la_LIBADD = \
-	$(top_builddir)/dbus/libdbus-glib-1.la \
-	$(DBUS_LIBS) \
-	$(DBUS_GLIB_LIBS) \
-	$(NULL)
-- 
GitLab