Alex Richardson [Mon, 8 Aug 2022 15:29:56 +0000 (15:29 +0000)]
tools/ci-build.sh: Ensure that $builddir is set
When adding the new FreeBSD CI, this was not implicitly forwarded to QEMU,
so the build script failed with confusing errors. Add an explicit check
that the variable is set to make those cases easier to debug.
Alex Richardson [Wed, 25 May 2022 21:33:17 +0000 (21:33 +0000)]
tools/ci-{build,install}.sh: Use a portable interpreter argument
FreeBSD has bash installed as /usr/local/bin/bash, so hardcoding /bin/bash
does not work. Instead use the portable replacement using env which will
find bash in $PATH.
Simon McVittie [Mon, 25 Jul 2022 13:30:02 +0000 (14:30 +0100)]
meson: Only require C++ compiler when building for Windows
dbus is generally a C-only project, but the Windows side has a tiny
amount of C++ to initialize global locks (because Windows doesn't have
a direct equivalent of PTHREAD_MUTEX_INITIALIZER). We don't need a C++
compiler when building for a non-Windows OS, so there's no need to
find it or check which options it supports.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Jordan Williams [Sat, 23 Jul 2022 11:21:44 +0000 (06:21 -0500)]
Use project relative paths in CMake files
This makes it possible for projects to incorporate D-Bus as a CMake sub-project in a larger CMake project.
Before this PR, doing so would result in many errors.
This is because CMAKE_SOURCE_DIR and CMAKE_BINARY_DIR would point to directories above the D-Bus project.
Using paths relative to the project directory, PROJECT_SOURCE_DIR and PROJECT_BINARY_DIR, corrects for this.
Jordan Williams [Fri, 22 Jul 2022 19:27:14 +0000 (14:27 -0500)]
Bump CMake version to 3.4
With the minimum version set to 3.4, none of the policies need to be set explicitly to the `NEW` behavior.
Each of the policies removed here was introduced before CMake version 3.4.
By default then, each of them will be set to NEW automatically.
This is part of the behavior of cmake_minimum_required.
The cmake_policy commands are therefore redundant and have been removed.
Simon McVittie [Tue, 19 Jul 2022 19:30:57 +0000 (20:30 +0100)]
NEWS, README.win: Officially drop support for non-C99 compilers
We're considering MSVC 2015 to be sufficiently close to C99 for our
purposes, and we now have CI for it, so we can easily check whether any
desired C99 feature works. Other pre-C99 compilers are obsolete.
Resolves: dbus#404 Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Fri, 15 Jul 2022 14:41:14 +0000 (15:41 +0100)]
test/bus: Break up dispatch test into three separate tests
This is really three separate test-cases: one for traditional
activation as a direct child process of the dbus-daemon, and two for
traditional activation (successful and failing) via the setuid
dbus-daemon-launch-helper on Unix.
The ones where activation succeeds extremely slow, as a result of the
instrumentation for simulating malloc() failures combined with a large
number of memory operations, particularly when using AddressSanitizer.
Splitting up "OOM" tests like these has a disproportionately good impact
on the time they take, because the simulated malloc() failure
instrumentation repeats the entire test making the first malloc() fail,
then making the second malloc() fail, and so on. For allocation failures
in the second half of the test, this means we repeat the first half of
the test with no malloc() failures a very large number of times, which
is not a good use of time, because we already tested it successfully.
Even when not using the "OOM" instrumentation, splitting up these tests
lets them run in parallel, which is also a major time saving.
Needless to say, this speeds up testing considerably. On my modern but
unexceptional x86 laptop, in a typical debug build with Meson, the old
dispatch test took just over 21 minutes, which drops to about 40 seconds
each for the new normal-activation and helper-activation tests (and for
most of that time, they're running in parallel, so the wall-clock time
taken for the whole test suite is somewhere around a minute).
In a debug build with Meson, gcc and AddressSanitizer, the old dispatch
test takes longer than my patience will allow, and the new separate
tests take about 5-6 minutes each. Reduce their timeout accordingly, but
not as far as the default for slow tests (5 minutes) to allow some
headroom for AddressSanitizer or slower systems.
The failed-helper-activation test is almost instantaneous, and no longer
needs to be marked as slow.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Mon, 18 Jul 2022 10:14:08 +0000 (11:14 +0100)]
test: Skip tests that involve switching uid if unable to do so
In a Linux user namespace, it is possible that we are uid 0 but are
unable to switch to some other uid like DBUS_USER or DBUS_TEST_USER,
because the other uid is not "mapped" in the user namespace, resulting
in setuid() or setresuid() failing with EINVAL "Invalid argument".
For example, it's easy for this to happen when running under the
bubblewrap tool.
Try to drop privileges in a child process, and skip the test if we
are unable to do so.
Resolves: dbus#407 Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Fri, 1 Apr 2022 17:56:26 +0000 (18:56 +0100)]
sysdeps: Only open oom_score_adj read/write if we need to write it
If we're running in a sandbox, we might not have write access to
oom_score_adj. In the common case where we don't have any special
protection from the OOM-killer, we can detect that with only read
access, and skip the part where we open it for writing.
(We would also not have write access to oom_score_adj if we're running
with elevated Linux capabilities while not root, but that should never
actually happen for dbus-daemon-launch-helper, which is setuid root
for production use or has no capabilities during unit-testing.)
Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Fri, 1 Apr 2022 17:58:34 +0000 (18:58 +0100)]
activation-helper: Never crash if unable to write oom_score_adj
_dbus_warn() normally only logs a warning, but can be made fatal by
environment variables. In particular, we do that during unit testing,
which can result in a build-time test failure if dbus is built in a
sandbox environment that prevents write access.
_dbus_log() does only the logging part of _dbus_warn(), which seems
more appropriate here.
Signed-off-by: Simon McVittie <smcv@collabora.com>
The comment refers to the nul-padding of sockaddr_un member sun_path and
using an addrlen of sizeof(sockaddr_un). There is not much need to
document an old now "broken" behaviour.
Simon McVittie [Fri, 15 Jul 2022 14:08:02 +0000 (15:08 +0100)]
dbus-launch-x11: Ignore X11 connection when checking for memory leaks
The X11 connection is opened and never closed. Because dbus-launch
forks and continues to run non-trivial code in a forked child, it is
not clear whether (or where) it would be safe to close it; instead, we
leave it open until process exit, at which point the socket is cleaned
up by the kernel.
Any memory allocated for the X11 connection is only allocated once per
run of dbus-launch, so there's no need to keep track of it, and we can
silence these memory leak warnings as uninteresting.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Fri, 15 Jul 2022 11:13:43 +0000 (12:13 +0100)]
meson: Set up functionally necessary compiler arguments separately
We have to set up feature-flag options like _GNU_SOURCE before we
do compiler checks like cc.has_header_symbol, otherwise we'll miss
symbols that are guarded by a feature-flag test, like environ in Linux
unistd.h.
However, we don't want to pass flags for extra compiler warnings
when doing these checks, because that can cause false negatives:
in particular, Meson's check programs nearly always trigger -Wunused.
So the warnings need to be in a separate list.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Fri, 15 Jul 2022 00:37:47 +0000 (01:37 +0100)]
test: Work around TAP test regression in Meson 0.63.0
With Meson 0.63.0, detailed output of TAP tests is not logged, and the
test deadlocks if the stderr pipe fills up. I'm hoping this will be fixed
before 0.63.1, but in the meantime we can work around it by falling back
to the 'exitcode' protocol: this means we lose machine-readable detailed
test results, but at least our tests pass.
See https://github.com/mesonbuild/meson/issues/10577 and
https://github.com/mesonbuild/meson/issues/10563 for details of the
Meson regression.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Mon, 27 Jun 2022 16:13:52 +0000 (17:13 +0100)]
CI: Explicitly build before running tests
If we don't do this, Meson will build everything that is a direct
dependency of the test executables, but it won't build indirect
dependencies like GLib's gspawn-win32-helper.exe.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Mon, 27 Jun 2022 10:14:06 +0000 (11:14 +0100)]
CI: Enable Ducktype-based documentation on Debian/Ubuntu
We don't currently know the equivalent of python3-mallard-ducktype on
other OSs like openSUSE, but we know this should work on Debian (it does
when we do Autotools builds).
Signed-off-by: Simon McVittie <smcv@collabora.com>