Simon McVittie [Mon, 17 Dec 2018 11:18:35 +0000 (11:18 +0000)]
test: Unembed hash test from libdbus and move it into test/
This required exposing one additional internal symbol:
_dbus_hash_table_ref(). I think that's a reasonable trade-off for not
compiling this test into the library.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Thu, 15 Nov 2018 14:08:03 +0000 (14:08 +0000)]
_dbus_test_main: Move to test-utils
Now that there is no code outside test/ that calls into this, we can
move it into test/, reducing the size of libdbus.
dbus-test-tap.[ch] still need to stay in dbus/ as long as there is
code in dbus/ or bus/ relying on them, and also need to be linked into
libdbus as long as there is other code in libdbus relying on them,
so they stay where they are for now. Similarly, dbus-tests.h lists
the tests that are still embedded in libdbus, and must stay where
it is for the moment.
With this move, various tests now need to be linked to the dbus-testutils
convenience library.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Wed, 3 Oct 2018 18:01:42 +0000 (19:01 +0100)]
test: Move dbus-daemon-launch-helper-test here, and rename
The -test suffix does not indicate that this is a test, but rather that
it is for tests (similar to the -unix and -win suffixes on modules like
dbus-sysdeps). This seems unnecessarily confusing, so rename it to end
with -for-tests.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Wed, 3 Oct 2018 18:15:38 +0000 (19:15 +0100)]
test: Move libdbus embedded tests from dbus/ to test/
This groups them with the rest of the tests, and enables parts of
the test code to be unembedded from libdbus and moved to test/ too.
Rename the executable to test-misc-internals, not test-dbus. The name
test-dbus made some sense as "the executable that contains the code in
dbus/", but makes a lot less sense in test/: dbus is the name of the
entire project, so this test has no particular special claim to that
name. test-libdbus doesn't seem right either, because all the tests
exercise libdbus one way or another.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Mon, 3 Sep 2018 22:27:29 +0000 (15:27 -0700)]
build: Compile most bus/ files into static libraries
This means we can share them between tests without having to compile
the same file repeatedly, and makes them easier to share between
directories when we move test executables into test/.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Mon, 3 Sep 2018 21:37:55 +0000 (14:37 -0700)]
test-utils: Add copyright and licensing
As far as I can tell, the only significant contributions have been
from Red Hat and Collabora, both of which have given permission to
relicense their parts of the dbus codebase to MIT/X11; so let's go
with that.
I'm assuming here that tree-wide changes from
_DBUS_GNUC_WARN_UNUSED_RESULT to _DBUS_WARN_UNUSED_RESULT, and tree-wide
changes to how we include config.h, are not significant for copyright
purposes.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Ralf Habacker [Thu, 10 Jan 2019 14:29:59 +0000 (15:29 +0100)]
Make sure ctest on Windows uses the currently built dbus library
The ctest application is usually not installed in the dbus build
directory. If an older dbus library is contained in this path, it will
be used instead of the currently built one, which can lead to runtime
errors (e.g.: c0000139) if the internal dbus API differs.
Simon McVittie [Thu, 20 Dec 2018 15:17:13 +0000 (15:17 +0000)]
dbus-spawn-win: Move _dbus_spawn_program() to main thread
We would like to stop taking ownership of envp, but we can't do that
without a deep copy if a different thread might still be using it
(asynchronously) after the main thread has returned from
_dbus_spawn_async_with_babysitter().
Originally part of a larger commit by Ralf Habacker.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Wed, 19 Dec 2018 17:29:11 +0000 (17:29 +0000)]
dbus-daemon(1): Give more comprehensive examples of how to add services
While writing the wording to deprecate XML policy installed by packages
into ${sysconfdir}, I realised we didn't give a typical example of
what packages *should* do.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Wed, 19 Dec 2018 17:27:15 +0000 (17:27 +0000)]
Officially deprecate package-supplied dbus-daemon policy in ${sysconfdir}
Now that dbus 1.10 has become widely available, we should start to
treat ${sysconfdir} as reserved for the sysadmin, and encourage
third-party software packages to install their integration files into
${datadir}.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Ralf Habacker [Mon, 17 Dec 2018 15:36:32 +0000 (16:36 +0100)]
Add cmake support for session based test executables
This patch introduces a new cmake macro add_session_test_executable,
which uses dbus-run-session to start a dbus-daemon process with a
temporary session bus in the background and the desired client file.
add_session_test_executable requires additional environment variables
defined in the top level CMakeLists.txt.
Ralf Habacker [Mon, 17 Dec 2018 15:13:00 +0000 (16:13 +0100)]
Add cmake support for session based test executables
This patch introduces a new cmake macro add_session_test_executable,
which uses dbus-run-session to start a dbus-daemon process with a
temporary session bus in the background and the desired client file.
add_session_test_executable requires additional environment variables
defined in the top level CMakeLists.txt.
Ralf Habacker [Sat, 15 Dec 2018 09:54:47 +0000 (10:54 +0100)]
Fix setup of build time output paths in cmake
Instead of the variables EXECUTABLE_OUTPUT_PATH and
LIBRARY_OUTPUT_PATH, which have become obsolete since
cmake 3.x, CMAKE_xxx_OUTPUT_PATH is now used to define
output paths in the build directory.
Simon McVittie [Fri, 14 Dec 2018 20:31:31 +0000 (20:31 +0000)]
test-wrappers: Copy strings that might come from getenv()
It is not safe to assume that the result of getenv() is not invalidated
by a subsequent call to setenv(), and dbus#240 demonstrates that this
can be a problem in practice when running Windows code under Wine.
Closes: https://gitlab.freedesktop.org/dbus/dbus/issues/240 Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Mon, 3 Sep 2018 21:53:24 +0000 (14:53 -0700)]
tests: Collect common code from embedded-test main executables
This all seems to have been written by Red Hat or by Collabora, so we
have permission to relicense it under the MIT/X11 license, and we
might as well do so.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Mon, 17 Dec 2018 10:56:38 +0000 (10:56 +0000)]
trivial: Remove trailing whitespace from copyright notices
We don't usually mass-remove trailing whitespace from the actual source
code because it would complicate cherry-picking bug fixes to older
branches, but that reasoning doesn't really apply to the comments
containing copyright and licensing notices.
Removing trailing whitespace makes it much easier to move code around:
we have a commit hook that rejects commits containing trailing
whitespace, but that commit hook counts moving a file as a delete + add
pair, so it objects to moving code that contains trailing whitespace.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Fri, 14 Dec 2018 20:06:02 +0000 (20:06 +0000)]
_dbus_threads_init_debug: Remove
libdbus has been thread-safe by default since 1.7.6 (2013):
dbus_threads_init_default() is called on a just-in-time basis
whenever needed, and _dbus_thread_init_debug() is equivalent to that.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Fri, 14 Dec 2018 12:51:51 +0000 (12:51 +0000)]
.gitignore: Normalize into LC_ALL=C sort order
If lists are in a completely arbitrary order, sorting them consistently
means that there is only one correct place to insert a new entry, avoiding
the merge conflicts that would occur if we always append new entries.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Fri, 14 Dec 2018 12:46:35 +0000 (12:46 +0000)]
.gitignore: Consolidate generic patterns at top level
Patterns in the top-level .gitignore match in all subdirectories, so
there's no need to repeat ourselves quite so much for generic
C, Autotools and gcov patterns.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Fri, 14 Dec 2018 12:42:52 +0000 (12:42 +0000)]
Top level .gitignore: Sort anchored patterns in LC_ALL=C sort order
If lists are in a completely arbitrary order, sorting them consistently
means that there is only one correct place to insert a new entry, avoiding
the merge conflicts that would occur if we always append new entries.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Fri, 14 Dec 2018 12:42:22 +0000 (12:42 +0000)]
Top level .gitignore: Group anchored and unanchored patterns
The anchored patterns match only in the top directory; the unanchored
patterns match in any subdirectory. While I'm moving the unanchored
patterns around anyway, sort them in lexicographical (LC_ALL=C sort)
order.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Ralf Habacker [Fri, 7 Dec 2018 16:52:58 +0000 (17:52 +0100)]
Decrease the runtime of test refs under Windows by default
If the environment variable DBUS_TEST_SLOW is not set or is 0
fewer iterations are performed in test-refs enough to demonstrate
that it works, rather than seriously trying to reproduce race
conditions.
This solves the long runtime that Wine 3.x (4 times longer than
native Windows 7) or Windows 7 as a VirtualBox 5.22 guest (10
times longer) is to be seen.
Simon McVittie [Tue, 11 Dec 2018 11:52:38 +0000 (11:52 +0000)]
test-privserver: Move helper executable out of name-test/
This means we don't need to distinguish between DBUS_NAME_TEST_EXEC and
DBUS_TEST_EXEC any more, because all test helper executables are in the
same place, both during build and when installed (we don't install
test-privserver since no installed test requires it yet, but in
principle we could).
Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Thu, 13 Dec 2018 13:07:20 +0000 (13:07 +0000)]
test-privserver: Add copyright and licensing information
I've assumed that trivial changes from Scott James Remnant (correcting
some bus names) and Marcus Brinkmann (adding a <config.h> include
tree-wide) are not significant here. All the other potential copyright
holders from the git log are listed, and all have given permission to
relicense their dbus contributions under the MIT/X11 license.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Wed, 29 Aug 2018 19:06:00 +0000 (20:06 +0100)]
build: Add a way to set CFLAGS for AddressSanitizer etc.
We don't want to set these globally via the normal CFLAGS, because if
we did, AddressSanitizer would catch test-segfault deliberately
segfaulting, and "helpfully" turn it into exit status 1, which in turn
makes our test fail because it asserts that the segfault is reported
as a segfault.
A typical use with gcc as compiler, on a reasonably recent Debian,
would be:
Simon McVittie [Mon, 3 Dec 2018 16:04:56 +0000 (16:04 +0000)]
Move _dbus_disable_crash_handling() back into test/ directory
It's only used in test code. We have to put it in its own translation
unit with no non-libc dependencies so that we can compile a copy of it
without AddressSanitizer support, because in a subsequent commit we will
special-case test-segfault to be compiled without using AddressSanitizer,
which would make linking to an AddressSanitizer-instrumented libdbus fail.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Thu, 6 Dec 2018 13:49:56 +0000 (13:49 +0000)]
Don't cast user-supplied pointers to DBusBasicValue *
If we cast a user-supplied pointer to DBusBasicValue *, that's like
promising that the pointer is to an object at least as strictly aligned
as a DBusBasicValue. In practice, it often isn't: for example, when
we marshal a dbus_uint32_t, a pointer to it is only guaranteed to be
32-bit-aligned, whereas DBusBasicValue typically requires 64-bit
alignment.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Ralf Habacker [Fri, 7 Dec 2018 18:02:14 +0000 (19:02 +0100)]
run-session: Fix warning 'array subscript 3 is above array bounds of 'char *[3]' on Windows
After the merge request !22 was created, this bug was fixed in !23,
the associated branch was used for local tests, but the fix was not
transferred to !22. After merging !22 into the master branch and
rebasing !23 to the master, this fix was lost.
Ralf Habacker [Thu, 6 Dec 2018 16:08:29 +0000 (17:08 +0100)]
Skip server oom wildcard test on Windows to avoid firewall exception request
After starting the test on Windows 10, whether the local user is an
administrator or not, a dialog box appears with a warning that some
features of the app have been blocked by the firewall and prompts for
credentials for an administrator account while the test continues to
run and pass.
If this request is aborted, the dialog disappears; no restrictions are
visible for the test case. When the test is restarted, the dialog is also
no longer displayed.
In the firewall configuration you can then see that test-server-oom.exe
has been added (but not enabled) for public networks, although no
confirmation has been received from an administrator account.
Ralf Habacker [Wed, 5 Dec 2018 07:30:17 +0000 (08:30 +0100)]
Add new cmake configure option DBUS_USE_WINE
If this variable is set, ctest uses wine to run cross compiled
test applications. Otherwise, they are assumed to run on a native
Windows operating system.
The new cmake variables Z_DRIVE_IF_WINE and TEST_WRAPPER have been
added to support this function.
Ralf Habacker [Wed, 5 Dec 2018 06:56:22 +0000 (07:56 +0100)]
Adds uac manifest to all executable test files to prevent the Windows 740 error when running
The case occurred during test-pending-call-dispatch. To avoid further
applications being affected in the future, the manifest is added to
all test applications.
Windows Error 740 is defined as 'The Requested Operation Requires Elevation'
Simon McVittie [Wed, 5 Dec 2018 13:16:10 +0000 (13:16 +0000)]
CI: Don't install weak dependencies (Recommends)
In particular this avoids installing the TeX toolchain.
However, this also means we don't install dbus, which broke some tests
in minimal containers where dbus wasn't already installed, because the
messagebus user wouldn't have been created. Make sure that user exists,
using the same adduser call as the Debian dbus package.
CMake really wants to find a C++ compiler (even though we only use C++
when compiling for Windows), so explicitly install the default
version of the GNU C++ compiler, g++.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Simon McVittie [Wed, 5 Dec 2018 12:58:22 +0000 (12:58 +0000)]
sysdeps test: Wait for spawned process to exit
On Windows, the "out" parameter for the process handle isn't set
unless we specify G_SPAWN_FLAGS_DO_NOT_REAP_CHILD. That means we
can't terminate it, and the child process is leaked. When running the
test individually, the leaked process is harmless apart from its
resource cost, but when running under CTest, it holds a file descriptor
open (or something) which causes CTest to not exit.
If we *do* specify G_SPAWN_FLAGS_DO_NOT_REAP_CHILD, we become
responsible for "reaping" the child process by waiting for its exit
status, which is an OS-specific action.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Resolves: https://gitlab.freedesktop.org/dbus/dbus/issues/238