Commit graph

944 commits

Author SHA1 Message Date
Simon McVittie
9251d32206 test: Replace some _dbus_assert() with _dbus_test_check()
Assertions can be disabled, but in test code the assertions are the
whole point, so use checks that can't be disabled instead.

Because there's a lot of test code, I haven't done this globally, only
in the tests that I recently converted from "embedded" to "modular".

Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-04-20 10:13:07 +01:00
Simon McVittie
e559663e03 test: Replace _dbus_assert_not_reached()
Assertions can be disabled; but in test code the assertions are the
entire point, so we don't want to disable them. Use _dbus_test_fatal()
instead.

test-service is actually a test helper rather than a test, so use its
pre-existing die() function instead.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-04-20 10:13:07 +01:00
Simon McVittie
c383f151be test: Enable more tests when embedded tests are disabled
These previously relied on embedding test-specific code in libdbus,
but they actually only need public APIs, private interfaces that get
exported anyway for the benefit of dbus-daemon, and the TAP helpers;
so we can run them even in production builds.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-04-20 10:13:07 +01:00
Simon McVittie
fcbb5e6586 test: Move TAP helpers into dbus-testutils if embedded tests are disabled
This lets us run a subset of the tests that previously relied on extra
test-only code being compiled into libdbus.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-04-20 10:13:04 +01:00
Ralf Habacker
e4feb9600e Add a trivial sanity-check for the atomic primitives
This doesn't verify that they're atomic, but does verify that they
return the right things.

This commit adds a new test function _dbus_test_check (a) to make
writing tests easier. It checks the given boolean expression and
generates a "not ok" test result if the expression is false.

Due to the current design of the test api, the test is only compiled
if embedded tests were enabled at the time of configuration.

It was also necessary to move the test_atomic target definitions in
test/Makefile.am to the --enable-embedded-tests section to avoid a
make distcheck build error.

The test case itself has been authored by smcv.

Co-authored-by: Simon McVittie <smcv@collabora.com>
2019-12-13 16:13:53 +01:00
Simon McVittie
ac5cdd281a Merge branch 'break-out-more-tests' into 'master'
Break out more tests from libdbus

See merge request dbus/dbus!121
2019-07-03 13:43:25 +00:00
Simon McVittie
f73b40b883 Merge branch 'pass-tests-if-root' into 'master'
Fix test failures when running as root

See merge request dbus/dbus!117
2019-07-03 13:42:07 +00:00
Simon McVittie
95db64700a tests: Move userdb test out of libdbus
All the functions under test turn out to be DBUS_PRIVATE_EXPORT already.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-07-03 11:19:50 +01:00
Simon McVittie
c1412056bb tests: Move mempool test out of libdbus
All the functions under test turn out to be DBUS_PRIVATE_EXPORT already.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-07-03 11:19:47 +01:00
Simon McVittie
7386456e4b tests: Move address test out of libdbus
Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-07-03 11:19:19 +01:00
Simon McVittie
78d5af5ce9 tests: Move _dbus_sha_test outside libdbus
Instead of exposing _dbus_sha_test() as a private exported symbol,
we can expose _dbus_sha_compute(), which is the only thing called by
the test that isn't already exported.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-07-03 11:18:49 +01:00
Simon McVittie
8421d887aa bus tests: Shut down audit socket
Some CI environments run build-time tests as root with CAP_AUDIT_WRITE.
In this case we need to close the audit socket so that it will not be
reported as leaked.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-07-03 11:11:23 +01:00
Simon McVittie
e148aa47d3 tests: Skip if unable to launch uninstalled dbus-daemon as other uid
Some CI systems do the entire build as uid 0 in a throwaway container.
If this is done in a build directory for which the messagebus user
does not have search (+x) permission, then they will be unable to
execute the just-built dbus-daemon binary.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-07-03 11:11:23 +01:00
Simon McVittie
505bbfe4bd tests: Skip system bus test if we are root but messagebus does not exist
Some CI systems do the build as root in a disposable container, and
run tests without ever having installed dbus. This means we can't
expect to be able to drop privileges from root to the DBUS_USER (usually
named messagebus or dbus) unless we have checked that the
DBUS_USER exists.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-07-03 11:11:23 +01:00
Simon McVittie
e4e904a86b tests: Improve messages when fd leaks are diagnosed
Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-07-02 20:44:33 +01:00
Simon McVittie
0ba41e071c Move _dbus_check_fdleaks_* from dbus-message-util to tests
This is only called from test code.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-07-02 20:44:33 +01:00
Simon McVittie
6231e7d75f test: Add basic test coverage for DBUS_COOKIE_SHA1
We don't actually complete successful authentication, because that
would require us to generate a cookie and compute the correct SHA1,
which is difficult to do in a deterministic authentication script.
However, we do assert that dbus#269 (CVE-2019-12749) has been fixed.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-06-09 13:08:53 +01:00
Simon McVittie
463ecfb4fd Merge branch 'send_destination_prefix' into 'master'
Send destination prefix

