From 04b11a971f8d7626e5a20b0d322faae437cea86c Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Tue, 27 Jan 2015 02:33:15 +0100 Subject: [PATCH 04/10] Do not require binfmt support for running cross compiled test applications. --- cmake/modules/Macros.cmake | 19 +++++++++++++++---- test/test-utils-glib.c | 10 ++++++++-- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/cmake/modules/Macros.cmake b/cmake/modules/Macros.cmake index fd3f62c..de1bbd7 100644 --- a/cmake/modules/Macros.cmake +++ b/cmake/modules/Macros.cmake @@ -5,19 +5,25 @@ if(DBUS_BUILD_TESTS AND CMAKE_CROSSCOMPILING AND CMAKE_SYSTEM_NAME STREQUAL "Win PATHS /usr/bin /usr/local/bin NO_CMAKE_FIND_ROOT_PATH ) - find_file(HAVE_BINFMT_WINE_SUPPORT + find_file(BINFMT_WINE_SUPPORT_FILE NAMES DOSWin wine Wine windows Windows PATHS /proc/sys/fs/binfmt_misc NO_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH ) - if(WINE_EXECUTABLE AND HAVE_BINFMT_WINE_SUPPORT) + if(BINFMT_WINE_SUPPORT_FILE) + file(READ ${BINFMT_WINE_SUPPORT_FILE} CONTENT) + if(${CONTENT} MATCHES "enabled") + set(HAVE_BINFMT_WINE_SUPPORT 1) + endif() + endif() + if(WINE_EXECUTABLE) list(APPEND FOOTNOTES "NOTE: The requirements to run cross compiled applications on your host system are achieved. You may run 'make check'.") endif() if(NOT WINE_EXECUTABLE) list(APPEND FOOTNOTES "NOTE: You may install the Windows emulator 'wine' to be able to run cross compiled test applications.") endif() if(NOT HAVE_BINFMT_WINE_SUPPORT) - list(APPEND FOOTNOTES "NOTE: You may activate binfmt_misc support for wine to be able to run cross compiled test applications.") + list(APPEND FOOTNOTES "NOTE: You may activate binfmt_misc support for wine to be able to run cross compiled test applications directly.") endif() else() list(APPEND FOOTNOTES "NOTE: You will not be able to run cross compiled applications on your host system.") @@ -43,7 +49,12 @@ macro(add_test_executable _target _source) # run tests with binfmt_misc set(PREFIX "z:") set(_env "DBUS_TEST_DAEMON=${PREFIX}${CMAKE_BINARY_DIR}/bin/dbus-daemon${EXEEXT}") - add_test(NAME ${_target} COMMAND $) + if(HAVE_BINFMT_WINE_SUPPORT) + add_test(NAME ${_target} COMMAND $) + else() + add_test(NAME ${_target} COMMAND ${WINE_EXECUTABLE} $) + list(APPEND _env "DBUS_TEST_DAEMON_WRAPPER=/usr/bin/wine") + endif() else() set(PREFIX) set(_env "DBUS_TEST_DAEMON=${CMAKE_BINARY_DIR}/bin/dbus-daemon${EXEEXT}") diff --git a/test/test-utils-glib.c b/test/test-utils-glib.c index 286e7a5..855a340 100644 --- a/test/test-utils-glib.c +++ b/test/test-utils-glib.c @@ -95,7 +95,8 @@ spawn_dbus_daemon (const gchar *binary, GError *error = NULL; GString *address; gint address_fd; - const gchar *const argv[] = { + gchar *argv[] = { + NULL, binary, configuration, "--nofork", @@ -154,8 +155,13 @@ spawn_dbus_daemon (const gchar *binary, #endif } + if (g_getenv ("DBUS_TEST_DAEMON_WRAPPER") != NULL) + { + argv[0] = g_strdup (g_getenv ("DBUS_TEST_DAEMON_WRAPPER")); + } + g_spawn_async_with_pipes (NULL, /* working directory */ - (gchar **) argv, /* g_s_a_w_p() is not const-correct :-( */ + (gchar **) argv[0] ? argv : argv+1, /* g_s_a_w_p() is not const-correct :-( */ NULL, /* envp */ G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH, #ifdef DBUS_UNIX -- 1.8.4.5