diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1e56976..da1ab7b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,19 +48,19 @@ jobs: run: | mkdir build cd build - cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_CXX_FLAGS="-O0 -g -W -Wextra -Wall -Wnon-virtual-dtor -Werror" -DCMAKE_VERBOSE_MAKEFILE=ON -DBUILD_TESTS=ON -DENABLE_PERF_TESTS=ON -DENABLE_STRESS_TESTS=ON -DBUILD_CODE_GEN=ON .. + cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="-O0 -g -W -Wextra -Wall -Wnon-virtual-dtor -Werror" -DCMAKE_VERBOSE_MAKEFILE=ON -DBUILD_TESTS=ON -DENABLE_PERF_TESTS=ON -DENABLE_STRESS_TESTS=ON -DBUILD_CODE_GEN=ON .. - name: configure-release if: matrix.build == 'shared-libsystemd' && matrix.os == 'ubuntu-22.04' run: | mkdir build cd build - cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_CXX_FLAGS="-O3 -DNDEBUG -W -Wextra -Wall -Wnon-virtual-dtor -Werror" -DCMAKE_VERBOSE_MAKEFILE=ON -DBUILD_TESTS=ON -DENABLE_PERF_TESTS=ON -DENABLE_STRESS_TESTS=ON -DBUILD_CODE_GEN=ON .. + cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_CXX_FLAGS="-O3 -DNDEBUG -W -Wextra -Wall -Wnon-virtual-dtor -Werror" -DCMAKE_VERBOSE_MAKEFILE=ON -DBUILD_TESTS=ON -DENABLE_PERF_TESTS=ON -DENABLE_STRESS_TESTS=ON -DBUILD_CODE_GEN=ON .. - name: configure-with-embedded-libsystemd if: matrix.build == 'embedded-static-libsystemd' run: | mkdir build cd build - cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_VERBOSE_MAKEFILE=ON -DBUILD_TESTS=ON -DENABLE_PERF_TESTS=ON -DENABLE_STRESS_TESTS=ON -DBUILD_CODE_GEN=ON -DBUILD_LIBSYSTEMD=ON -DLIBSYSTEMD_VERSION=244 .. + cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_VERBOSE_MAKEFILE=ON -DBUILD_TESTS=ON -DENABLE_PERF_TESTS=ON -DENABLE_STRESS_TESTS=ON -DBUILD_CODE_GEN=ON -DBUILD_LIBSYSTEMD=ON -DLIBSYSTEMD_VERSION=244 .. - name: make run: | cd build @@ -84,22 +84,3 @@ jobs: build/sdbus-c++*.deb build/sdbus-c++*.ddeb retention-days: 10 - freebsd-build: - name: build (freebsd, clang/libc++, basu) - runs-on: macos-12 # until https://github.com/actions/runner/issues/385 - steps: - - uses: actions/checkout@v2 - - name: Test in FreeBSD VM - uses: vmactions/freebsd-vm@v0 - with: - copyback: false - usesh: true - prepare: | - pkg install -y cmake ninja pkgconf basu expat googletest - run: | - cmake -B _build -G Ninja -DBUILD_CODE_GEN=ON -DBUILD_TESTS=ON -DENABLE_PERF_TESTS=ON -DENABLE_STRESS_TESTS=ON - cmake --build _build - cmake --install _build - pkg install -y dbus - service dbus onestart - ctest --output-on-failure --test-dir _build diff --git a/CMakeLists.txt b/CMakeLists.txt index 7332b23..bbe61b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ include(GNUInstallDirs) # Installation directories for `install` command and pkg # PERFORMING CHECKS & PREPARING THE DEPENDENCIES #------------------------------- -set(LIBSYSTEMD "systemd") +set(LIBSYSTEMD "libsystemd") option(BUILD_LIBSYSTEMD "Build libsystemd static library and incorporate it into libsdbus-c++" OFF) @@ -23,15 +23,9 @@ if(NOT BUILD_LIBSYSTEMD) message(WARNING "libsystemd not found, checking for libelogind instead") pkg_check_modules(Systemd IMPORTED_TARGET GLOBAL libelogind>=236) if(TARGET PkgConfig::Systemd) - set(LIBSYSTEMD "elogind") + set(LIBSYSTEMD "libelogind") string(REPLACE "." ";" VERSION_LIST ${Systemd_VERSION}) list(GET VERSION_LIST 0 Systemd_VERSION) - else() - message(WARNING "libelogind not found, checking for basu instead") - pkg_check_modules(Systemd IMPORTED_TARGET GLOBAL basu) - set(LIBSYSTEMD "basu") - # https://git.sr.ht/~emersion/basu/commit/d4d185d29a26 - set(Systemd_VERSION "240") endif() endif() if(NOT TARGET PkgConfig::Systemd) @@ -122,11 +116,7 @@ endif() # Having an object target allows unit tests to reuse already built sources without re-building add_library(sdbus-c++-objlib OBJECT ${SDBUSCPP_SRCS}) -target_compile_definitions(sdbus-c++-objlib PRIVATE - BUILD_LIB=1 - LIBSYSTEMD_VERSION=${LIBSYSTEMD_VERSION} - SDBUS_${LIBSYSTEMD} - SDBUS_HEADER=<${LIBSYSTEMD}/sd-bus.h>) +target_compile_definitions(sdbus-c++-objlib PRIVATE BUILD_LIB=1 LIBSYSTEMD_VERSION=${LIBSYSTEMD_VERSION}) target_include_directories(sdbus-c++-objlib PUBLIC $ $) if(DEFINED BUILD_SHARED_LIBS) diff --git a/src/Connection.cpp b/src/Connection.cpp index dea217c..d235ed1 100644 --- a/src/Connection.cpp +++ b/src/Connection.cpp @@ -31,7 +31,7 @@ #include #include #include "ScopeGuard.h" -#include SDBUS_HEADER +#include #include #include #include diff --git a/src/Connection.h b/src/Connection.h index c69627b..445c915 100644 --- a/src/Connection.h +++ b/src/Connection.h @@ -32,7 +32,7 @@ #include "IConnection.h" #include "ScopeGuard.h" #include "ISdBus.h" -#include SDBUS_HEADER +#include #include #include #include diff --git a/src/Error.cpp b/src/Error.cpp index 11625cb..e4a1f14 100644 --- a/src/Error.cpp +++ b/src/Error.cpp @@ -25,7 +25,7 @@ */ #include -#include SDBUS_HEADER +#include #include "ScopeGuard.h" namespace sdbus diff --git a/src/Flags.cpp b/src/Flags.cpp index ca20d5c..3b7b8d6 100644 --- a/src/Flags.cpp +++ b/src/Flags.cpp @@ -25,7 +25,7 @@ */ #include -#include SDBUS_HEADER +#include namespace sdbus { diff --git a/src/IConnection.h b/src/IConnection.h index 1c23bbe..74b7832 100644 --- a/src/IConnection.h +++ b/src/IConnection.h @@ -28,7 +28,7 @@ #define SDBUS_CXX_INTERNAL_ICONNECTION_H_ #include -#include SDBUS_HEADER +#include #include #include #include diff --git a/src/ISdBus.h b/src/ISdBus.h index 9ca8f3f..5fdd352 100644 --- a/src/ISdBus.h +++ b/src/ISdBus.h @@ -28,7 +28,7 @@ #ifndef SDBUS_CXX_ISDBUS_H #define SDBUS_CXX_ISDBUS_H -#include SDBUS_HEADER +#include namespace sdbus::internal { diff --git a/src/Message.cpp b/src/Message.cpp index c45493e..b68801d 100644 --- a/src/Message.cpp +++ b/src/Message.cpp @@ -31,7 +31,7 @@ #include "ISdBus.h" #include "IConnection.h" #include "ScopeGuard.h" -#include SDBUS_HEADER +#include #include namespace sdbus { diff --git a/src/Object.cpp b/src/Object.cpp index c6df821..6b6b3be 100644 --- a/src/Object.cpp +++ b/src/Object.cpp @@ -35,7 +35,7 @@ #include "IConnection.h" #include "Utils.h" #include "VTableUtils.h" -#include SDBUS_HEADER +#include #include #include diff --git a/src/Object.h b/src/Object.h index c22abe2..aad5c4c 100644 --- a/src/Object.h +++ b/src/Object.h @@ -29,7 +29,7 @@ #include #include "IConnection.h" -#include SDBUS_HEADER +#include #include #include #include diff --git a/src/Proxy.cpp b/src/Proxy.cpp index 8a760ca..061b620 100644 --- a/src/Proxy.cpp +++ b/src/Proxy.cpp @@ -32,7 +32,7 @@ #include "sdbus-c++/IConnection.h" #include "sdbus-c++/Error.h" #include "ScopeGuard.h" -#include SDBUS_HEADER +#include #include #include #include diff --git a/src/Proxy.h b/src/Proxy.h index f11f059..b0c4fac 100644 --- a/src/Proxy.h +++ b/src/Proxy.h @@ -29,7 +29,7 @@ #include #include "IConnection.h" -#include SDBUS_HEADER +#include #include #include #include diff --git a/src/SdBus.cpp b/src/SdBus.cpp index f99849a..b523b79 100644 --- a/src/SdBus.cpp +++ b/src/SdBus.cpp @@ -224,12 +224,7 @@ int SdBus::sd_bus_open_user_with_address(sd_bus **ret, const char* address) int SdBus::sd_bus_open_system_remote(sd_bus **ret, const char *host) { -#ifdef SDBUS_basu - // https://git.sr.ht/~emersion/basu/commit/01d33b244eb6 - return -EOPNOTSUPP; -#else return ::sd_bus_open_system_remote(ret, host); -#endif } int SdBus::sd_bus_request_name(sd_bus *bus, const char *name, uint64_t flags) diff --git a/src/Types.cpp b/src/Types.cpp index 5e4cc65..ca8f4a2 100644 --- a/src/Types.cpp +++ b/src/Types.cpp @@ -27,7 +27,7 @@ #include #include #include "MessageUtils.h" -#include SDBUS_HEADER +#include #include namespace sdbus { diff --git a/src/Utils.h b/src/Utils.h index 277ca91..7c044e3 100644 --- a/src/Utils.h +++ b/src/Utils.h @@ -28,7 +28,7 @@ #define SDBUS_CXX_INTERNAL_UTILS_H_ #include -#include SDBUS_HEADER +#include #if LIBSYSTEMD_VERSION>=246 #define SDBUS_CHECK_OBJECT_PATH(_PATH) \ diff --git a/src/VTableUtils.c b/src/VTableUtils.c index e848faf..a10f027 100644 --- a/src/VTableUtils.c +++ b/src/VTableUtils.c @@ -25,7 +25,7 @@ */ #include "VTableUtils.h" -#include SDBUS_HEADER +#include sd_bus_vtable createVTableStartItem(uint64_t flags) { diff --git a/src/VTableUtils.h b/src/VTableUtils.h index 03bdf31..bf34666 100644 --- a/src/VTableUtils.h +++ b/src/VTableUtils.h @@ -27,7 +27,7 @@ #ifndef SDBUS_CXX_INTERNAL_VTABLEUTILS_H_ #define SDBUS_CXX_INTERNAL_VTABLEUTILS_H_ -#include SDBUS_HEADER +#include #include #ifdef __cplusplus diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 56c4852..25ed6cd 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -104,9 +104,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}) #---------------------------------- add_executable(sdbus-c++-unit-tests ${UNITTESTS_SRCS}) -target_compile_definitions(sdbus-c++-unit-tests PRIVATE - LIBSYSTEMD_VERSION=${LIBSYSTEMD_VERSION} - SDBUS_HEADER=<${LIBSYSTEMD}/sd-bus.h>) +target_compile_definitions(sdbus-c++-unit-tests PRIVATE LIBSYSTEMD_VERSION=${LIBSYSTEMD_VERSION}) target_link_libraries(sdbus-c++-unit-tests sdbus-c++-objlib GTest::gmock) add_executable(sdbus-c++-integration-tests ${INTEGRATIONTESTS_SRCS}) @@ -140,22 +138,21 @@ endif() # INSTALLATION #---------------------------------- -include(GNUInstallDirs) set(TESTS_INSTALL_PATH "/opt/test/bin" CACHE STRING "Specifies where the test binaries will be installed") install(TARGETS sdbus-c++-unit-tests DESTINATION ${TESTS_INSTALL_PATH} COMPONENT test) install(TARGETS sdbus-c++-integration-tests DESTINATION ${TESTS_INSTALL_PATH} COMPONENT test) -install(FILES ${INTEGRATIONTESTS_SOURCE_DIR}/files/org.sdbuscpp.integrationtests.conf DESTINATION ${CMAKE_INSTALL_FULL_SYSCONFDIR}/dbus-1/system.d COMPONENT test) +install(FILES ${INTEGRATIONTESTS_SOURCE_DIR}/files/org.sdbuscpp.integrationtests.conf DESTINATION /etc/dbus-1/system.d COMPONENT test) if(ENABLE_PERF_TESTS) install(TARGETS sdbus-c++-perf-tests-client DESTINATION ${TESTS_INSTALL_PATH} COMPONENT test) install(TARGETS sdbus-c++-perf-tests-server DESTINATION ${TESTS_INSTALL_PATH} COMPONENT test) - install(FILES ${PERFTESTS_SOURCE_DIR}/files/org.sdbuscpp.perftests.conf DESTINATION ${CMAKE_INSTALL_FULL_SYSCONFDIR}/dbus-1/system.d COMPONENT test) + install(FILES ${PERFTESTS_SOURCE_DIR}/files/org.sdbuscpp.perftests.conf DESTINATION /etc/dbus-1/system.d COMPONENT test) endif() if(ENABLE_STRESS_TESTS) install(TARGETS sdbus-c++-stress-tests DESTINATION ${TESTS_INSTALL_PATH} COMPONENT test) - install(FILES ${STRESSTESTS_SOURCE_DIR}/files/org.sdbuscpp.stresstests.conf DESTINATION ${CMAKE_INSTALL_FULL_SYSCONFDIR}/dbus-1/system.d COMPONENT test) + install(FILES ${STRESSTESTS_SOURCE_DIR}/files/org.sdbuscpp.stresstests.conf DESTINATION /etc/dbus-1/system.d COMPONENT test) endif() #---------------------------------- diff --git a/tests/integrationtests/DBusMethodsTests.cpp b/tests/integrationtests/DBusMethodsTests.cpp index 43871d5..2d777b8 100644 --- a/tests/integrationtests/DBusMethodsTests.cpp +++ b/tests/integrationtests/DBusMethodsTests.cpp @@ -277,10 +277,6 @@ TEST_F(SdbusTestObject, CannotSetGeneralMethodTimeoutWithLibsystemdVersionLessTh TEST_F(SdbusTestObject, CanCallMethodSynchronouslyWithoutAnEventLoopThread) { -#if defined(__clang__) && defined(__FreeBSD__) - GTEST_SKIP() << "https://github.com/Kistler-Group/sdbus-cpp/issues/359"; -#endif - auto proxy = std::make_unique(BUS_NAME, OBJECT_PATH, sdbus::dont_run_event_loop_thread); auto multiplyRes = proxy->multiply(INT64_VALUE, DOUBLE_VALUE); diff --git a/tests/integrationtests/DBusStandardInterfacesTests.cpp b/tests/integrationtests/DBusStandardInterfacesTests.cpp index e648fac..cc85cdd 100644 --- a/tests/integrationtests/DBusStandardInterfacesTests.cpp +++ b/tests/integrationtests/DBusStandardInterfacesTests.cpp @@ -61,9 +61,12 @@ TEST_F(SdbusTestObject, PingsViaPeerInterface) TEST_F(SdbusTestObject, AnswersMachineUuidViaPeerInterface) { - if (::access("/etc/machine-id", F_OK) == -1 && - ::access("/var/lib/dbus/machine-id", F_OK) == -1) - GTEST_SKIP() << "/etc/machine-id and /var/lib/dbus/machine-id files do not exist, GetMachineId() will not work"; + // If /etc/machine-id does not exist in your system (which is very likely because you have + // a non-systemd Linux), org.freedesktop.DBus.Peer.GetMachineId() will not work. To solve + // this, you can create /etc/machine-id yourself as symlink to /var/lib/dbus/machine-id, + // and then org.freedesktop.DBus.Peer.GetMachineId() will start to work. + if (::access("/etc/machine-id", F_OK) == -1) + GTEST_SKIP() << "/etc/machine-id file does not exist, GetMachineId() will not work"; ASSERT_NO_THROW(m_proxy->GetMachineId()); }