From 72e735807efc194b0b791b6852e5a9b54320dc0b Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Mon, 30 Jan 2023 13:10:07 +0100 Subject: [PATCH 1/7] dbus/win: use a Unix socket if possible for autolaunch: protocol Unix domain sockets are used if the host on which dbus is running supports this. Due to this change, the minimum supported glib2 version on Windows is 2.72. --- dbus/dbus-server-socket.c | 2 +- dbus/dbus-server-socket.h | 3 +++ dbus/dbus-server-win.c | 17 +++++++++++++++-- dbus/dbus-sysdeps-win.c | 32 ++++++++++++++++++++++++++++++++ dbus/dbus-sysdeps.h | 3 +++ 5 files changed, 54 insertions(+), 3 deletions(-) diff --git a/dbus/dbus-server-socket.c b/dbus/dbus-server-socket.c index 5dc1b54e..2bb71f21 100644 --- a/dbus/dbus-server-socket.c +++ b/dbus/dbus-server-socket.c @@ -689,7 +689,7 @@ _dbus_server_new_for_domain_socket (const char *path, * @param error location to store reason for failure. * @returns the new server, or #NULL on failure. */ -static DBusServer * +DBusServer * _dbus_server_new_for_dir (const char *dir, DBusError *error) { diff --git a/dbus/dbus-server-socket.h b/dbus/dbus-server-socket.h index 31b086e8..1dcf9092 100644 --- a/dbus/dbus-server-socket.h +++ b/dbus/dbus-server-socket.h @@ -39,6 +39,9 @@ DBusServer* _dbus_server_new_for_socket (DBusSocket *fds, DBusServer* _dbus_server_new_for_autolaunch (const DBusString *address, DBusError *error); DBUS_PRIVATE_EXPORT +DBusServer* _dbus_server_new_for_dir (const char *dir, + DBusError *error); +DBUS_PRIVATE_EXPORT DBusServer* _dbus_server_new_for_tcp_socket (const char *host, const char *bind, const char *port, diff --git a/dbus/dbus-server-win.c b/dbus/dbus-server-win.c index af0b697e..1c5547b0 100644 --- a/dbus/dbus-server-win.c +++ b/dbus/dbus-server-win.c @@ -66,12 +66,25 @@ _dbus_server_listen_platform_specific (DBusAddressEntry *entry, const char *port = "0"; const char *family = "ipv4"; const char *scope = dbus_address_entry_get_value (entry, "scope"); + dbus_bool_t supported = FALSE; if (_dbus_daemon_is_session_bus_address_published (scope)) return DBUS_SERVER_LISTEN_ADDRESS_ALREADY_USED; - *server_p = _dbus_server_new_for_tcp_socket (host, bind, port, - family, error, FALSE); + if (!_dbus_win_check_af_unix_support (&supported, error)) + { + _DBUS_ASSERT_ERROR_IS_SET(error); + return DBUS_SERVER_LISTEN_DID_NOT_CONNECT; + } + + if (supported) + { + const char *tmp = _dbus_get_tmpdir (); + *server_p = _dbus_server_new_for_dir (tmp, error); + } + else + *server_p = _dbus_server_new_for_tcp_socket (host, bind, port, + family, error, FALSE); if (*server_p) { _DBUS_ASSERT_ERROR_IS_CLEAR(error); diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index e8fb78da..972a35a4 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -4517,5 +4517,37 @@ _dbus_listen_unix_socket (const char *path, return s; } +/** + * Checks and returns result for availability of unix domain sockets on Windows + * + * @param supported returns whether unix domain sockets are supported + * @param error return location for an error + * @returns #FALSE if error is set + */ +dbus_bool_t +_dbus_win_check_af_unix_support (dbus_bool_t *supported, + DBusError *error) +{ + SOCKET temp; + + if (!_dbus_win_startup_winsock ()) + { + _DBUS_SET_OOM (error); + return FALSE; + } + + *supported = FALSE; + + temp = socket (AF_UNIX, SOCK_STREAM, 0); + + if (temp != INVALID_SOCKET) + { + *supported = TRUE; + closesocket (temp); + } + + return TRUE; +} + /** @} end of sysdeps-win */ /* tests in dbus-sysdeps-util.c */ diff --git a/dbus/dbus-sysdeps.h b/dbus/dbus-sysdeps.h index e022d4f5..e8c8554a 100644 --- a/dbus/dbus-sysdeps.h +++ b/dbus/dbus-sysdeps.h @@ -589,6 +589,9 @@ DBusSocket _dbus_listen_unix_socket (const char *path, dbus_bool_t abstract, DBusError *error); +dbus_bool_t _dbus_win_check_af_unix_support (dbus_bool_t *supported, + DBusError *error); + DBusSocket _dbus_connect_exec (const char *path, char *const argv[], DBusError *error); From abde4af83bcbbc4a19116b4ef2cd4325b74d75f0 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Mon, 3 Feb 2025 23:08:07 +0100 Subject: [PATCH 2/7] Add dedicated manual test case for AF_UNIX support --- test/CMakeLists.txt | 1 + test/manual-socket-afunix.c | 298 ++++++++++++++++++++++++++++++++++++ test/meson.build | 6 + 3 files changed, 305 insertions(+) create mode 100644 test/manual-socket-afunix.c diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 032ba1f7..a4da8c53 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -94,6 +94,7 @@ add_helper_executable(test-exit ${test-exit_SOURCES} ${DBUS_INTERNAL_LIBRARIES}) # to link, hence the quoting here add_helper_executable(test-segfault "${test-segfault_SOURCES}") add_helper_executable(test-sleep-forever ${test-sleep-forever_SOURCES} ${DBUS_INTERNAL_LIBRARIES}) +add_helper_executable(manual-socket-afunix manual-socket-afunix.c dbus-testutils) add_helper_executable(manual-tcp ${manual-tcp_SOURCES} ${DBUS_INTERNAL_LIBRARIES}) add_helper_executable(manual-backtrace manual-backtrace.c dbus-1) if(WIN32) diff --git a/test/manual-socket-afunix.c b/test/manual-socket-afunix.c new file mode 100644 index 00000000..f3e56f74 --- /dev/null +++ b/test/manual-socket-afunix.c @@ -0,0 +1,298 @@ +/* + * SPDX-License-Identifier: MIT + * SPDX-FileCopyrightText: 2025 Ralf Habacker + */ + +#include +#include +#include + +#include +#include +#include +#include +#include +#ifdef DBUS_WIN +#include +#include +#include +#include +#define close(a) closesocket(a) +#undef errno +#define errno WSAGetLastError() +#define strerror(a) "" +#define unlink _unlink +#define F_OK 0 +#define access _access +#ifndef ERROR_NO_SUCH_DEVICE +#define ERROR_NO_SUCH_DEVICE 433 +#endif +#else +#include +#include +#include +#define INVALID_SOCKET -1 +#define SOCKET int +#endif + +#define SOCK_PATH "tpf_unix_sock.server" +#define DATA "Hello from server" + +static char* +sock_path(void) +{ + static DBusString path = _DBUS_STRING_INIT_INVALID; + static dbus_bool_t first = TRUE; + + if (first) + { + if (!_dbus_string_init (&path)) + goto out; + if (!_dbus_string_append (&path, _dbus_get_tmpdir ())) + goto out; + if (!_dbus_string_append (&path, "/" SOCK_PATH "-")) + goto out; + if (!_dbus_generate_random_ascii (&path, 6, NULL)) + goto out; + first = FALSE; + } + + return _dbus_string_get_data (&path); +out: + _dbus_test_fatal ("Could not setup socket path"); + return NULL; +} + +static dbus_bool_t +test_afunix_socket_raw (const char *test_data_dir _DBUS_GNUC_UNUSED) +{ + SOCKET accept_sock = INVALID_SOCKET, server_sock = INVALID_SOCKET, client_sock = INVALID_SOCKET; + int rc; + int bytes_rec = 0; + int ret = FALSE; + socklen_t len; + struct sockaddr_un server_sockaddr; + struct sockaddr_un client_sockaddr; + char buf[256]; + int backlog = 10; + + _DBUS_ZERO (server_sockaddr); + _DBUS_ZERO (client_sockaddr); + _DBUS_ZERO (buf); + +#ifdef DBUS_WIN + { + WSADATA data; + WORD version = MAKEWORD (2, 2); + rc = WSAStartup (version, &data); + if (rc == -1) + { + _dbus_test_fatal ("STARTUP ERROR: %d '%s'", WSAGetLastError(), ""); + goto err; + } + } +#endif + + server_sock = socket (AF_UNIX, SOCK_STREAM, 0); + + if (server_sock == INVALID_SOCKET) + { +#ifdef DBUS_WIN + if (errno == WSAEAFNOSUPPORT) + { + _dbus_test_skip ("No AF_UNIX support available"); + ret = TRUE; + goto err; + } +#endif + _dbus_test_fatal ("server SOCKET ERROR: %d '%s'", errno, strerror(errno)); + goto err; + } + else + { + _dbus_test_diag ("AF_UNIX stream socket created for server"); + } + + client_sock = socket (AF_UNIX, SOCK_STREAM, 0); + + if (client_sock == INVALID_SOCKET) + { +#ifdef DBUS_WIN + if (errno == WSAEAFNOSUPPORT) + { + _dbus_test_skip ("No AF_UNIX support available"); + ret = TRUE; + goto err; + } +#endif + _dbus_test_fatal ("client SOCKET ERROR = %d '%s'", errno, strerror(errno)); + goto err; + } + else + _dbus_test_diag ("AF_UNIX stream socket created for client"); + + server_sockaddr.sun_family = AF_UNIX; + server_sockaddr.sun_path[0] = '\0'; + strncat (server_sockaddr.sun_path, sock_path(), sizeof (server_sockaddr.sun_path) - 1); + len = sizeof (server_sockaddr); + rc = unlink (sock_path()); + + if (rc == -1) + { +#ifdef DBUS_WIN + if (errno == ERROR_NO_SUCH_DEVICE) + { + _dbus_test_diag ("got error ERROR_NO_SUCH_DEVICE on unlinking file, ignoring"); + } + else +#endif + if (errno == ENOENT) + { + _dbus_test_diag ("AF_UNIX socket file did not exist"); + } + else + { + _dbus_test_fatal ("Unlinking AF_UNIX socket file fails = %d '%s'", errno, strerror(errno)); + goto err; + } + } + + if (access (sock_path(), F_OK) == 0) + { + _dbus_test_fatal ("AF_UNIX socket file '%s' still present", sock_path()); + } + + rc = bind (server_sock, (struct sockaddr *) &server_sockaddr, len); + + if (rc == -1) + { +#ifdef DBUS_WIN + if (errno == WSAEAFNOSUPPORT) + { + _dbus_test_skip ("Binding to AF_UNIX socket failed, no support available"); + return FALSE; + } + else if (errno == WSAEADDRINUSE) + { + _dbus_test_diag ("Binding to AF_UNIX socket failed, address in use"); + return FALSE; + } +#endif + _dbus_test_fatal ("BIND ERROR: %d '%s'", errno, strerror(errno)); + goto err; + } + + rc = listen (server_sock, backlog); + if (rc == -1) + { + _dbus_test_fatal ("LISTEN ERROR: %d '%s'", errno, strerror(errno)); + goto err; + } + else + _dbus_test_diag ("Listening on AF_UNIX server socket"); + + rc = connect (client_sock, (struct sockaddr *) &server_sockaddr, len); + if(rc == -1) + { + _dbus_test_fatal ("CONNECT ERROR = %d '%s'", errno, strerror(errno)); + goto err; + } + else + { + _dbus_test_diag ("Connected to AF_UNIX server socket"); + } + + accept_sock = accept (server_sock, (struct sockaddr *) &client_sockaddr, &len); + if (accept_sock == INVALID_SOCKET) + { + _dbus_test_fatal ("ACCEPT ERROR: %d '%s'", errno, strerror(errno)); + goto err; + } + else + { + _dbus_test_diag ("AF_UNIX server accepted connection"); + } + + len = sizeof (client_sockaddr); + rc = getsockname (server_sock, (struct sockaddr *) &client_sockaddr, &len); + if (rc == -1) + { + _dbus_test_fatal ("GETPEERNAME ERROR: %d '%s'", errno, strerror(errno)); + goto err; + } + else + _dbus_test_diag ("AF_UNIX server socket filepath: '%s'", client_sockaddr.sun_path); + + len = sizeof (client_sockaddr); + rc = getsockname (accept_sock, (struct sockaddr *) &client_sockaddr, &len); + if (rc == -1) + { + _dbus_test_fatal ("GETSOCKNAME ERROR: %d '%s'", errno, strerror(errno)); + goto err; + } + else + _dbus_test_diag ("Accepted AF_UNIX socket filepath: '%s'", client_sockaddr.sun_path); + + len = sizeof (client_sockaddr); + rc = getpeername (accept_sock, (struct sockaddr *) &client_sockaddr, &len); + if (rc == -1) + { + _dbus_test_fatal ("GETPEERNAME ERROR: %d '%s'", errno, strerror(errno)); + goto err; + } + else + _dbus_test_diag ("Client AF_UNIX socket filepath: '%s'", client_sockaddr.sun_path); + + memset (buf, 0, sizeof (buf)); + strcpy (buf, DATA); + _dbus_test_diag ("Sending data over AF_UNIX socket ..."); + rc = send (client_sock, buf, strlen(buf) + 1, 0); + if (rc == -1) + { + _dbus_test_fatal ("SEND ERROR: %d '%s'", errno, strerror(errno)); + goto err; + } + else + { + _dbus_test_diag ("Data sent!"); + } + + _dbus_test_diag ("Waiting to read data from AF_UNIX socket ..."); + bytes_rec = recv (accept_sock, buf, sizeof(buf), 0); + if (bytes_rec == -1 || bytes_rec != strlen(DATA) + 1) + { + _dbus_test_diag ("RECV ERROR: %d '%s'", errno, strerror(errno)); + goto err; + } + else + { + _dbus_test_diag ("Data from AF_UNIX socket received = '%s'", buf); + } + ret = TRUE; +err: + if (server_sock != INVALID_SOCKET) + close (server_sock); + if (accept_sock != INVALID_SOCKET) + close (accept_sock); + if (client_sock != INVALID_SOCKET) + close (client_sock); + rc = unlink (sock_path()); + if (rc == -1) + _dbus_test_diag ("unlink AF_UNIX socket file failure: %d '%s'", errno, strerror(errno)); + + return ret; +} + +static DBusTestCase tests[] = +{ + { "test dbus unix socket raw", test_afunix_socket_raw }, + { NULL } +}; + +int +main (int argc, char **argv) +{ + return _dbus_test_main (argc, argv, _DBUS_N_ELEMENTS (tests), tests, + DBUS_TEST_FLAGS_NONE, + NULL, NULL); +} diff --git a/test/meson.build b/test/meson.build index a60afac6..62b07d4f 100644 --- a/test/meson.build +++ b/test/meson.build @@ -425,6 +425,12 @@ tests += [ 'link': [ libdbus_testutils, ], 'test': false, }, + { + 'name': 'manual-socket-afunix', + 'srcs': [ 'manual-socket-afunix.c' ], + 'link': [ libdbus_testutils ], + 'test': false, + }, { 'name': 'manual-tcp', 'srcs': [ 'manual-tcp.c' ], From bdfef3916f20a07b8e66ce7286ec6e060d619963 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Sat, 15 Mar 2025 12:47:02 +0100 Subject: [PATCH 3/7] CI: Use official wine-staging package on openSUSE to get AF_UNIX support AF_UNIX support was added to wine-staging with version 10.2. --- tools/ci-install.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tools/ci-install.sh b/tools/ci-install.sh index 72d2165f..fc99f1be 100755 --- a/tools/ci-install.sh +++ b/tools/ci-install.sh @@ -247,11 +247,17 @@ case "$ci_distro" in # cross packages=( "${packages[@]}" - wine xvfb-run ) - - # add required repos + if ! zypper lr Emulators > /dev/null; then + $zypper ar --refresh --no-gpgcheck \ + "https://download.opensuse.org/repositories/Emulators/$version/Emulators.repo" + fi + packages=( + "${packages[@]}" + wine-staging + wine-staging-32bit + ) if [ "${ci_host%%-*}" = x86_64 ]; then bits="64" else From b8292da025eada2c054f1c012cbfbd8a522d370a Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Sat, 15 Mar 2025 13:33:05 +0100 Subject: [PATCH 4/7] cmake: Fix bug not enabling test wrapper for running minimal tests when cross compiling The test wrapper needs to be enabled for running any test when cross compiling. --- cmake/modules/Macros.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmake/modules/Macros.cmake b/cmake/modules/Macros.cmake index 14d06c24..6a2b978b 100644 --- a/cmake/modules/Macros.cmake +++ b/cmake/modules/Macros.cmake @@ -1,6 +1,6 @@ option(DBUS_USE_WINE "set to 1 or ON to support running test cases with Wine" OFF) -if((DBUS_ENABLE_MODULAR_TESTS OR DBUS_ENABLE_INTRUSIVE_TESTS) AND CMAKE_CROSSCOMPILING AND CMAKE_SYSTEM_NAME STREQUAL "Windows") +if(CMAKE_CROSSCOMPILING AND CMAKE_SYSTEM_NAME STREQUAL "Windows") if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux") find_file(WINE_EXECUTABLE NAMES wine @@ -35,6 +35,7 @@ if((DBUS_ENABLE_MODULAR_TESTS OR DBUS_ENABLE_INTRUSIVE_TESTS) AND CMAKE_CROSSCOM set(Z_DRIVE_IF_WINE "z:") if(DBUS_USE_WINE AND WINE_EXECUTABLE) set(TEST_WRAPPER "${WINE_EXECUTABLE}") + message(STATUS "Using wrapper for running tests: ${TEST_WRAPPER}") endif() endif() From 4cdb60a78cdad3c82be544e61db6056501c80ad1 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Sat, 27 Dec 2025 09:18:53 +0100 Subject: [PATCH 5/7] cmake: extend macro add_test_executable() to get specific environment variables --- cmake/modules/Macros.cmake | 30 ++++++++-- test/CMakeLists.txt | 102 +++++++++++++++++----------------- test/name-test/CMakeLists.txt | 18 +++--- 3 files changed, 86 insertions(+), 64 deletions(-) diff --git a/cmake/modules/Macros.cmake b/cmake/modules/Macros.cmake index 6a2b978b..24874068 100644 --- a/cmake/modules/Macros.cmake +++ b/cmake/modules/Macros.cmake @@ -115,10 +115,18 @@ endmacro() # create executable and add an associated unit test # # see @ref add_helper_executable for supported parameters +# @param ARGS additional arguments added to the test command in front of the target file +# @param ENV additional environment variables to provide to the running test +# @param LIBS additional libraries to link the executable with # macro(add_test_executable _target _source) - add_helper_executable(${_target} "${_source}" ${ARGN}) - add_unit_test(${_target} ${_target}) + set(options) + set(oneValueArgs) + set(multiValueArgs ARGS ENV LIBS) + cmake_parse_arguments(ATE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + add_helper_executable(${_target} "${_source}" LIBS ${ATE_LIBS}) + add_unit_test(${_target} ${_target} ARGS ${ATE_ARGS} ENV ${ATE_ENV}) endmacro() # @@ -134,31 +142,45 @@ endmacro() # # @param _target target name # @param _source sources to add to this target +# @param LIBS additional libraries to link the executable with # macro(add_helper_executable _target _source) + set(options) + set(oneValueArgs) + set(multiValueArgs LIBS) + cmake_parse_arguments(AHE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + set(_sources "${_source}") if(WIN32 AND NOT MSVC) # avoid triggering UAC add_uac_manifest(_sources) endif() add_executable(${_target} ${_sources}) - target_link_libraries(${_target} ${ARGN}) + target_link_libraries(${_target} ${AHE_LIBS}) endmacro() # # create executable and add an associated unit test with dbus session setup # # see @ref add_helper_executable for supported parameters +# see @ref add_unit_test for supported parameters # macro(add_session_test_executable _target _source) - add_helper_executable(${_target} "${_source}" ${ARGN}) + set(options) + set(oneValueArgs) + set(multiValueArgs ARGS ENV LIBS) + cmake_parse_arguments(ASTE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + add_helper_executable(${_target} "${_source}" LIBS ${ASTE_LIBS}) add_unit_test(${_target} ${_target} ARGS ${DBUS_TEST_RUN_SESSION} --config-file=${DBUS_TEST_DATA}/valid-config-files/tmp-session.conf --dbus-daemon=${DBUS_TEST_DAEMON} + ${ASTE_ARGS} ENV "DBUS_SESSION_BUS_PID=" + ${ASTE_ENV} ) endmacro() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index a4da8c53..60059310 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -74,36 +74,36 @@ set(manual-paths_SOURCES 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) -add_test_executable(test-shell ${test-shell_SOURCES} ${DBUS_INTERNAL_LIBRARIES}) -add_test_executable(test-string internals/strings.c dbus-testutils) -add_test_executable(test-printf internals/printf.c dbus-testutils) -add_helper_executable(test-privserver test-privserver.c dbus-testutils) -add_helper_executable(test-shell-service ${test-shell-service_SOURCES} dbus-testutils) +add_helper_executable(manual-dir-iter ${manual-dir-iter_SOURCES} LIBS ${DBUS_INTERNAL_LIBRARIES}) +add_helper_executable(test-service ${test-service_SOURCES} LIBS dbus-testutils) +add_helper_executable(test-names ${test-names_SOURCES} LIBS dbus-testutils) +add_test_executable(test-shell ${test-shell_SOURCES} LIBS ${DBUS_INTERNAL_LIBRARIES}) +add_test_executable(test-string internals/strings.c LIBS dbus-testutils) +add_test_executable(test-printf internals/printf.c LIBS dbus-testutils) +add_helper_executable(test-privserver test-privserver.c LIBS dbus-testutils) +add_helper_executable(test-shell-service ${test-shell-service_SOURCES} LIBS dbus-testutils) if(NOT WINCE AND ENABLE_TRADITIONAL_ACTIVATION) - add_test_executable(test-spawn-oom internals/spawn-oom.c dbus-testutils) + add_test_executable(test-spawn-oom internals/spawn-oom.c LIBS dbus-testutils) endif() if(ENABLE_TRADITIONAL_ACTIVATION) - add_helper_executable(test-spawn ${test-spawn_SOURCES} ${DBUS_INTERNAL_LIBRARIES}) + add_helper_executable(test-spawn ${test-spawn_SOURCES} LIBS ${DBUS_INTERNAL_LIBRARIES}) endif() -add_helper_executable(test-exit ${test-exit_SOURCES} ${DBUS_INTERNAL_LIBRARIES}) +add_helper_executable(test-exit ${test-exit_SOURCES} LIBS ${DBUS_INTERNAL_LIBRARIES}) # the second argument of add_helper_executable() is a whitespace-separated # list of source files and the third and subsequent arguments are libraries # to link, hence the quoting here add_helper_executable(test-segfault "${test-segfault_SOURCES}") -add_helper_executable(test-sleep-forever ${test-sleep-forever_SOURCES} ${DBUS_INTERNAL_LIBRARIES}) -add_helper_executable(manual-socket-afunix manual-socket-afunix.c dbus-testutils) -add_helper_executable(manual-tcp ${manual-tcp_SOURCES} ${DBUS_INTERNAL_LIBRARIES}) -add_helper_executable(manual-backtrace manual-backtrace.c dbus-1) +add_helper_executable(test-sleep-forever ${test-sleep-forever_SOURCES} LIBS ${DBUS_INTERNAL_LIBRARIES}) +add_helper_executable(manual-socket-afunix manual-socket-afunix.c LIBS dbus-testutils) +add_helper_executable(manual-tcp ${manual-tcp_SOURCES} LIBS ${DBUS_INTERNAL_LIBRARIES}) +add_helper_executable(manual-backtrace manual-backtrace.c LIBS dbus-1) if(WIN32) - add_helper_executable(manual-paths ${manual-paths_SOURCES} dbus-testutils) + add_helper_executable(manual-paths ${manual-paths_SOURCES} LIBS dbus-testutils) endif() if(DBUS_ENABLE_INTRUSIVE_TESTS) - add_test_executable(test-atomic ${test-atomic_SOURCES} dbus-testutils) - add_test_executable(test-hash internals/hash.c dbus-testutils) + add_test_executable(test-atomic ${test-atomic_SOURCES} LIBS dbus-testutils) + add_test_executable(test-hash internals/hash.c LIBS dbus-testutils) set_target_properties(test-hash PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS}) set(SOURCES @@ -111,7 +111,7 @@ if(DBUS_ENABLE_INTRUSIVE_TESTS) internals/dbus-marshal-recursive-util.h internals/marshal-recursive.c ) - add_test_executable(test-marshal-recursive "${SOURCES}" dbus-testutils) + add_test_executable(test-marshal-recursive "${SOURCES}" LIBS dbus-testutils) set_target_properties(test-marshal-recursive PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS}) set(SOURCES @@ -123,7 +123,7 @@ if(DBUS_ENABLE_INTRUSIVE_TESTS) internals/dbus-message-util.h internals/message-internals.c ) - add_test_executable(test-message-internals "${SOURCES}" dbus-testutils) + add_test_executable(test-message-internals "${SOURCES}" LIBS dbus-testutils) set_target_properties(test-message-internals PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS}) set(SOURCES @@ -143,39 +143,39 @@ if(DBUS_ENABLE_INTRUSIVE_TESTS) internals/misc-internals.h internals/sha.c ) - add_test_executable(test-misc-internals "${SOURCES}" dbus-testutils) + add_test_executable(test-misc-internals "${SOURCES}" LIBS dbus-testutils) set_target_properties(test-misc-internals PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS}) - add_test_executable(test-platform-mutex test-platform-mutex.c ${DBUS_INTERNAL_LIBRARIES} dbus-testutils) + add_test_executable(test-platform-mutex test-platform-mutex.c LIBS ${DBUS_INTERNAL_LIBRARIES} dbus-testutils) set(SOURCES bus/main.c bus/common.c bus/common.h) - add_test_executable(test-bus "${SOURCES}" dbus-daemon-internal dbus-testutils ${EXPAT_LIBRARIES}) + add_test_executable(test-bus "${SOURCES}" LIBS dbus-daemon-internal dbus-testutils ${EXPAT_LIBRARIES}) set_target_properties(test-bus PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS}) if(ENABLE_TRADITIONAL_ACTIVATION) set(SOURCES bus/normal-activation.c bus/common.c bus/common.h) - add_test_executable(test-bus-normal-activation "${SOURCES}" dbus-daemon-internal dbus-testutils ${EXPAT_LIBRARIES}) + add_test_executable(test-bus-normal-activation "${SOURCES}" LIBS dbus-daemon-internal dbus-testutils ${EXPAT_LIBRARIES}) set_target_properties(test-bus-normal-activation PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS}) endif() set(SOURCES bus/dispatch-sha1.c bus/common.c bus/common.h) - add_test_executable(test-bus-dispatch-sha1 "${SOURCES}" dbus-daemon-internal dbus-testutils ${EXPAT_LIBRARIES}) + add_test_executable(test-bus-dispatch-sha1 "${SOURCES}" LIBS dbus-daemon-internal dbus-testutils ${EXPAT_LIBRARIES}) set_target_properties(test-bus-dispatch-sha1 PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS}) if(NOT WIN32) - add_test_executable(test-bus-system bus/system.c launch-helper-internal dbus-testutils) - add_test_executable(test-counter internals/counter.c dbus-testutils) + add_test_executable(test-bus-system bus/system.c LIBS launch-helper-internal dbus-testutils) + add_test_executable(test-counter internals/counter.c LIBS dbus-testutils) if(ENABLE_TRADITIONAL_ACTIVATION) - add_test_executable(test-bus-launch-helper-oom bus/launch-helper-oom.c launch-helper-internal dbus-testutils) - add_helper_executable(dbus-daemon-launch-helper-for-tests bus/launch-helper-for-tests.c launch-helper-internal) + add_test_executable(test-bus-launch-helper-oom bus/launch-helper-oom.c LIBS launch-helper-internal dbus-testutils) + add_helper_executable(dbus-daemon-launch-helper-for-tests bus/launch-helper-for-tests.c LIBS launch-helper-internal) set(SOURCES bus/failed-helper-activation.c bus/common.c bus/common.h) - add_test_executable(test-bus-failed-helper-activation "${SOURCES}" dbus-daemon-internal dbus-testutils ${EXPAT_LIBRARIES}) + add_test_executable(test-bus-failed-helper-activation "${SOURCES}" LIBS dbus-daemon-internal dbus-testutils ${EXPAT_LIBRARIES}) set_target_properties(test-bus-failed-helper-activation PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS}) set(SOURCES bus/helper-activation.c bus/common.c bus/common.h) - add_test_executable(test-bus-helper-activation "${SOURCES}" dbus-daemon-internal dbus-testutils ${EXPAT_LIBRARIES}) + add_test_executable(test-bus-helper-activation "${SOURCES}" LIBS dbus-daemon-internal dbus-testutils ${EXPAT_LIBRARIES}) set_target_properties(test-bus-helper-activation PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS}) endif() endif() @@ -199,26 +199,26 @@ if(DBUS_WITH_GLIB) set(TEST_LIBRARIES ${DBUS_INTERNAL_LIBRARIES} dbus-testutils dbus-testutils-glib ${GLIB2_LIBRARIES}) - add_test_executable(test-assertions internals/assertions.c ${TEST_LIBRARIES}) - add_test_executable(test-corrupt corrupt.c ${TEST_LIBRARIES}) - add_test_executable(test-dbus-daemon dbus-daemon.c ${TEST_LIBRARIES}) - add_test_executable(test-dbus-daemon-eavesdrop dbus-daemon-eavesdrop.c ${TEST_LIBRARIES}) - add_test_executable(test-desktop-file internals/desktop-file.c ${TEST_LIBRARIES}) - add_test_executable(test-fdpass fdpass.c ${TEST_LIBRARIES}) - add_test_executable(test-header-fields header-fields.c ${TEST_LIBRARIES}) - add_test_executable(test-loopback loopback.c ${TEST_LIBRARIES}) - add_test_executable(test-marshal marshal.c ${TEST_LIBRARIES}) - add_test_executable(test-monitor monitor.c ${TEST_LIBRARIES}) - add_test_executable(test-refs internals/refs.c ${TEST_LIBRARIES}) - add_test_executable(test-relay relay.c ${TEST_LIBRARIES}) - add_test_executable(test-server-oom internals/server-oom.c ${TEST_LIBRARIES}) - add_test_executable(test-syntax syntax.c ${TEST_LIBRARIES}) - add_test_executable(test-sysdeps internals/sysdeps.c ${TEST_LIBRARIES}) - add_test_executable(test-syslog internals/syslog.c ${TEST_LIBRARIES}) - add_test_executable(test-uid-permissions uid-permissions.c ${TEST_LIBRARIES}) - add_test_executable(test-userdb internals/userdb.c ${TEST_LIBRARIES}) - add_helper_executable(manual-authz manual-authz.c ${TEST_LIBRARIES}) - add_helper_executable(manual-test-thread-blocking thread-blocking.c ${TEST_LIBRARIES}) + add_test_executable(test-assertions internals/assertions.c LIBS ${TEST_LIBRARIES}) + add_test_executable(test-corrupt corrupt.c LIBS ${TEST_LIBRARIES}) + add_test_executable(test-dbus-daemon dbus-daemon.c LIBS ${TEST_LIBRARIES}) + add_test_executable(test-dbus-daemon-eavesdrop dbus-daemon-eavesdrop.c LIBS ${TEST_LIBRARIES}) + add_test_executable(test-desktop-file internals/desktop-file.c LIBS ${TEST_LIBRARIES}) + add_test_executable(test-fdpass fdpass.c LIBS ${TEST_LIBRARIES}) + add_test_executable(test-header-fields header-fields.c LIBS ${TEST_LIBRARIES}) + add_test_executable(test-loopback loopback.c LIBS ${TEST_LIBRARIES}) + add_test_executable(test-marshal marshal.c LIBS ${TEST_LIBRARIES}) + add_test_executable(test-monitor monitor.c LIBS ${TEST_LIBRARIES}) + add_test_executable(test-refs internals/refs.c LIBS ${TEST_LIBRARIES}) + add_test_executable(test-relay relay.c LIBS ${TEST_LIBRARIES}) + add_test_executable(test-server-oom internals/server-oom.c LIBS ${TEST_LIBRARIES}) + add_test_executable(test-syntax syntax.c LIBS ${TEST_LIBRARIES}) + add_test_executable(test-sysdeps internals/sysdeps.c LIBS ${TEST_LIBRARIES}) + add_test_executable(test-syslog internals/syslog.c LIBS ${TEST_LIBRARIES}) + add_test_executable(test-uid-permissions uid-permissions.c LIBS ${TEST_LIBRARIES}) + add_test_executable(test-userdb internals/userdb.c LIBS ${TEST_LIBRARIES}) + add_helper_executable(manual-authz manual-authz.c LIBS ${TEST_LIBRARIES}) + add_helper_executable(manual-test-thread-blocking thread-blocking.c LIBS ${TEST_LIBRARIES}) endif() ### keep these in creation order, i.e. uppermost dirs first diff --git a/test/name-test/CMakeLists.txt b/test/name-test/CMakeLists.txt index 098993ae..b7ec8cd7 100644 --- a/test/name-test/CMakeLists.txt +++ b/test/name-test/CMakeLists.txt @@ -1,20 +1,20 @@ add_definitions(${DBUS_INTERNAL_CLIENT_DEFINITIONS}) if(WIN32) - add_test_executable(test-autolaunch-win test-autolaunch-win.c ${DBUS_INTERNAL_LIBRARIES} dbus-testutils) + add_test_executable(test-autolaunch-win test-autolaunch-win.c LIBS ${DBUS_INTERNAL_LIBRARIES} dbus-testutils) else() - add_helper_executable(test-autolaunch test-autolaunch.c dbus-testutils) + add_helper_executable(test-autolaunch test-autolaunch.c LIBS dbus-testutils) endif() -add_session_test_executable(test-ids test-ids.c ${DBUS_INTERNAL_LIBRARIES}) -add_session_test_executable(test-pending-call-disconnected test-pending-call-disconnected.c ${DBUS_INTERNAL_LIBRARIES}) +add_session_test_executable(test-ids test-ids.c LIBS ${DBUS_INTERNAL_LIBRARIES}) +add_session_test_executable(test-pending-call-disconnected test-pending-call-disconnected.c LIBS ${DBUS_INTERNAL_LIBRARIES}) if(ENABLE_TRADITIONAL_ACTIVATION) - add_session_test_executable(test-pending-call-dispatch test-pending-call-dispatch.c ${DBUS_INTERNAL_LIBRARIES}) - add_session_test_executable(test-pending-call-timeout test-pending-call-timeout.c ${DBUS_INTERNAL_LIBRARIES}) + add_session_test_executable(test-pending-call-dispatch test-pending-call-dispatch.c LIBS ${DBUS_INTERNAL_LIBRARIES}) + add_session_test_executable(test-pending-call-timeout test-pending-call-timeout.c LIBS ${DBUS_INTERNAL_LIBRARIES}) endif() -add_session_test_executable(test-shutdown test-shutdown.c dbus-testutils) +add_session_test_executable(test-shutdown test-shutdown.c LIBS dbus-testutils) if(ENABLE_TRADITIONAL_ACTIVATION) - add_session_test_executable(test-privserver-client test-privserver-client.c dbus-testutils) - add_session_test_executable(test-thread-init test-threads-init.c ${DBUS_INTERNAL_LIBRARIES}) + add_session_test_executable(test-privserver-client test-privserver-client.c LIBS dbus-testutils) + add_session_test_executable(test-thread-init test-threads-init.c LIBS ${DBUS_INTERNAL_LIBRARIES}) endif() From cac337cc7674f50f57f8cfefccd8fc7a629c1eb3 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Sat, 22 Mar 2025 10:44:14 +0100 Subject: [PATCH 6/7] tools/ci-build.sh: use WINEPATH environment variable to setup wine path --- tools/ci-build.sh | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/tools/ci-build.sh b/tools/ci-build.sh index b258c951..372dd1e1 100755 --- a/tools/ci-build.sh +++ b/tools/ci-build.sh @@ -59,25 +59,8 @@ init_wine() { addpath="$addpath$d$wb" d=";" done - - # create registry file from template - local wineaddpath=$(echo "$addpath" | sed 's,\\,\\\\\\\\,g') - sed "s,@PATH@,$wineaddpath,g" ../tools/user-path.reg.in > user-path.reg - - # add path to registry - wine regedit /C user-path.reg - - # check if path(s) has been set and break if not - local o=$(wine cmd /C "echo %PATH%") - case "$o" in - (*z:* | *Z:*) - # OK - ;; - (*) - echo "Failed to add Unix paths '$*' to path: Wine %PATH% = $o" >&2 - exit 1 - ;; - esac + # setup paths for wine + export WINEPATH=$addpath } # ci_buildsys: From 0c1b525c880c9f34b27ec94771929ed68c6d7b72 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Mon, 30 Jan 2023 13:10:07 +0100 Subject: [PATCH 7/7] cmake,meson: Set minimum glib version to 2.72 This version is required for glib-based tests with AF_UNIX support under Windows. As dbus is at the beginning of a new development branch and 2.72 is quite old (2022), the minimum version has been unconditionally raised. --- CMakeLists.txt | 3 ++- meson.build | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c6aa0a08..d710de15 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -182,7 +182,8 @@ endif() find_package(EXPAT) find_package(X11) -find_package(GLIB2) +set(GLIB_MIN_VERSION 2.72) # for AF_UNIX +find_package(GLIB2 ${GLIB_MIN_VERSION}) if(GLIB2_FOUND) option(DBUS_WITH_GLIB "build with glib" ON) endif() diff --git a/meson.build b/meson.build index 7281b7ec..6ac73a3c 100644 --- a/meson.build +++ b/meson.build @@ -397,11 +397,12 @@ endif # a running dbus-daemon will be disabled if message_bus is not set. message_bus = get_option('message_bus') +minimum_glib = '2.72' # for AF_UNIX if get_option('modular_tests').disabled() glib = dependency('', required: false) else glib = dependency( - 'glib-2.0', version: '>=2.40', + 'glib-2.0', version: '>=' + minimum_glib, required: get_option('modular_tests'), fallback: ['glib', 'libglib_dep'], default_options: fallback_subproject_options + [