diff options
-rw-r--r-- | .travis.yml | 50 | ||||
-rw-r--r-- | bus/activation.c | 43 | ||||
-rw-r--r-- | bus/selinux.c | 2 | ||||
-rw-r--r-- | bus/test-launch-helper.c | 2 | ||||
-rw-r--r-- | bus/test-main.c | 2 | ||||
-rw-r--r-- | bus/test-system.c | 2 | ||||
-rw-r--r-- | cmake/i686-w64-mingw32.cmake | 20 | ||||
-rw-r--r-- | cmake/modules/Macros.cmake | 4 | ||||
-rw-r--r-- | cmake/test/CMakeLists.txt | 3 | ||||
-rw-r--r-- | dbus/dbus-internals.c | 6 | ||||
-rw-r--r-- | dbus/dbus-test-main.c | 2 | ||||
-rw-r--r-- | test/Makefile.am | 2 | ||||
-rwxr-xr-x | tools/ci-build.sh | 204 |
13 files changed, 322 insertions, 20 deletions
diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..db296739 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,50 @@ +sudo: required +dist: trusty +language: c +install: + # travis-ci has a sources list for Chrome which doesn't support i386 + - ": | sudo tee /etc/apt/sources.list.d/google-chrome.list" + - test "$dbus_ci_host" != mingw || sudo dpkg --add-architecture i386 + - sudo apt-get -qq -y update + - sudo apt-get -qq -y build-dep dbus + - > + sudo apt-get -qq -y install + automake + autotools-dev + debhelper + dh-autoreconf + doxygen + dpkg-dev + gnome-desktop-testing + libapparmor-dev + libaudit-dev + libcap-ng-dev + libexpat-dev + libglib2.0-dev + libselinux1-dev + libx11-dev + python + python-dbus + python-gi + valgrind + xmlto + xsltproc + - > + test "$dbus_ci_host" != mingw || sudo apt-get -qq -y install + binutils-mingw-w64-i686 g++-mingw-w64-i686 wine:i386 +script: + # python-dbus and python-gi aren't available to Travis's version of + # Python in /opt, which it uses as a default + - PYTHON=/usr/bin/python dbus_ci_parallel=2 dbus_ci_sudo=yes ./tools/ci-build.sh + +env: + - dbus_ci_variant=release + - dbus_ci_variant=debug + - dbus_ci_variant=reduced + - dbus_ci_variant=legacy + - dbus_ci_buildsys=cmake + - dbus_ci_host=mingw + - dbus_ci_host=mingw dbus_ci_variant=debug + - dbus_ci_host=mingw dbus_ci_buildsys=cmake + +# vim:set sw=2 sts=2 et: diff --git a/bus/activation.c b/bus/activation.c index 7b1ab063..d1169e67 100644 --- a/bus/activation.c +++ b/bus/activation.c @@ -1418,7 +1418,8 @@ pending_activation_finished_cb (DBusBabysitter *babysitter, { BusPendingActivation *p = _dbus_hash_iter_get_value (&iter); - if (p != pending_activation && strcmp (p->exec, pending_activation->exec) == 0) + if (p != pending_activation && p->exec != NULL && + strcmp (p->exec, pending_activation->exec) == 0) pending_activation_failed (p, &error); } @@ -1744,9 +1745,19 @@ bus_activation_activate_service (BusActivation *activation, return FALSE; } - entry = activation_find_entry (activation, service_name, error); - if (!entry) - return FALSE; + if (bus_context_get_systemd_activation (activation->context) && + strcmp (service_name, "org.freedesktop.systemd1") == 0) + { + /* if we're doing systemd activation, we assume systemd will connect + * eventually, and it does not need a .service file */ + entry = NULL; + } + else + { + entry = activation_find_entry (activation, service_name, error); + if (!entry) + return FALSE; + } /* Bypass the registry lookup if we're auto-activating, bus_dispatch would not * call us if the service is already active. @@ -1853,17 +1864,20 @@ bus_activation_activate_service (BusActivation *activation, return FALSE; } - pending_activation->exec = _dbus_strdup (entry->exec); - if (!pending_activation->exec) + if (entry != NULL) { - _dbus_verbose ("Failed to copy service exec for pending activation\n"); - BUS_SET_OOM (error); - bus_pending_activation_unref (pending_activation); - bus_pending_activation_entry_free (pending_activation_entry); - return FALSE; + pending_activation->exec = _dbus_strdup (entry->exec); + if (!pending_activation->exec) + { + _dbus_verbose ("Failed to copy service exec for pending activation\n"); + BUS_SET_OOM (error); + bus_pending_activation_unref (pending_activation); + bus_pending_activation_entry_free (pending_activation_entry); + return FALSE; + } } - if (entry->systemd_service) + if (entry != NULL && entry->systemd_service != NULL) { pending_activation->systemd_service = _dbus_strdup (entry->systemd_service); if (!pending_activation->systemd_service) @@ -2055,6 +2069,11 @@ bus_activation_activate_service (BusActivation *activation, proceed with traditional activation. */ } + /* If entry was NULL, it would be because we were doing systemd activation + * and activating systemd itself; but we already handled that case with + * an early-return */ + _dbus_assert (entry != NULL); + /* use command as system and session different */ if (!_dbus_string_init (&command)) { diff --git a/bus/selinux.c b/bus/selinux.c index ef627c8c..ca884ef5 100644 --- a/bus/selinux.c +++ b/bus/selinux.c @@ -146,7 +146,9 @@ log_callback (const char *fmt, ...) vsyslog (LOG_USER | LOG_INFO, fmt, ap); +#ifdef HAVE_LIBAUDIT out: +#endif va_end(ap); } diff --git a/bus/test-launch-helper.c b/bus/test-launch-helper.c index e9ba412a..c58d06eb 100644 --- a/bus/test-launch-helper.c +++ b/bus/test-launch-helper.c @@ -102,7 +102,7 @@ main (int argc, char **argv) const char *dir; DBusString config_file; - if (argc > 1) + if (argc > 1 && strcmp (argv[1], "--tap") != 0) dir = argv[1]; else dir = _dbus_getenv ("DBUS_TEST_DATA"); diff --git a/bus/test-main.c b/bus/test-main.c index 788574fe..faa63955 100644 --- a/bus/test-main.c +++ b/bus/test-main.c @@ -95,7 +95,7 @@ main (int argc, char **argv) progname = argv[0]; - if (argc > 1) + if (argc > 1 && strcmp (argv[1], "--tap") != 0) dir = argv[1]; else dir = _dbus_getenv ("DBUS_TEST_DATA"); diff --git a/bus/test-system.c b/bus/test-system.c index 5f02d0ab..2d7848c7 100644 --- a/bus/test-system.c +++ b/bus/test-system.c @@ -73,7 +73,7 @@ main (int argc, char **argv) progname = argv[0]; - if (argc > 1) + if (argc > 1 && strcmp (argv[1], "--tap") != 0) dir = argv[1]; else dir = _dbus_getenv ("DBUS_TEST_DATA"); diff --git a/cmake/i686-w64-mingw32.cmake b/cmake/i686-w64-mingw32.cmake new file mode 100644 index 00000000..1be4e78c --- /dev/null +++ b/cmake/i686-w64-mingw32.cmake @@ -0,0 +1,20 @@ +# Toolchain for mingw-w64 32-bit compilers, as shipped in Debian/Ubuntu. + +set(GNU_HOST i686-w64-mingw32) +set(CMAKE_SYSTEM_PROCESSOR "i686") + +set(COMPILER_PREFIX "${GNU_HOST}-") + +set(CMAKE_SYSTEM_NAME "Windows") +set(CMAKE_CROSSCOMPILING TRUE) +set(WIN32 TRUE) +set(MINGW TRUE) + +include(CMakeForceCompiler) +cmake_force_c_compiler(${COMPILER_PREFIX}gcc GNU) +cmake_force_cxx_compiler(${COMPILER_PREFIX}g++ GNU) +set(CMAKE_RC_COMPILER ${COMPILER_PREFIX}windres) + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/cmake/modules/Macros.cmake b/cmake/modules/Macros.cmake index fd3f62c4..8d6cf11f 100644 --- a/cmake/modules/Macros.cmake +++ b/cmake/modules/Macros.cmake @@ -43,11 +43,11 @@ 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 $<TARGET_FILE:${_target}>) + add_test(NAME ${_target} COMMAND $<TARGET_FILE:${_target}> --tap) else() set(PREFIX) set(_env "DBUS_TEST_DAEMON=${CMAKE_BINARY_DIR}/bin/dbus-daemon${EXEEXT}") - add_test(NAME ${_target} COMMAND $<TARGET_FILE:${_target}>) + add_test(NAME ${_target} COMMAND $<TARGET_FILE:${_target}> --tap) endif() list(APPEND _env "DBUS_SESSION_BUS_ADDRESS=") list(APPEND _env "DBUS_FATAL_WARNINGS=1") diff --git a/cmake/test/CMakeLists.txt b/cmake/test/CMakeLists.txt index eb4b1f10..e78af7a5 100644 --- a/cmake/test/CMakeLists.txt +++ b/cmake/test/CMakeLists.txt @@ -72,7 +72,7 @@ add_helper_executable(test-spawn ${test-spawn_SOURCES} ${DBUS_INTERNAL_LIBRARIES 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}) +add_helper_executable(manual-tcp ${manual-tcp_SOURCES} ${DBUS_INTERNAL_LIBRARIES}) if(WIN32) add_helper_executable(manual-paths ${manual-paths_SOURCES} ${DBUS_INTERNAL_LIBRARIES}) endif() @@ -119,6 +119,7 @@ set (TESTDIRS test/data/incomplete-messages test/data/auth test/data/sha-1 + test/data/systemd-activation test/data/valid-config-files test/data/valid-config-files/basic.d test/data/valid-config-files/session.d diff --git a/dbus/dbus-internals.c b/dbus/dbus-internals.c index 30a5fa73..d7ef0893 100644 --- a/dbus/dbus-internals.c +++ b/dbus/dbus-internals.c @@ -1066,6 +1066,12 @@ _dbus_test_oom_handling (const char *description, max_failures_to_try = 4; } + if (max_failures_to_try < 1) + { + _dbus_verbose ("not testing OOM handling\n"); + return TRUE; + } + i = setting ? max_failures_to_try - 1 : 1; while (i < max_failures_to_try) { diff --git a/dbus/dbus-test-main.c b/dbus/dbus-test-main.c index 9a80f853..08e402b9 100644 --- a/dbus/dbus-test-main.c +++ b/dbus/dbus-test-main.c @@ -51,7 +51,7 @@ main (int argc, setlocale(LC_ALL, ""); #endif - if (argc > 1) + if (argc > 1 && strcmp (argv[1], "--tap") != 0) test_data_dir = argv[1]; else test_data_dir = NULL; diff --git a/test/Makefile.am b/test/Makefile.am index b7f40bb0..82c76f4e 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -294,7 +294,7 @@ if DBUS_ENABLE_INSTALLED_TESTS $(installcheck_environment) \ $(srcdir)/dbus-test-runner \ $(testexecdir) \ - $(testexec_PROGRAMS) } + $(installable_tests); } endif DBUS_ENABLE_INSTALLED_TESTS in_data = \ diff --git a/tools/ci-build.sh b/tools/ci-build.sh new file mode 100755 index 00000000..a2abc0b5 --- /dev/null +++ b/tools/ci-build.sh @@ -0,0 +1,204 @@ +#!/bin/sh + +set -e +set -x + +if [ -z "$dbus_ci_variant" ]; then + dbus_ci_variant=release +fi + +if [ -z "$dbus_ci_host" ]; then + dbus_ci_host=native +fi + +if [ -z "$dbus_ci_buildsys" ]; then + dbus_ci_buildsys=autotools +fi + +if [ -z "$dbus_ci_parallel" ]; then + dbus_ci_parallel=1 +fi + +dbus_test=yes +dbus_test_fatal=yes + +NOCONFIGURE=1 ./autogen.sh + +srcdir="$(pwd)" +mkdir ci-build-${dbus_ci_variant}-${dbus_ci_host} +cd ci-build-${dbus_ci_variant}-${dbus_ci_host} + +make="make -j${dbus_ci_parallel} V=1 VERBOSE=1" + +case "$dbus_ci_host" in + (mingw) + mirror=http://sourceforge.net/projects/msys2/files/REPOS/MINGW/i686/ + mingw="$(pwd)/mingw32" + install -d "${mingw}" + export PKG_CONFIG_LIBDIR="${mingw}/lib/pkgconfig" + export PKG_CONFIG_PATH= + export PKG_CONFIG="pkg-config --define-variable=prefix=${mingw}" + unset CC + unset CXX + for pkg in \ + expat-2.1.0-6 \ + gcc-libs-5.2.0-4 \ + gettext-0.19.6-1 \ + glib2-2.46.1-1 \ + libffi-3.2.1-3 \ + zlib-1.2.8-9 \ + ; do + wget ${mirror}/mingw-w64-i686-${pkg}-any.pkg.tar.xz + tar -xvf mingw-w64-i686-${pkg}-any.pkg.tar.xz + done + export TMPDIR=/tmp + ;; +esac + +case "$dbus_ci_buildsys" in + (autotools) + case "$dbus_ci_variant" in + (debug) + # Full developer/debug build. + set _ "$@" + set "$@" --enable-developer --enable-tests + shift + # The test coverage for OOM-safety is too + # verbose to be useful on travis-ci. + export DBUS_TEST_MALLOC_FAILURES=0 + ;; + + (reduced) + # A smaller configuration than normal, with + # various features disabled; this emulates + # an older system or one that does not have + # all the optional libraries. + set _ "$@" + # No LSMs (the release build has both) + set "$@" --disable-selinux --disable-apparmor + # No inotify (we will use dnotify) + set "$@" --disable-inotify + # No epoll or kqueue (we will use poll) + set "$@" --disable-epoll --disable-kqueue + # No special init system support + set "$@" --disable-launchd --disable-systemd + # No libaudit or valgrind + set "$@" --disable-libaudit --without-valgrind + shift + ;; + + (legacy) + # An unrealistically cut-down configuration, + # to check that it compiles and works. + set _ "$@" + # Disable native atomic operations on Unix + # (armv4, as used as the baseline for Debian + # armel, is one architecture that really + # doesn't have them) + set "$@" dbus_cv_sync_sub_and_fetch=no + # No epoll, kqueue or poll (we will fall back + # to select, even on Unix where we would + # usually at least have poll) + set "$@" --disable-epoll --disable-kqueue + set "$@" CPPFLAGS=-DBROKEN_POLL=1 + # Enable SELinux and AppArmor but not + # libaudit - that configuration has sometimes + # failed + set "$@" --enable-selinux --enable-apparmor + set "$@" --disable-libaudit --without-valgrind + # No directory monitoring at all + set "$@" --disable-inotify --disable-dnotify + # No special init system support + set "$@" --disable-launchd --disable-systemd + # No X11 autolaunching + set "$@" --disable-x11-autolaunch + shift + ;; + + (*) + ;; + esac + + case "$dbus_ci_host" in + (mingw) + set _ "$@" + set "$@" --build="$(config.guess)" + set "$@" --host=i686-w64-mingw32 + set "$@" LDFLAGS=-L"${mingw}/lib" + set "$@" CPPFLAGS=-I"${mingw}/include" + set "$@" CFLAGS=-static-libgcc + set "$@" CXXFLAGS=-static-libgcc + # don't run tests yet, Wine needs Xvfb and + # more msys2 libraries + dbus_test= + # don't "make install" system-wide + dbus_ci_sudo= + shift + ;; + esac + + ../configure \ + --enable-installed-tests \ + --enable-maintainer-mode \ + --enable-modular-tests \ + --with-glib \ + "$@" + + ${make} + [ -z "$dbus_test" ] || ${make} check || [ -z "$dbus_test_fatal" ] + cat test/test-suite.log || : + [ -z "$dbus_test" ] || ${make} distcheck || \ + [ -z "$dbus_test_fatal" ] + + ${make} install DESTDIR=$(pwd)/DESTDIR + ( cd DESTDIR && find . ) + + if [ -n "$dbus_ci_sudo" ] && [ -n "$dbus_test" ]; then + sudo ${make} install + LD_LIBRARY_PATH=/usr/local/lib ${make} installcheck || \ + [ -z "$dbus_test_fatal" ] + cat test/test-suite.log || : + + # re-run them with gnome-desktop-testing + env LD_LIBRARY_PATH=/usr/local/lib \ + gnome-desktop-testing-runner -d /usr/local/share dbus/ || \ + [ -z "$dbus_test_fatal" ] + + # these tests benefit from being re-run as root + sudo env LD_LIBRARY_PATH=/usr/local/lib \ + gnome-desktop-testing-runner -d /usr/local/share \ + dbus/test-uid-permissions_with_config.test || \ + [ -z "$dbus_test_fatal" ] + fi + ;; + + (cmake) + case "$dbus_ci_host" in + (mingw) + set _ "$@" + set "$@" -D CMAKE_TOOLCHAIN_FILE="${srcdir}/cmake/i686-w64-mingw32.cmake" + set "$@" -D CMAKE_PREFIX_PATH="${mingw}" + set "$@" -D CMAKE_INCLUDE_PATH="${mingw}/include" + set "$@" -D CMAKE_LIBRARY_PATH="${mingw}/lib" + set "$@" -D EXPAT_LIBRARY="${mingw}/lib/libexpat.dll.a" + set "$@" -D GLIB2_LIBRARIES="${mingw}/lib/libglib-2.0.dll.a" + set "$@" -D GOBJECT_LIBRARIES="${mingw}/lib/libgobject-2.0.dll.a" + set "$@" -D GIO_LIBRARIES="${mingw}/lib/libgio-2.0.dll.a" + shift + # don't run tests yet, Wine needs Xvfb and more + # msys2 libraries + dbus_test= + ;; + esac + + cmake "$@" ../cmake + + ${make} + # The test coverage for OOM-safety is too verbose to be useful on + # travis-ci. + export DBUS_TEST_MALLOC_FAILURES=0 + [ -z "$dbus_test" ] || ctest -VV || [ -z "$dbus_test_fatal" ] + ${make} install DESTDIR=$(pwd)/DESTDIR + ( cd DESTDIR && find . ) + ;; +esac |