See merge request dbus/dbus!85
2019-05-30 14:49:09 +00:00
Adrian Szyndela
8fcc1f9a8a test: activation tests for send_destination_prefix
This adds a few tests for checking if activation is allowed
for names specified within send_destination_prefix namespaces.

Signed-off-by: Adrian Szyndela <adrian.s@samsung.com>
Change-Id: I7a5a66f82fc08ce6cb46e37de2c3dfae24d9ea67
2019-05-14 10:31:13 +02:00
Adrian Szyndela
7b7c572434 test: send_destination(_prefix) tests
This adds tests for mostly "send_destination_prefix" cases
and some "send_destination" cases.

The general test case is:
- addressed recipient is running and owns a name;
- a message is sent to the name owner;
- the response is checked for allow/deny (method return/error).
Each test case is executed both for primary and queued ownership.

The tests include:
- checking send allow/deny for names and namespaces, including nesting;
- checking send allow/deny for neighbour names;
- checking send allow/deny for names/namespaces+interface+member.

Signed-off-by: Adrian Szyndela <adrian.s@samsung.com>
Change-Id: If5fcada01601355e7aadefadad79c0b24f8c397f
2019-05-14 10:31:12 +02:00
Simon McVittie
6884f63e0e Merge branch 'unix-gids' into 'master'
Add UnixGroupIDs to connection credentials

See merge request dbus/dbus!105

Fixes: dbus/dbus#196
2019-05-13 11:32:24 +00:00
Simon McVittie
14f46d14a0 build: Don't assume we can set permissions on a directory
MSYS2 has enough of a Unixish environment to run Autotools, but
apparently not enough of a Unixish environment to have functional
permissions.

Closes: dbus#216
2019-04-17 16:32:01 +01:00
Simon McVittie
fd0c19d6d8 Merge branch 'disable-traditional-activation' into 'master'
Configure option to disable traditional activation

See merge request dbus/dbus!107
2019-04-17 13:33:06 +00:00
Simon McVittie
3c8422884a test-dbus-daemon: Fix a misleading variable name
In D-Bus I'd expect "ay_iter" to be an iterator over the type 'ay',
i.e. a byte-array. Abbreviate a little less to avoid this.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-04-17 14:17:41 +01:00
Simon McVittie
812678e595 test-dbus-daemon: Say why we don't check the value of LinuxSecurityLabel
Suggested on !105 by Matthijs van Duin.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-04-17 14:13:42 +01:00
Matthijs van Duin
afafd2fad0 Add UnixGroupIDs to connection credentials
Signed-off-by: Matthijs van Duin <matthijsvanduin@gmail.com>
2019-03-25 23:01:26 +01:00
Topi Miettinen
94b5b236aa
Configure option to disable traditional activation
Traditional activation could be disabled if all services use
SystemdService activation instead. Provide an example of a hardened
DBus systemd service drop-in file for such a setup.

Signed-off-by: Topi Miettinen <toiwoton@gmail.com>
2019-03-25 21:51:33 +02:00
Ralf Habacker
433d5c2471 test-spawn-oom: Separate single spawn tests from oom related
This makes it possible to run each test independent from oom condition.
2019-03-15 17:06:01 +00:00
Simon McVittie
47953c5d85 Merge branch 'nss-fds' into 'master'
_dbus_test_main: Exercise NSS modules before running tests

Closes #256

See merge request dbus/dbus!93

Reviewed-by: pwithnall
Tested-by: rhabacker
2019-01-28 11:18:16 +00:00
Simon McVittie
02e3c4fdfa _dbus_test_main: Exercise NSS modules before running tests
Some NSS modules like those for sssd and LDAP might allocate fds
on a one-per-process basis, for example a socket to talk to sssd.
Make sure those have already been allocated before we enter the code
under test, so that they don't show up as having been "leaked" by the
first module of code under test that happens to do a NSS lookup.

