]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
Add manual-paths test executable with cmake build support.
authorRalf Habacker <ralf.habacker@freenet.de>
Wed, 11 Feb 2015 17:09:14 +0000 (18:09 +0100)
committerRalf Habacker <ralf.habacker@freenet.de>
Thu, 12 Feb 2015 22:22:18 +0000 (23:22 +0100)
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=83539
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
cmake/CMakeLists.txt
cmake/config.h.cmake
cmake/test/CMakeLists.txt
test/manual-paths.c [new file with mode: 0644]

index b997f8b14f6a4913eb2ee637f72383f530d80665..45b7d06d865725c53f71f9ca60a999e9f0e66a1d 100644 (file)
@@ -63,6 +63,8 @@ if (NOT DBUS_DATADIR)
     SET(DBUS_DATADIR ${DATADIR})
 endif()
 
+set(DBUS_PREFIX ${DBUS_INSTALL_DIR})
+
 set(prefix                   ${DBUS_INSTALL_DIR})
 set(exec_prefix              ${prefix})
 set(EXPANDED_LIBDIR          ${DBUS_INSTALL_DIR}/lib)
index f718052866e3e3ac301190f4585dd5fa47f01d4f..cd4720c9a023ca6ec2be50c6dee9a938ac02d329 100644 (file)
@@ -17,6 +17,7 @@
 #cmakedefine DBUS_CONSOLE_AUTH_DIR "@DBUS_CONSOLE_AUTH_DIR@"
 #cmakedefine DBUS_DATADIR  "@DBUS_DATADIR@"
 #cmakedefine DBUS_BINDIR   "@DBUS_BINDIR@"
+#cmakedefine DBUS_PREFIX "@DBUS_PREFIX@"
 #cmakedefine DBUS_SYSTEM_CONFIG_FILE  "@DBUS_SYSTEM_CONFIG_FILE@"
 #cmakedefine DBUS_SESSION_CONFIG_FILE "@DBUS_SESSION_CONFIG_FILE@"
 #cmakedefine DBUS_DAEMON_NAME "@DBUS_DAEMON_NAME@"
index 477beb40bd72ac20b4e5f38fe10714ace3c852e7..c5e73bcab75698420ebd1e9b2e6e6c0a0ce4d76f 100644 (file)
@@ -58,6 +58,10 @@ set (manual-tcp_SOURCES
     ${CMAKE_SOURCE_DIR}/../test/manual-tcp.c
 )
 
+set (manual-paths_SOURCES
+    ${CMAKE_SOURCE_DIR}/../test/manual-paths.c
+)
+
 add_helper_executable(manual-dir-iter ${manual-dir-iter_SOURCES} ${DBUS_INTERNAL_LIBRARIES})
 add_helper_executable(test-service ${test-service_SOURCES} dbus-testutils)
 add_helper_executable(test-names ${test-names_SOURCES} dbus-testutils)
@@ -69,6 +73,9 @@ add_helper_executable(test-exit ${test-exit_SOURCES} ${DBUS_INTERNAL_LIBRARIES})
 add_helper_executable(test-segfault ${test-segfault_SOURCES} ${DBUS_INTERNAL_LIBRARIES})
 add_helper_executable(test-sleep-forever ${test-sleep-forever_SOURCES} ${DBUS_INTERNAL_LIBRARIES})
 add_test_executable(manual-tcp ${manual-tcp_SOURCES} ${DBUS_INTERNAL_LIBRARIES})
+if(WIN32)
+    add_helper_executable(manual-paths ${manual-paths_SOURCES} ${DBUS_INTERNAL_LIBRARIES})
+endif()
 
 if(DBUS_WITH_GLIB)
     message(STATUS "with glib test apps")
diff --git a/test/manual-paths.c b/test/manual-paths.c
new file mode 100644 (file)
index 0000000..4ce3ffc
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * Simple manual paths check
+ *
+ * syntax:  manual-paths
+ *
+*/
+
+#include "config.h"
+#include "dbus/dbus-list.h"
+#include "dbus/dbus-internals.h"
+#include "dbus/dbus-sysdeps.h"
+
+#include <stdio.h>
+
+dbus_bool_t print_install_root()
+{
+  char runtime_prefix[1000];
+
+  if (!_dbus_get_install_root(runtime_prefix, sizeof(runtime_prefix)))
+    {
+      fprintf(stderr, "dbus_get_install_root() failed\n");
+      return FALSE;
+    }
+  fprintf(stdout, "dbus_get_install_root() returned '%s'\n", runtime_prefix);
+  return TRUE;
+}
+
+dbus_bool_t print_service_dirs()
+{
+  DBusList *dirs;
+  DBusList *link;
+  dirs = NULL;
+
+  if (!_dbus_get_standard_session_servicedirs (&dirs))
+    _dbus_assert_not_reached ("couldn't get standard dirs");
+
+  while ((link = _dbus_list_pop_first_link (&dirs)))
+    {
+      printf ("default service dir: %s\n", (char *)link->data);
+      dbus_free (link->data);
+      _dbus_list_free_link (link);
+    }
+  dbus_free (dirs);
+  return TRUE;
+}
+
+dbus_bool_t print_replace_install_prefix(const char *s)
+{
+  const char *s2 = _dbus_replace_install_prefix(s);
+  if (!s2)
+    return FALSE;
+
+  fprintf(stdout, "replaced '%s' by '%s'\n", s, s2);
+  return TRUE;
+}
+
+int
+main (int argc, char **argv)
+{
+  if (!print_install_root())
+    return -1;
+
+  if (!print_service_dirs())
+    return -2;
+
+  if (!print_replace_install_prefix(DBUS_BINDIR "/dbus-daemon"))
+    return -3;
+
+  if (!print_replace_install_prefix("c:\\Windows\\System32\\testfile"))
+    return -4;
+
+  return 0;
+}