From 1be16e7392c5cba7495a20a2ebd6ad5eeebd9a67 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Sat, 14 Sep 2013 10:21:17 +0800 Subject: [PATCH v2] Unify the way to find dbus-daemon test binary There are two ways to find the dbus-daemon for testing. The first one is defined as string at compile stage and the second one is export it from test environment. The first way has limitation that after defined, it's static string, so it's impossible to run installable check. So let's unify to the second way. --- cmake/config.h.cmake | 3 --- configure.ac | 4 ---- test/name-test/Makefile.am | 1 + tools/dbus-launch.c | 52 ++++++++++++++++++++++++-------------------- 4 files changed, 29 insertions(+), 31 deletions(-) diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake index f14b169..9d62449 100644 --- a/cmake/config.h.cmake +++ b/cmake/config.h.cmake @@ -33,9 +33,6 @@ #define DBUS_TEST_EXEC "@DBUS_TEST_EXEC@" #define DBUS_EXEEXT "@EXEEXT@" -/* Full path to test file test/test-exit in builddir */ -#define TEST_BUS_BINARY "@TEST_BUS_BINARY@" - /* Some dbus features */ #cmakedefine DBUS_ENABLE_ANSI 1 #cmakedefine DBUS_ENABLE_VERBOSE_MODE 1 diff --git a/configure.ac b/configure.ac index da4ab5f..5ed4e73 100644 --- a/configure.ac +++ b/configure.ac @@ -1638,10 +1638,6 @@ AC_DEFINE_UNQUOTED([DBUS_TEST_EXEC], ["$DBUS_TEST_EXEC"], AC_DEFINE_UNQUOTED([DBUS_EXEEXT], ["$EXEEXT"], [Extension for executables, typically empty or .exe]) -AC_DEFINE_UNQUOTED(TEST_BUS_BINARY, ["$DBUS_PWD/bus/dbus-daemon$EXEEXT"], - [Full path to the daemon in the builddir]) -AC_SUBST(TEST_BUS_BINARY) - AC_DEFINE_UNQUOTED(TEST_BUS_LAUNCH_BINARY, ["$DBUS_PWD/tools/dbus-launch$EXEEXT"], [Full path to the dbus-launch in the builddir]) diff --git a/test/name-test/Makefile.am b/test/name-test/Makefile.am index 931cb2c..da41e58 100644 --- a/test/name-test/Makefile.am +++ b/test/name-test/Makefile.am @@ -18,6 +18,7 @@ TESTS_ENVIRONMENT = \ DBUS_TOP_SRCDIR=@abs_top_srcdir@ \ PYTHON=@PYTHON@ \ DBUS_TEST_DATA=@abs_top_builddir@/test/data \ + DBUS_TEST_DAEMON=@abs_top_builddir@/bus/dbus-daemon$(EXEEXT) \ $(NULL) TESTS=run-test.sh run-test-systemserver.sh else diff --git a/tools/dbus-launch.c b/tools/dbus-launch.c index 14fa226..18abf5b 100644 --- a/tools/dbus-launch.c +++ b/tools/dbus-launch.c @@ -1109,30 +1109,34 @@ main (int argc, char **argv) verbose ("Calling exec()\n"); #ifdef DBUS_ENABLE_EMBEDDED_TESTS - /* exec from testdir */ - if (getenv ("DBUS_USE_TEST_BINARY") != NULL) - { - if (config_file == NULL && getenv ("DBUS_TEST_DATA") != NULL) - { - ret = asprintf (&config_file, "%s/valid-config-files/session.conf", - getenv ("DBUS_TEST_DATA")); - } - if (ret == -1 && config_file != NULL) - free (config_file); - - execl (TEST_BUS_BINARY, - TEST_BUS_BINARY, - "--fork", - "--print-pid", write_pid_fd_as_string, - "--print-address", write_address_fd_as_string, - config_file ? "--config-file" : "--session", - config_file, /* has to be last in this varargs list */ - NULL); - - fprintf (stderr, - "Failed to execute test message bus daemon %s: %s. Will try again with the system path.\n", - TEST_BUS_BINARY, strerror (errno)); - } + { + const char *test_daemon; + /* exec from testdir */ + if (getenv ("DBUS_USE_TEST_BINARY") != NULL && + (test_daemon = getenv ("DBUS_TEST_DAEMON")) != NULL) + { + if (config_file == NULL && getenv ("DBUS_TEST_DATA") != NULL) + { + ret = asprintf (&config_file, "%s/valid-config-files/session.conf", + getenv ("DBUS_TEST_DATA")); + } + if (ret == -1 && config_file != NULL) + free (config_file); + + execl (test_daemon, + test_daemon, + "--fork", + "--print-pid", write_pid_fd_as_string, + "--print-address", write_address_fd_as_string, + config_file ? "--config-file" : "--session", + config_file, /* has to be last in this varargs list */ + NULL); + + fprintf (stderr, + "Failed to execute test message bus daemon %s: %s. Will try again with the system path.\n", + test_daemon, strerror (errno)); + } + } #endif /* DBUS_ENABLE_EMBEDDED_TESTS */ execl (DBUS_DAEMONDIR"/dbus-daemon", -- 1.7.9.5