Commit graph

944 commits

Author SHA1 Message Date
Marc-André Lureau
f893b86e52 autotools: dist listen-autolaunch-win.conf.in as well
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-07-13 20:36:13 +01:00
Marc-André Lureau
9aa751f59e meson: add test-autolaunch-win
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-07-13 20:36:13 +01:00
Simon McVittie
ac9d36836e test: Set PATH or WINEPATH to find dbus-daemon.exe in build-time tests
When building for Windows, either natively or cross-compiling and
running tests with Wine, test-autolaunch-win expects to be able to
find the just-built dbus-daemon.exe in the PATH.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-07-13 20:36:13 +01:00
Simon McVittie
09ebed95ea test: Extend some timeouts
Group slow tests (those taking about a minute or more in one of the
configurations built on Gitlab-CI) into a new 'slow' suite, which can
be used with `meson test --no-suite=slow` to run just the faster tests.
They default to a 5 minute timeout (usually enough) unless overridden
(bus/dispatch.c can be *very* slow when OOM testing is enabled, and
gets a 30 minute timeout).

For the remaining tests, default to Meson's usual 30 second timeout,
but bump up the timeout a bit in some cases to have a safety margin
(my method was to take the slowest run on our Gitlab-CI, and make sure
we're allowing about 3 times that long).

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-07-13 20:36:13 +01:00
Simon McVittie
64711328ec test: Group together tests that run the dbus-daemon
These have slightly different requirements on CI, and are harder to
get working on Windows.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-07-13 20:36:13 +01:00
Simon McVittie
1dc8cf5875 test: Add missing session.conf, system.conf to Meson build
For as-installed testing on Unix, we want these to be symlinks to the
production versions of the same file.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-07-13 20:36:13 +01:00
Simon McVittie
08348e9e46 test: Install transient-services.sh into a subdirectory
This is what we do with Autotools, and keeping Meson the same means we
can diff the installed trees more easily.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-07-13 20:36:13 +01:00
Simon McVittie
77312171b9 test: libdbus-testutils depends on GIO, not just GLib
This matters when we build against GLib as a Meson subproject.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-07-13 20:36:13 +01:00
Simon McVittie
78d359dbb6 test: Make environment variables consistent with Autotools
DBUS_SESSION_BUS_LISTEN_ADDRESS is the same as in non-test files:
the test data distinguishes between DBUS_SESSION_BUS_LISTEN_ADDRESS,
the real session bus configuration, and TEST_LISTEN, the test-only
configuration.

DBUS_TEST_HOMEDIR and HOME should be in the build directory, not
the source directory.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-07-13 20:36:13 +01:00
Simon McVittie
e75d8a7cbc test: Correct generation of .test metadata
If a helper executable is not, in itself, a test-case, then we should
not generate metadata that tells ginsttest-runner to run it as a
test-case.

Meanwhile, we were previously generating foo_with_config.test metadata
for tests that don't get installed; stop doing that.

We also need to distinguish between the abstract name of the test
(which usually does not start with test-), the name of the .test file
(which does start with test- for compiled executables), and the name
of the executable (which may include .exe as well). To make validation
against the Autotools build system as straightforward as possible,
generate exactly the same names as in Autotools. We can consider removing
the test- prefix later, if we remove the Autotools build system.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-07-13 20:36:13 +01:00
Simon McVittie
c8ecf552c8 test: Allow for scripts that don't get installed
At the moment there aren't any like this, but it seems reasonable that
we might get some later.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-07-13 20:36:13 +01:00
Simon McVittie
fad7a62c39 test: Don't run integration tests at build-time
Some items listed in the tests array are helper executables rather
than actually being tests, and should not be run as a test at any time.
Those have {"test": false}. Expand this special case to the scripts
array for completeness (although currently, no scripts need this).

Meanwhile, some items listed in the scripts array are "as-installed"
integration tests which cannot safely be run at build-time, because
they make assertions about the state of the installed system.
Introduce {"build_time_test": false} for these, and expand this special
case to the tests array for completeness (although currently, no
compiled executables need this).

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-07-13 20:36:13 +01:00
Simon McVittie
0793e3be3d build: Propagate some comments from Autotools build into Meson
Comments like these represent hard-won knowledge which we should not
discard.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-07-13 20:36:13 +01:00
Simon McVittie
7445af51a4 build: Add machine-readable licensing markers to the Meson build system
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-07-13 20:36:13 +01:00
Simon McVittie
d9194ffb4d test: Try to create temporary XDG_RUNTIME_DIR with correct mode
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-07-13 20:36:13 +01:00
Simon McVittie
1582f713a3 build: Distribute Meson build system in release tarballs
As long as we are treating Autotools as a first-class citizen, what we
release will be `make distcheck` output.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-07-13 20:36:13 +01:00
Simon McVittie
fa764fe4e9 test/data: Generate a separate installable set of data files
Some of the strings we need to substitute into these files are not
the same for as-installed testing as for build-time testing.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-07-13 20:36:13 +01:00
Simon McVittie
60afeaa5d6 test: Avoid arbitrary Python injection if compiled in a path with quotes
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-07-13 20:36:13 +01:00
Simon McVittie
22b12cdb3f test: Disable sanitizers for test-segfault
This resolves the TODO comment.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-07-13 20:36:13 +01:00
Simon McVittie
4bce2c36f0 test: Expect TAP output for tests in name-test
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-07-13 20:36:13 +01:00
Simon McVittie
43927ea002 test: Don't run test-autolaunch directly
It's intended to be run from run-test.sh.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-07-13 20:36:13 +01:00
Simon McVittie
83fbc01dca test: Sort test executables
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-07-13 20:36:13 +01:00
Félix Piédallu
cd2e382610 Add Meson build system
Signed-off-by: Félix Piédallu <felix@piedallu.me>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-07-13 20:36:13 +01:00
Ralf Habacker
b1dd6fa7a6 Add a test application for autostart on Windows implementation
The test application performs several individual tests to detect possible
problems with the autostart support under Windows. Connections are tested
with the standard scope, a 'custom' scope, the 'install path' scope and
the 'user' scope.

Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
2022-06-27 15:34:23 +02:00
Marc-André Lureau
e4d6b74b25 build-sys: drop DBUS_CMAKE
TEST_LISTEN is defined by the cmake/autotools (or meson) build systems.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-06-17 15:19:38 +04:00
Marc-André Lureau
708dd5a55e test: fix unused variable warnings
../../test/internals/assertions.c: In function ‘test_assert_error_is_set’:
../../test/internals/assertions.c:82:14: warning: unused variable ‘ep’ [-Wunused-variable]
   82 |   DBusError *ep = NULL;
      |              ^~
../../test/internals/assertions.c:81:13: warning: unused variable ‘e’ [-Wunused-variable]
   81 |   DBusError e = DBUS_ERROR_INIT;

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-05-19 17:57:31 +02:00
Ralf Habacker
5f1bc83d36 Add unit tests for platform-specific mutex implementation.
The tests are enabled with the embedded tests; the required
low-level functions from the dbus library are decorated with
DBUS_EMBEDDED_TESTS_EXPORT to indicate the appropriate usage.

On Windows, all tests are run; on unix-like operating systems,
individual tests are disabled:
- the tests on #NULL pointers of type DBus[C|R]Mutex, since they
  point to a data structure and would cause a segment violation
  when accessed.
- the multiple lock test for type DBusCMutex, since it would block
  the current thread.

Since the whole point of "rmutex" is to be able to lock multiple
times, the "rmutex double lock" test is enabled on unix-like
operating systems too.

Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
2022-05-01 19:52:48 +02:00
Ralf Habacker
29946ad7c1 tests: Fix build warning "dereferencing type-punned pointer will break strict-aliasing rules"
To avoid that build break in test-marshall-recursive-util.c the newly
added function _dbus_string_append_buffer_as_hex() is used to print
the hex bytes.

Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
2022-05-01 16:28:51 +00:00
Ralf Habacker
21a6441f33 _dbus_string_test(): Fix fatal build error caused by "-Wstrict-aliasing"
To fix this problem, the problematic code was replaced by a new function
_dbus_string_get_allocated_size(), which uses the existing macro
DBUS_CONST_STRING_PREAMBLE for these purposes.

Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
Part-of: https://gitlab.freedesktop.org/dbus/dbus/-/merge_requests/275
Reviewed-by: Simon McVittie <smcv@collabora.com>
2022-04-21 13:55:38 +01:00
Ralf Habacker
3e8423d299 test-segfault: Fix build error caused by a null pointer dereference warning
Only do the deliberate crash via undefined behaviour (which the compiler
is quite right to warn us about!) if raise() isn't available.

The pointer needs to be volatile otherwise the compiler is free to remove
the store.

Part-of: https://gitlab.freedesktop.org/dbus/dbus/-/merge_requests/275
Reviewed-by: Simon McVittie <smcv@collabora.com>
2022-04-21 13:54:23 +01:00
Simon McVittie
63632eaf8d test: Add basic test coverage for _dbus_close_all and friends
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-04-21 11:02:44 +01:00
Simon McVittie
6a4a89ccea test-utils-glib: Add backports of some convenience macros
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-04-21 11:02:44 +01:00
Simon McVittie
b7c325e573 test-utils-glib: Ensure correct precedence in g_assert_nonnull()
It's best-practice to put macro arguments in parentheses so that they
are always treated as a unit.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-04-21 11:02:44 +01:00
Simon McVittie
6130ac4267 build: Define DBUS_INT64_MODIFIER, analogous to G_GINT64_MODIFIER
Using PRId64, etc. to print dbus_int64_t or dbus_uint64_t is not 100%
portable. On platforms where both long and long long are 64-bit (such as
Linux and macOS), we will prefer to define dbus_int64_t as long.
If the operating system has chosen to define int64_t as long long,
which is apparently the case on macOS, then the compiler can warn that
we are passing a long argument to PRId64, which is "lld" and therefore
expects a long long argument (even though that ends up with the same
bit-pattern being used).

We can't necessarily just use int64_t and uint64_t directly, even if all
our supported platforms have them available now, because swapping
dbus_int64_t between long and long long might change C++ name mangling,
causing ABI breaks in third-party libraries if they define C++ functions
that take a dbus_int64_t argument.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-04-19 18:27:47 +00:00
Simon McVittie
47a4bdfaf8 tests: Ensure session bus has started before integration test
The session dbus-daemon won't necessarily be run immediately on login
if we are using systemd socket activation for it, and the transient
services directory $XDG_RUNTIME_DIR/dbus-1/services isn't created until
it's actually run. Ping the dbus-daemon to make sure it's available.

Signed-off-by: Simon McVittie <smcv@debian.org>
Bug-Debian: https://bugs.debian.org/1005889
2022-02-21 18:09:22 +00:00
Simon McVittie
632831c959 test-utils: Don't assume all arrays of tests are zero-terminated
Fixes: dbus!233
Resolves: dbus#366
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-12-15 17:47:32 +00:00
Simon McVittie
9d60676ae0 Disable the Containers interface
We've had a request for a 1.14.x stable-branch, but the Containers
interface is only partially implemented, not yet described in the
D-Bus Specification, and not ready to be part of our API guarantees.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-12-10 16:48:51 +00:00
Ralf Habacker
77375263f5 cmake: add option ENABLE_VERBOSE_CONFIG
Checking the filenames of generated configuration files is now optionally
possible with this cmake option. They are no longer displayed by default
to avoid unnecessarily flooding the output.
2021-12-10 14:16:52 +00:00
Ralf Habacker
0d0649145f In _dbus_test_main() check if a specified test name is available
Fixes #362
2021-12-10 10:36:37 +01:00
Ralf Habacker
febafd863e test/test-utils.c: Add command line option --list-tests to test applications
With this command line option a list of available tests is printed to
stdout.
2021-12-10 10:36:28 +01:00
Ralf Habacker
3432cd938d test/test-utils.c: Add command line option --help to test applications 2021-12-10 10:21:35 +01:00
Simon McVittie
ac5e65ef43 test: Exercise successful and failed RemoveMatch calls
Reproduces: https://gitlab.freedesktop.org/dbus/dbus/-/issues/351
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-11-22 16:10:51 +00:00
David King
7dc6b64d98 test/thread-blocking.c: Fix a memory leak
Free name inside the for loop. Found by Coverity.

Bug-RedHat: https://bugzilla.redhat.com/show_bug.cgi?id=1938701
2021-10-29 18:03:13 +00:00
Ralf Habacker
ee24cadf2e Apply cmake formatting rules 2021-10-25 15:56:46 +02:00
Ralf Habacker
5b1870a5bd cmake: make support for traditional activation optional
Traditional activation is enabled/disabled with the cmake configure
parameter -DENABLE_TRADITIONAL_ACTIVATION, which is enabled by default.

This was added to the Autotools build system as part of dbus/dbus!107
but until now was not possible to disable when building with CMake.
2020-09-23 17:21:40 +02:00
Ralf Habacker
b698fb7639 cmake: move up checking DBUS_ENABLE_EMBEDDED_TESTS from subdir test/name-test to test
The whole file is only added with the mentioned variable
set, so it can also be skipped completly one level up.
2020-09-23 14:27:53 +00:00
Simon McVittie
f0e526bca8 tests: On Unix, include <netinet/in.h> for IPPROTO_TCP
Otherwise, dbus doesn't compile on FreeBSD if the GLib-based tests
are enabled (which suggests that no FreeBSD user has run those tests
successfully).

We already include <netinet/in.h> in other places with no conditions
or checks other than "is Unix", so apparently it's portable enough that
specifically testing for its presence is not necessary. POSIX requires it
to exist.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-08-14 17:02:46 +01:00
Simon McVittie
fc0f296583 fdpass test: Assert that we don't leak file descriptors
Reproduces: dbus#294
Reproduces: CVE-2020-12049
Reproduces: GHSL-2020-057
Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-06-02 10:42:54 +01:00
Félix Piédallu
362b22605c shell-test: Print diagnostics to stderr
Some of the command-lines that we print as diagnostics contain newlines,
which will cause warnings or errors under a strict TAP parser (and one of
them wasn't correctly prefixed with '#' anyway). TAP parsers only parse
stdout, not stderr, so we can use stderr for these diagnostic messages.

[smcv: Expand commit message]

Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-04-28 11:50:23 +01:00
Ralf Habacker
44c8b03c34 desktop-file test: Free result on all code paths
Otherwise, Coverity will diagnose this as a resource leak,
because it doesn't understand that our assertions end up guaranteeing
that the result is freed if and only if it's non-`NULL`.

Coverity CID: 354884
2020-04-27 12:39:35 +00:00