[PATCH 2/2] Cmake support for cross plattform usable test files.
Ralf Habacker
ralf.habacker at freenet.de
Fri Apr 9 14:34:28 PDT 2010
Recent test configuration files contains 'unix:...'
bus adresses which do not work on windows.
For cross plattform usable test files the whole
listen tag entry has to be set by the build system,
which is available with a new build system variable
named TEST_LISTEN.
To have the client client side definition in sync,
TEST_CONNECTION has been moved from c file into cmake
build system.
---
bus/dispatch.c | 8 +++++++-
cmake/CMakeLists.txt | 18 ++++++++++++++----
cmake/config.h.cmake | 3 +++
cmake/test/CMakeLists.txt | 7 -------
.../debug-allow-all-fail.conf.cmake | 16 ++++++++++++++++
.../debug-allow-all-pass.conf.cmake | 16 ++++++++++++++++
6 files changed, 56 insertions(+), 12 deletions(-)
create mode 100644 test/data/valid-config-files-system/debug-allow-all-fail.conf.cmake
create mode 100644 test/data/valid-config-files-system/debug-allow-all-pass.conf.cmake
diff --git a/bus/dispatch.c b/bus/dispatch.c
index d4c69dc..d0a92c9 100644
--- a/bus/dispatch.c
+++ b/bus/dispatch.c
@@ -41,11 +41,17 @@
#include <unistd.h>
#endif
+#ifndef TEST_CONNECTION
+/*
+ TODO autotools:
+ move to build system as already done for cmake
+*/
#ifdef DBUS_UNIX
#define TEST_CONNECTION "debug-pipe:name=test-server"
#else
#define TEST_CONNECTION "tcp:host=localhost,port=1234"
#endif
+#endif
static dbus_bool_t
send_one_message (DBusConnection *connection,
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
index f464c29..1bae290 100644
--- a/cmake/CMakeLists.txt
+++ b/cmake/CMakeLists.txt
@@ -475,10 +475,6 @@ if (MINGW)
set (HAVE_GNUC_VARARGS 1)
endif(MINGW)
-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h )
-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/dbus-env.bat.cmake ${CMAKE_BINARY_DIR}/bin/dbus-env.bat )
-install_files(/bin FILES ${CMAKE_BINARY_DIR}/bin/dbus-env.bat)
-
# compiler definitions
add_definitions(-DHAVE_CONFIG_H=1)
add_definitions(${DBUS_BUS_CFLAGS} -DDBUS_API_SUBJECT_TO_CHANGE)
@@ -490,6 +486,14 @@ if (DBUS_BUILD_TESTS)
set(TEST_VALID_SERVICE_SYSTEM_DIR ${CMAKE_BINARY_DIR}/test/data/valid-service-files-system)
set(TEST_SOCKET_DIR ${DBUS_SESSION_SOCKET_DIR} )
set(TEST_LAUNCH_HELPER_BINARY ${EXECUTABLE_OUTPUT_PATH}/dbus-daemon-launch-helper-test)
+ if (UNIX)
+ set (TEST_LISTEN "debug-pipe:name=test-server")
+ set (TEST_CONNECTION "${TEST_LISTEN}")
+ endif (UNIX)
+ if (WIN32)
+ set (TEST_LISTEN "tcp:host=localhost,port=12436")
+ set (TEST_CONNECTION "${TEST_LISTEN}")
+ endif (WIN32)
endif (DBUS_BUILD_TESTS)
set(DBUS_LIBRARIES dbus-1)
@@ -501,6 +505,11 @@ set (DBUS_INTERNAL_ADD_LIBRARY_OPTIONS STATIC)
set (DBUS_INTERNAL_LIBRARY_DEFINITIONS "-DDBUS_STATIC_BUILD")
set (DBUS_INTERNAL_CLIENT_DEFINITIONS "-DDBUS_STATIC_BUILD")
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h )
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/dbus-env.bat.cmake ${CMAKE_BINARY_DIR}/bin/dbus-env.bat )
+install_files(/bin FILES ${CMAKE_BINARY_DIR}/bin/dbus-env.bat)
+
+
########### subdirs ###############
add_subdirectory( dbus )
@@ -576,6 +585,7 @@ message(" Console auth dir: ${DBUS_CONSOLE_AUTH_DIR} "
message(" System bus user: ${DBUS_USER} ")
message(" 'make check' socket dir: ${TEST_SOCKET_DIR} ")
endif (WIN32)
+message(" Test listen address: ${TEST_LISTEN} ")
if (MSVC)
message(" build timestamp: ${DBUS_BUILD_TIMESTAMP} ")
endif (MSVC)
diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake
index 2313dd2..a4aae42 100644
--- a/cmake/config.h.cmake
+++ b/cmake/config.h.cmake
@@ -26,6 +26,9 @@
#define VERSION DBUS_VERSION_STRING
+#define TEST_LISTEN "@TEST_LISTEN@"
+#define TEST_CONNECTION "@TEST_CONNECTION@"
+
// test binaries
/* Full path to test file test/test-exit in builddir */
#define TEST_BUS_BINARY "@TEST_BUS_BINARY@"
diff --git a/cmake/test/CMakeLists.txt b/cmake/test/CMakeLists.txt
index 014e940..8e36e2d 100644
--- a/cmake/test/CMakeLists.txt
+++ b/cmake/test/CMakeLists.txt
@@ -122,13 +122,6 @@ FOREACH(FILE_TYPE *.message *.message-raw *.auth-script *.sha1 *.txt *.conf *.se
ENDFOREACH(DIR)
ENDFOREACH(FILE_TYPE)
-if (UNIX)
- set (TEST_LISTEN "debug-pipe:name=test-server")
-endif (UNIX)
-if (WIN32)
- set (TEST_LISTEN "tcp:host=localhost,port=1234")
-endif (WIN32)
-
### generate test files
MESSAGE(STATUS "Generating test files from templates into test directory")
diff --git a/test/data/valid-config-files-system/debug-allow-all-fail.conf.cmake b/test/data/valid-config-files-system/debug-allow-all-fail.conf.cmake
new file mode 100644
index 0000000..0c73d8c
--- /dev/null
+++ b/test/data/valid-config-files-system/debug-allow-all-fail.conf.cmake
@@ -0,0 +1,16 @@
+<!-- Bus that listens on a debug pipe and doesn't create any restrictions -->
+
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+ <listen>@TEST_LISTEN@</listen>
+ <type>system</type>
+ <servicehelper>@TEST_LAUNCH_HELPER_BINARY@</servicehelper>
+ <servicedir>@TEST_INVALID_SERVICE_SYSTEM_DIR@</servicedir>
+ <policy context="default">
+ <allow send_interface="*"/>
+ <allow receive_interface="*"/>
+ <allow own="*"/>
+ <allow user="*"/>
+ </policy>
+</busconfig>
diff --git a/test/data/valid-config-files-system/debug-allow-all-pass.conf.cmake b/test/data/valid-config-files-system/debug-allow-all-pass.conf.cmake
new file mode 100644
index 0000000..d46ec18
--- /dev/null
+++ b/test/data/valid-config-files-system/debug-allow-all-pass.conf.cmake
@@ -0,0 +1,16 @@
+<!-- Bus that listens on a debug pipe and doesn't create any restrictions -->
+
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+ <listen>@TEST_LISTEN@</listen>
+ <type>system</type>
+ <servicehelper>@TEST_LAUNCH_HELPER_BINARY@</servicehelper>
+ <servicedir>@TEST_VALID_SERVICE_SYSTEM_DIR@</servicedir>
+ <policy context="default">
+ <allow send_interface="*"/>
+ <allow receive_interface="*"/>
+ <allow own="*"/>
+ <allow user="*"/>
+ </policy>
+</busconfig>
--
1.7.0.2.msysgit.0
--------------000506020805000505030307--
More information about the dbus
mailing list