Simplify linking for tests that use libdbus-testutils
authorSimon McVittie <simon.mcvittie@collabora.co.uk>
Wed, 15 Jun 2011 10:50:33 +0000 (11:50 +0100)
committerSimon McVittie <simon.mcvittie@collabora.co.uk>
Fri, 29 Jul 2011 10:17:17 +0000 (11:17 +0100)
This is the library used by tests that link libdbus-internal and DBusLoop.
By linking libdbus-internal into it, we can avoid having to repeat that
dependency all over the place - libtool and cmake both know how to follow
recursive dependencies.

In cmake, also use libdbus-testutils for more tests, in preference to
repeating its source files.

cmake/test/CMakeLists.txt
cmake/test/name-test/CMakeLists.txt
test/Makefile.am
test/name-test/Makefile.am

index 9a259d2..4ec702d 100644 (file)
@@ -2,24 +2,20 @@ project(test)
 
 add_definitions(${DBUS_INTERNAL_CLIENT_DEFINITIONS})
 
-add_library(dbus_testutils STATIC
+add_library(dbus-testutils STATIC
     ${CMAKE_SOURCE_DIR}/../test/test-utils.h
     ${CMAKE_SOURCE_DIR}/../test/test-utils.c
 )
-target_link_libraries(dbus_testutils ${DBUS_INTERNAL_LIBRARIES})
+target_link_libraries(dbus-testutils ${DBUS_INTERNAL_LIBRARIES})
 
 add_subdirectory( name-test )
 
 set (test-service_SOURCES
     ${CMAKE_SOURCE_DIR}/../test/test-service.c
-    ${CMAKE_SOURCE_DIR}/../test/test-utils.c
-    ${CMAKE_SOURCE_DIR}/../test/test-utils.h
 )
 
 set (test-names_SOURCES
     ${CMAKE_SOURCE_DIR}/../test/test-names.c
-    ${CMAKE_SOURCE_DIR}/../test/test-utils.c
-    ${CMAKE_SOURCE_DIR}/../test/test-utils.h
 )
 
 set (break_loader_SOURCES
@@ -28,8 +24,6 @@ set (break_loader_SOURCES
 
 set (test-shell-service_SOURCES
     ${CMAKE_SOURCE_DIR}/../test/test-shell-service.c
-    ${CMAKE_SOURCE_DIR}/../test/test-utils.c
-    ${CMAKE_SOURCE_DIR}/../test/test-utils.h
 )
 
 set (shell-test_SOURCES
@@ -53,17 +47,17 @@ set (test-sleep-forever_SOURCES
 )
 
 add_executable(test-service ${test-service_SOURCES})
-target_link_libraries(test-service ${DBUS_INTERNAL_LIBRARIES})
+target_link_libraries(test-service dbus-testutils)
 
 add_executable(test-names ${test-names_SOURCES})
-target_link_libraries(test-names ${DBUS_INTERNAL_LIBRARIES})
+target_link_libraries(test-names dbus-testutils)
 
 add_executable(shell-test ${shell-test_SOURCES})
 target_link_libraries(shell-test ${DBUS_INTERNAL_LIBRARIES})
 ADD_TEST(shell-test ${EXECUTABLE_OUTPUT_PATH}/shell-test${EXT})
 
 add_executable(test-shell-service ${test-shell-service_SOURCES})
-target_link_libraries(test-shell-service ${DBUS_INTERNAL_LIBRARIES})
+target_link_libraries(test-shell-service dbus-testutils)
 
 add_executable(spawn-test ${spawn-test_SOURCES})
 target_link_libraries(spawn-test ${DBUS_INTERNAL_LIBRARIES})
index 25ec7f6..80b9908 100644 (file)
@@ -21,19 +21,19 @@ target_link_libraries(test-ids ${DBUS_INTERNAL_LIBRARIES})
 ADD_TEST(test-ids ${EXECUTABLE_OUTPUT_PATH}/test-ids)
 
 add_executable(test-shutdown ${NAMEtest-DIR}/test-shutdown.c)
-target_link_libraries(test-shutdown ${DBUS_INTERNAL_LIBRARIES} dbus_testutils)
+target_link_libraries(test-shutdown dbus-testutils)
 ADD_TEST(test-shutdown ${EXECUTABLE_OUTPUT_PATH}/test-shutdown)
 
 add_executable(test-privserver ${NAMEtest-DIR}/test-privserver.c)
-target_link_libraries(test-privserver ${DBUS_INTERNAL_LIBRARIES} dbus_testutils)
+target_link_libraries(test-privserver dbus-testutils)
 ADD_TEST(test-privserver ${EXECUTABLE_OUTPUT_PATH}/test-privserver)
 
 add_executable(test-privserver-client ${NAMEtest-DIR}/test-privserver-client.c)
-target_link_libraries(test-privserver-client ${DBUS_INTERNAL_LIBRARIES} dbus_testutils)
+target_link_libraries(test-privserver-client dbus-testutils)
 ADD_TEST(test-privserver-client ${EXECUTABLE_OUTPUT_PATH}/test-privserver-client)
 
 add_executable(test-autolaunch ${NAMEtest-DIR}/test-autolaunch.c)
-target_link_libraries(test-autolaunch ${DBUS_INTERNAL_LIBRARIES} dbus_testutils)
+target_link_libraries(test-autolaunch dbus-testutils)
 ADD_TEST(test-autolaunch ${EXECUTABLE_OUTPUT_PATH}/test-autolaunch)
 
 endif (DBUS_BUILD_TESTS)
index ad8b6a1..0448dca 100644 (file)
@@ -9,7 +9,13 @@ INCLUDES=-I$(top_srcdir)
 # improve backtraces from test stuff
 AM_LDFLAGS = @R_DYNAMIC_LDFLAG@
 
-libdbus_testutils_la_SOURCES = test-utils.h test-utils.c
+libdbus_testutils_la_SOURCES = \
+       test-utils.c \
+       test-utils.h \
+       $(NULL)
+libdbus_testutils_la_LIBADD = \
+       $(top_builddir)/dbus/libdbus-internal.la \
+       $(NULL)
 
 noinst_LTLIBRARIES = libdbus-testutils.la
 
@@ -86,11 +92,11 @@ test_sleep_forever_SOURCES =                        \
 # tests linked to only the public libdbus have their own CPPFLAGS.
 AM_CPPFLAGS=-DDBUS_STATIC_BUILD
 
-test_service_LDADD = libdbus-testutils.la $(top_builddir)/dbus/libdbus-internal.la
-test_names_LDADD = libdbus-testutils.la $(top_builddir)/dbus/libdbus-internal.la
+test_service_LDADD = libdbus-testutils.la
+test_names_LDADD = libdbus-testutils.la
 ## break_loader_LDADD = $(top_builddir)/dbus/libdbus-internal.la
-test_shell_service_LDADD = libdbus-testutils.la $(top_builddir)/dbus/libdbus-internal.la
-shell_test_LDADD = libdbus-testutils.la $(top_builddir)/dbus/libdbus-internal.la
+test_shell_service_LDADD = libdbus-testutils.la
+shell_test_LDADD = libdbus-testutils.la
 spawn_test_LDADD = $(top_builddir)/dbus/libdbus-internal.la
 
 EXTRA_DIST = dbus-test-runner
index 226a2b7..f4754f3 100644 (file)
@@ -46,24 +46,24 @@ test_shutdown_SOURCES =            \
        test-shutdown.c
 
 test_shutdown_CFLAGS=
-test_shutdown_LDADD=$(top_builddir)/dbus/libdbus-internal.la ../libdbus-testutils.la
+test_shutdown_LDADD=../libdbus-testutils.la
 
 test_privserver_SOURCES =            \
        test-privserver.c
 
 test_privserver_CFLAGS=
-test_privserver_LDADD=$(top_builddir)/dbus/libdbus-internal.la ../libdbus-testutils.la
+test_privserver_LDADD=../libdbus-testutils.la
 
 test_privserver_client_SOURCES =            \
        test-privserver-client.c
 
 test_privserver_client_CFLAGS=
-test_privserver_client_LDADD=$(top_builddir)/dbus/libdbus-internal.la ../libdbus-testutils.la
+test_privserver_client_LDADD=../libdbus-testutils.la
 
 test_autolaunch_SOURCES =            \
        test-autolaunch.c
 
 test_autolaunch_CFLAGS=
-test_autolaunch_LDADD=$(top_builddir)/dbus/libdbus-internal.la ../libdbus-testutils.la
+test_autolaunch_LDADD=../libdbus-testutils.la
 
 endif