The call to _dbus_test_check_memleaks tears down libdbus' own memory
allocations, but not any hidden state in libc or NSS.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-01-25 11:49:56 +00:00
Ralf Habacker
6332f7d4b1 Fixes remaining indentations that are not covered by the cmake formatting script in CMakeLists.txt files 2019-01-24 09:08:15 +01:00
Ralf Habacker
2798e68776 Adjust indents of CMakeLists.txt files always to 4 spaces 2019-01-24 09:08:15 +01:00
Ralf Habacker
904fa97a1b Remove obsolete parameter in end... cmake keywords 2019-01-24 09:07:27 +01:00
Ralf Habacker
5972bbe382 Remove spaces between cmake command and opening bracket 2019-01-24 09:07:27 +01:00
Ralf Habacker
3927b1dd39 Use lower case cmake keywords in CMakeLists.txt files 2019-01-24 09:07:27 +01:00
Simon McVittie
6d8280ec93 Merge branch 'code-coverage' into 'master'
Adapt to API change in AX_CODE_COVERAGE version 28

Closes #249

See merge request dbus/dbus!88

Reviewed-by: @pwithnall
2019-01-23 20:45:32 +00:00
Ralf Habacker
3bf97922bd Move cmake related build system to top level
Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
2019-01-22 09:57:40 +01:00
Simon McVittie
83be61aa2d Consistently add CODE_COVERAGE_CPPFLAGS everywhere
We forgot this in a couple of places.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-01-21 18:46:07 +00:00
Simon McVittie
e0ea7a130c Consistently add CODE_COVERAGE_LIBS everywhere
We need to link the code coverage objects, directly or indirectly,
into every executable and every shared library. The rule I've followed
to make it clear that we do this, without too much repetition, is:
each executable, shared library or convenience library has
CODE_COVERAGE_LIBS in its LDADD or LIBADD, unless it is linked to a
convenience library in the same directory that has CODE_COVERAGE_LIBS
in *its* LIBADD.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-01-21 18:45:38 +00:00
Simon McVittie
2938c2125e Adapt to API change in AX_CODE_COVERAGE version 28
AX_CODE_COVERAGE recently changed the way it embedded its Makefile rules
in the output file: instead of using @CODE_COVERAGE_RULES@, users
are now meant to include aminclude_static.am.

The new AX_CODE_COVERAGE is only in the latest autoconf-archive release,
version 2019.01.06, which is inconveniently new, so bundle everything
we need for the moment.

This requires us to stop using the deprecated CODE_COVERAGE_LDFLAGS
(which we still used to support older versions of autoconf-archive)
and replace them with CODE_COVERAGE_LIBS.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-01-21 18:43:08 +00:00
Simon McVittie
1972390d42 test: Move _dbus_list_test() here
Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-01-21 15:22:07 +00:00
Simon McVittie
0296c1fcbf test: Move _dbus_transport_unix_test() here
This requires exposing _dbus_connection_get_address() as an internal
symbol, but that seems worth it.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-01-21 15:22:07 +00:00
Simon McVittie
d9dfe4ee3e test: Move _dbus_server_test() here
Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-01-21 15:22:07 +00:00
Simon McVittie
58fc8a0360 test: Move _dbus_misc_test() here
Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-01-21 15:22:06 +00:00
Simon McVittie
0dd9853a37 test: Move _dbus_signature_test() here
This is all public API, so there's no need to embed it in the library.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-01-21 15:22:06 +00:00
Simon McVittie
cccb35dfef test: Move sysdeps tests here
Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-01-21 15:22:05 +00:00
Simon McVittie
b1cfd892fc test: Move string tests (most of dbus-string-util.c) here
Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-01-21 15:21:43 +00:00
Simon McVittie
8ead2011ac test: Move marshalling tests into test/
dbus-marshal-recursive-util.c contains utility functions used by the
other two, as well as tests. The others are purely test code.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-01-21 15:21:16 +00:00
Simon McVittie
f1f5294276 test: Move dbus-message-factory and most of dbus-message-util into test/
As with previous moves, I've tried to extract the possible copyright
holders from the git history.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-01-21 15:20:39 +00:00
Simon McVittie
9feeeaea9a test: Move auth, credentials tests from libdbus-internal into test/
Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-01-21 15:20:22 +00:00