Commit graph

17 commits

Author SHA1 Message Date
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
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
b7f11c17d1 _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>
2019-01-21 15:19:36 +00:00
Simon McVittie
651a82e685 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>
2019-01-21 15:14:29 +00:00
Daniel Wendt
37b6e180e1 Enable "unused result" warning for Visual Studio >= 2012 (MSVC 11.0)
The _Must_inspect_result_ annotation is documented to be used in both
the declaration and implementation, but in testing with the MSVC 2012
compiler it appears to be sufficient to use the annotation only in the
declaration to get a compiler warning, as with the GCC compiler.
So the annotation is not necessary in the C implementation.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=105460
[smcv: Rebase dbus-sysdeps.h changes on master]
[smcv: Clarify commit message]
Reviewed-by: Simon McVittie <smcv@collabora.com>
Tested-by: Daniel Wendt <daniel.wendt@linux.com>
2018-03-15 19:53:05 +00:00
Simon McVittie
f59b4f9226 test-utils: Separate failable and non-failable functions
test_object_try_whatever() now has libdbus-like OOM handling,
while test_object_whatever() has GLib-like OOM handling. This is
because an overwhelming majority of the callers of these functions
either didn't check for OOM anyway, or checked for it but then
aborted. In the uncommon case where we do care, we can use the _try_
version.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=100317
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Signed-off-by: Simon McVittie <smcv@collabora.com>
2017-12-04 11:52:52 +00:00
Simon McVittie
dbd731491b tests: always use libdbus-internal for main loop, never dbus-glib
This gets rid of a potential circular dependency, which is annoying
when bootstrapping. It is nice to have the regression tests use
the shared libdbus, but we're about to make it possible to
do that anyway, even though some of them use internal symbols.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=83115
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-02-20 20:49:32 +00:00
Simon McVittie
8b238f3f0d Factor out some utility functions from test/dbus-daemon*
In the process, make test_kill_pid() safer: do not try to terminate
more than one pid, or the NULL handle.

Also stop leaking the address_fd in spawn_dbus_daemon, a pre-existing
bug that was spotted by Philip Withnall during review.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88810
Reviewed-by: Philip Withnall
2015-02-03 16:18:57 +00:00
Simon McVittie
30e7a81302 Tests: allow dbus-glib to be replaced with use of libdbus-internal
We only use dbus-glib for its main loop; within dbus, DBusLoop is
available as an alternative, although it isn't thread-safe and
isn't public API.

For tests that otherwise only use libdbus public API, it's desirable to
be able to avoid DBusLoop, so we can run them against an installed
libdbus as an integration test. However, if we don't have dbus-glib,
we're going to have to use an in-tree main loop, which might as well
be DBusLoop.

The major disadvantage of using dbus-glib is that it isn't safe to
link both dbus-1 and dbus-internal at the same time. This is awkward
for a future test case that wants to use _dbus_getsid() in dbus-daemon.c,
but only on Windows (fd.o #54445). If we use the same API wrapper around
both dbus-glib and DBusLoop, we can compile that test against dbus-glib
or against DBusLoop, depending on the platform.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68852
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2013-09-03 12:00:51 +01:00
Simon McVittie
f17fd1cc4e Define DBUS_COMPILATION externally for all tests that use internal stuff
It might as well go in the AM_CPPFLAGS rather than in the source code.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68852
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2013-09-03 12:00:44 +01:00
Marcus Brinkmann
dbecdeabb2 Consistently include <config.h> in all C source files and never in header files. 2010-03-19 20:11:48 +01:00
Colin Walters
a73a79a155 Add noinst convenience test library, add a test-shutdown
* test/Makefile.am: New convenience library
	libdbus_testutils_la.  Reorder build so that
	test/ gets built before test/name-test so
	name-test files can depend on it.
	* test/name-test/test-shutdown.c: New file,
	exercises dbus_shutdown () a bit.
	* test/name-test/run-test.sh Run test-shutdown.
	* test/test-utils.h: In some cases we already have
	DBUS_COMPILATION defined, avoid double definition
	warning.
2008-05-30 16:53:35 -04:00
Colin Walters
9d8989cfec Add test library functions for using DBusServer
* test/test-utils.h, test/test-utils.c: Add functions
	which hook up a DBusServer to a DBusLoop, useful
	for test cases.
2008-05-30 16:19:40 -04:00
Havoc Pennington
fe22b2194d 2003-04-07 Havoc Pennington <hp@redhat.com>
* doc/dbus-specification.sgml: require that base service names
	start with ':' and that the base service is created/deleted
	as first and last things a connection does on the bus

	* bus/dispatch.c (check_existent_service_activation): lots more
	work on the activation test; it doesn't fully pass yet...

	* test/test-service.c (main): fix so we don't memleak the
	connection to the message bus
	(filter_func): accept a message asking us to exit
2003-04-07 23:28:16 +00:00
Havoc Pennington
1617fbe36c having a bad cvs add day apparently 2003-04-07 15:42:22 +00:00