summaryrefslogtreecommitdiff
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
* Add test for _dbus_string_skip_blank()Ralf Habacker2023-02-084-0/+54
| | | | | | [smcv: Fix a memory leak] Reproduces: https://gitlab.freedesktop.org/dbus/dbus/-/issues/421
* gitlab-ci: build libdbus as subprojectDaniel Wagner2023-02-075-0/+72
| | | | | | | Test it's possible to consume libdbus as a subproject. Suggested-by: Simon McVittie <smcv@collabora.com> Signed-off-by: Daniel Wagner <dwagner@suse.de>
* cmake: add missing test for header-fieldsRalf Habacker2023-02-061-0/+1
| | | | Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
* Add multithreaded unit test for DBusCounter to available build systemsRalf Habacker2023-01-054-0/+142
| | | | | The mentioned test is build on unix like platforms when embedded tests are enabled.
* meson: Introduce message_bus and tools command line optionDaniel Wagner2023-01-042-28/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | To make the consume libdbus via Meson's subproject use case more useful, introduce message_bus and tools command line options which control if the D-Bus daemon and/or the tools are build. The idea here is that depending projects are interested only in the library. The strong recommendation is only to build libdbus as static library: libdbus_dep = dependency( 'dbus-1', required: get_option('libdbus'), fallback: ['dbus', 'libdbus_dep'], default_options: [ 'default_library=static', 'embedded_tests=false', 'message_bus=false', 'modular_tests=disabled', 'tools=false', ], ) This ensures that any installed D-Bus infrastructure on the target system is not overwritten. Signed-off-by: Daniel Wagner <dwagner@suse.de>
* Add SPDX license marker for the AFL-2.1 OR GPL-2.0-or-later licenseRalf Habacker2023-01-0434-0/+68
| | | | | | | | | The full license texts are not added because they were already added in a previous commit. Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de> see #394
* Permit access to /tmp dbus socketDave Jones2023-01-031-0/+4
| | | | | | After 6e48c317 the test-apparmor-activation test fails as it can no longer access the dbus socket in /tmp. This commit updates the apparmor profile used within the test
* Fix some stray filename references for GPL-2.0-or-laterSimon McVittie2022-11-291-1/+1
| | | | | | The SPDX name for this license includes the `.0`. Signed-off-by: Simon McVittie <smcv@collabora.com>
* Use 'continue' keyword in preference to 'goto' where possibleSimon McVittie2022-11-294-18/+25
| | | | | | | | | | | | | | | In some more complicated loops, we do need to use 'goto' to exit from an inner loop, or to jump to cleanup or an increment of an iterator immediately before the next loop iteration. However, in these simple cases, jumping to a label immediately before the 'while' keyword is unnecessary: we can use an equivalent 'continue' statement for flow control. This makes it easier for maintainers to notice the loops where we are doing something more complicated, which still use 'goto', and know that they need to pay more attention in those cases. Signed-off-by: Simon McVittie <smcv@collabora.com>
* dbus-hash: Add (AFL-2.1 OR GPL-2.0-or-later) AND TCL SPDX license identifierSimon McVittie2022-11-291-0/+1
| | | | | | | The TCL-derived code is under its own license, so the overall license of the file is (AFL-2.1 OR GPL-2.0-or-later) AND TCL. Signed-off-by: Simon McVittie <smcv@collabora.com>
* test-exit: Add a permissive licenseSimon McVittie2022-10-121-0/+5
| | | | | | | Red Hat have previously given permission for relicensing, and all subsequent contributions to this file were trivial. Signed-off-by: Simon McVittie <smcv@collabora.com>
* test-threads-init: Add a permissive licenseSimon McVittie2022-10-121-0/+6
| | | | | | | | With permission from Philip Withnall on behalf of Endless, me on behalf of Collabora, and relying on previous permission from Red Hat representatives. Signed-off-by: Simon McVittie <smcv@collabora.com>
* manual-tcp: Add a permissive licenseSimon McVittie2022-10-121-0/+3
| | | | | | With permission from Ralf Habacker via dbus!304 and the mailing list. Signed-off-by: Simon McVittie <smcv@collabora.com>
* manual-paths: Apply a permissive licenseSimon McVittie2022-10-121-0/+4
| | | | | | | | This was contributed by Ralf Habacker and later edited by me, with a trivial change from Thomas Zimmermann which I don't think affects its copyright. Signed-off-by: Simon McVittie <smcv@collabora.com>
* manual-dir-iter: Apply a permissive licenseSimon McVittie2022-10-121-0/+4
| | | | | | | This was contributed by Ralf Habacker, with a trivial change from Philip Withnall which I don't think affects its copyright. Signed-off-by: Simon McVittie <smcv@collabora.com>
* test-shutdown: Apply a permissive licenseSimon McVittie2022-10-121-0/+6
| | | | | | | | | All significant contributions to this file were from companies or individuals that gave permission for relicensing to MIT (I have assumed that trivial changes from Marcus Brinkmann and Kjartan Maraas were too small to affect copyright status). Signed-off-by: Simon McVittie <smcv@collabora.com>
* test-ids: Apply a permissive licenseSimon McVittie2022-10-121-0/+5
| | | | | | | | | All significant contributions to this file were from companies that gave permission for relicensing to MIT (I have assumed that trivial changes from Marcus Brinkmann and Ralf Habacker were too small to affect copyright status). Signed-off-by: Simon McVittie <smcv@collabora.com>
* test-autolaunch: Add a permissive licenseSimon McVittie2022-10-121-0/+6
| | | | | | | | The license for this file was never stated, but all contributions to it have been from Red Hat or Collabora, and representatives of both companies gave permission for MIT relicensing in 2007. Signed-off-by: Simon McVittie <smcv@collabora.com>
* launch-helper-for-tests: Add a permissive licenseSimon McVittie2022-10-121-1/+5
| | | | | | I wrote this, and it hasn't changed since. Signed-off-by: Simon McVittie <smcv@collabora.com>
* test-autolaunch-win.c: Prevent assertion in dbus_message_unref()Ralf Habacker2022-10-121-1/+1
| | | | | | | | | dbus_message_unref() is in principle able to handle a NULL parameter, but causes the program to abort when `fatal_warnings_on_check_failed` is set. Therefore the call with a NULL parameter is avoided from now on. Fixes #422
* test-autolaunch-win: Remove redundant check for ERROR messageSimon McVittie2022-10-111-21/+2
| | | | | | | | | | | This seems to have been intended to give a more specific error message if the method call failed, but it will not have been effective, because dbus_connection_send_with_reply_and_block() ends with a check for ERROR messages using dbus_set_error_from_message(). This means that if the reply was an ERROR message, it will already have been converted into a DBusError by the time call_method() regains control. Signed-off-by: Simon McVittie <smcv@collabora.com>
* test-autolaunch-win: Don't overwrite an error with another errorSimon McVittie2022-10-111-1/+0
| | | | | | | | | | | | | | | | | | | An unrelated branch failed CI with this assertion failure: 26: dbus[6768]: error: arguments to dbus_set_error() were incorrect, assertion "(error) == NULL || !dbus_error_is_set ((error))" failed in file ...\dbus-errors.c line 365. Looking at the test, this seems to be the most likely candidate for this bug in error handling, which is masking whatever the real cause for the failure was (we can't tell from here). If dbus_connection_send_with_reply_and_block() returns NULL, then it should already have set the error. Fixing this bug in the error handling will hopefully give us a better error message for the actual failure if it happens again. Signed-off-by: Simon McVittie <smcv@collabora.com>
* dbus/dbus-macros-internal, test/test-platform-mutex.c: Use upper case for ↵Ralf Habacker2022-10-111-1/+1
| | | | | | | SPDX license operator https://spdx.github.io/spdx-spec/SPDX-license-expressions/ says that using upper-case operators is canonical.
* dbus-message: Report OOM as OOM, not InvalidArgsSimon McVittie2022-10-111-9/+0
| | | | | Resolves: https://gitlab.freedesktop.org/dbus/dbus/-/issues/420 Signed-off-by: Simon McVittie <smcv@collabora.com>
* dbus-connection: Test built-in filtersKai A. Hiller2022-10-111-0/+87
|
* dbus-monitor: Disable automatic message filteringKai A. Hiller2022-10-111-1/+1
|
* test: Parse a message with a byteswapped Unix fd indexSimon McVittie2022-10-055-0/+48
| | | | | Reproduces: https://gitlab.freedesktop.org/dbus/dbus/-/issues/417 Signed-off-by: Simon McVittie <smcv@collabora.com>
* test: Add infrastructure to parse valid raw message blobsSimon McVittie2022-10-057-0/+194
| | | | Signed-off-by: Simon McVittie <smcv@collabora.com>
* test: Add targeted tests for dbus/dbus#413, dbus/dbus#418Simon McVittie2022-10-051-3/+95
| | | | | | | | | | Unlike the message-internals test, these do not rely on extra debug instrumentation in libdbus, and so can be used for "as-installed" testing. (However, they do require GLib.) Reproduces: https://gitlab.freedesktop.org/dbus/dbus/-/issues/413 Reproduces: https://gitlab.freedesktop.org/dbus/dbus/-/issues/418 Signed-off-by: Simon McVittie <smcv@collabora.com>
* test: Export G_TEST_BUILDDIR, G_TEST_SRCDIRSimon McVittie2022-10-052-0/+4
| | | | | | | | | | | | | | These environment variables are used by GLib's g_test_build_filename() and related convenience functions, which make it easier for unit tests to find data files in a way that works for both build-time tests and "as-installed" tests. During "as-installed" testing, both variables will normally be unset, and GLib uses the directory containing the executable. In most cases that results in the right thing happening, and this will also be true for dbus, since we install the test executables in ${libexecdir}/installed-tests, helper executables in the same place, and test data in ${libexecdir}/installed-tests/data. Signed-off-by: Simon McVittie <smcv@collabora.com>
* test/data: Add messages that reproduce dbus/dbus#413, dbus/dbus#418Simon McVittie2022-10-0512-0/+194
| | | | | | | | | | | | | | | | | | | | | | | | In debug builds with "embedded tests" enabled, these will automatically be used as input for the message-internals test. Some of the messages themselves are output from a fuzzer, others are simplifications to include only one reason for lack of validity per message. I've included an annotated hex-dump for each message here, but the dbus test suite doesn't currently know how to convert hex to binary, so I've also committed the corresponding binary. See the comment at the top of each hex-dump for how to create the binary version (which requires the xxd tool shipped with vim). It would be nice for the dbus test suite to be able to convert the annotated hex-dump to binary, either at build-time with a Python script or at runtime by loading the text file and decoding the hex, but I don't want to block on that for dbus/dbus#413 and dbus/dbus#418. Reproduces: https://gitlab.freedesktop.org/dbus/dbus/-/issues/413 Reproduces: https://gitlab.freedesktop.org/dbus/dbus/-/issues/418 Signed-off-by: Simon McVittie <smcv@collabora.com>
* test-syntax: Exercise correctly- and incorrectly-nested structs, dictsSimon McVittie2022-10-051-0/+10
| | | | | Reproduces: https://gitlab.freedesktop.org/dbus/dbus/-/issues/418 Signed-off-by: Simon McVittie <smcv@collabora.com>
* gitlab-ci: update FreeBSD CI image to 13.1Alex Richardson2022-09-211-2/+2
| | | | | | | | | | FreeBSD 13.0 has reached EOL and it appears packages are built against a newer baseline now, so we end up with missing symbol errors: ld-elf.so.1: /lib/libc.so.7: version FBSD_1.7 required by /usr/local/lib/libpython3.9.so.1.0 not found It also appears that the fdpass test still fails on 13.1, so update the condition to less than 14.0
* test: Use DBUS_TEST_SOCKET_DIR to create the test socketAlex Richardson2022-09-151-39/+81
| | | | | | | I am trying to run cross-compiled tests in QEMU with the build directory mounted via smbfs, and therefore creating the sockets in the CWD does not work. Using DBUS_TEST_SOCKET_DIR (/tmp by default) allows me to run the tests successfully.
* test: Don't use strict TAP parsing on WindowsSimon McVittie2022-09-121-0/+3
| | | | | | | | | Debug messages in a background thread can corrupt the machine-readable TAP output, and in particular GWin32AppInfo emits debug messages from a background thread when we link to libgio. Resolves: https://gitlab.freedesktop.org/dbus/dbus/-/issues/414 Signed-off-by: Simon McVittie <smcv@collabora.com>
* build: Only work around Meson 0.63.0 bugs for version 0.63.0Simon McVittie2022-09-121-1/+1
| | | | | | mesonbuild/meson#10577 was fixed in 0.63.1. Signed-off-by: Simon McVittie <smcv@collabora.com>
* test/fdpass.c: skip test that fails on FreeBSD 13.0Alex Richardson2022-08-101-0/+9
| | | | | | | | | The /odd-limit/at test passes on 13.1 and 14.0 images, but fails on 13.1. Debugging has not given me any useful hints why this may be the case, so disable this test on 13.0 for now. This allows us to drop the ci_test_fatal: "no" override which will ensure that any FreeBSD regressions are caught.
* test-utils-glibc.c: Fix -Werror,-Wmissing-noreturn on FreeBSDAlex Richardson2022-08-101-4/+8
| | | | | Add a conditional _DBUS_GNUC_NORETURN to avoid `error: function 'back_to_root' could be declared with attribute 'noreturn'`
* test-utils-glib.c: Avoid using a non-portable errno valueAlex Richardson2022-08-101-1/+1
| | | | | | ENODATA is not available on FreeBSD. Since the actual errno value here does not matter, use EPERM instead. This fixes the DBus build on FreeBSD.
* Use project relative paths in CMake filesJordan Williams2022-07-251-3/+3
| | | | | | | 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.
* test/bus: Break up dispatch test into three separate testsSimon McVittie2022-07-186-19/+148
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* test/bus: Factor out common setup/teardown codeSimon McVittie2022-07-188-102/+97
| | | | Signed-off-by: Simon McVittie <smcv@collabora.com>
* test: Skip tests that involve switching uid if unable to do soSimon McVittie2022-07-181-0/+62
| | | | | | | | | | | | | | | 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>
* gitlab: skip failing runtime directory check, add FIXMEMarc-André Lureau2022-07-151-0/+4
| | | | Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
* test: enable AF_UNIX server-oom test on !unixMarc-André Lureau2022-07-151-2/+4
| | | | Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
* test/server-oom: do not hardcode /tmpMarc-André Lureau2022-07-151-1/+9
| | | | Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
* test: enable AF_UNIX relay tests on !unixMarc-André Lureau2022-07-151-5/+4
| | | | Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
* test/relay: do not hardcode /tmp on !unixMarc-André Lureau2022-07-151-3/+11
| | | | Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
* test: enable AF_UNIX loopback tests on !unixMarc-André Lureau2022-07-151-11/+4
| | | | Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
* tests/loopback: do not hardcode /tmp for !unixMarc-André Lureau2022-07-151-11/+30
| | | | Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>