summaryrefslogtreecommitdiff
path: root/test/test-utils-glib.h
Commit message (Collapse)AuthorAgeFilesLines
* test: Skip TCP tests if getaddrinfo doesn't workSimon McVittie2018-06-041-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For example, this can be the case in bubblewrap or Debian pbuilder after unsharing the network namespace: bwrap \ --bind / / \ --dev-bind /dev /dev \ --bind /dev/shm /dev/shm \ --bind /dev/pts /dev/pts \ --unshare-net \ ${builddir}/test/test-loopback --tap ... ok 1 /connect/tcp # SKIP Name resolution does not work here: getaddrinfo("127.0.0.1", "0", {flags=ADDRCONFIG, family=INET, socktype=STREAM, protocol=TCP}): Name or service not known On some systems this can be circumvented by using nss_wrapper from <https://cwrap.org/nss_wrapper.html>: cat > hosts <<EOF 127.0.0.1 localhost EOF bwrap \ ... \ env \ LD_PRELOAD=libnss_wrapper.so \ NSS_WRAPPER_HOSTS=$(pwd)/hosts \ ${builddir}/test/test-loopback --tap ... # listening at tcp:host=127.0.0.1,port=39219,family=ipv4,guid=... but for systems where that does't work, we should be prepared to skip the affected tests. Signed-off-by: Simon McVittie <smcv@collabora.com> Reviewed-by: Philip Withnall <withnall@endlessm.com> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=106812 (cherry picked from commit f1faafd59bec67d347edb10447c4b9b18193458c)
* Add a simplified backport of g_steal_pointer()Simon McVittie2018-02-071-0/+15
| | | | | | | | | | | | | | | This will be used in tests later in the branch. Sadly we can't use GLIB_VERSION_2_44 unless we are willing to have a hard dependency on GLib 2.44, which would force us to do all our Travis-CI builds in Docker containers rather than in ye olde base system, and that adds 50% to the time taken to do builds. Reviewed-by: Philip Withnall <withnall@endlessm.com> [smcv: Rebase onto 1.13.x branch, fix minor conflicts] Signed-off-by: Simon McVittie <smcv@collabora.com> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=101354 (cherry picked from commit d5742550ca566317eaddea0ff7db04098f9f044f)
* tests: Add the ability to multiply up test timeoutsSimon McVittie2018-02-061-1/+1
| | | | | | | | | Tests that brute-force OOM code paths can be rather slow. 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> (cherry picked from commit 5c91d85f3ed462dac1e011aab216c9021e826773)
* tests: In slower tests, make the timeout per-test-caseSimon McVittie2017-09-271-0/+2
| | | | | | | | | | | | | | | Some test-cases in the dbus-daemon and relay tests spam the bus with thousands of messages, which can take 25 seconds on slower CPUs like MIPS. Similarly, the refs test spams millions of refcount operations, which it appears might take more than a minute on PA-RISC (HPPA). To get an idea of how close we are to having a problem on other architectures, log a message and start a timer when we reset the timeout in setup(), and log the elapsed time when we reach teardown(). Bug: https://bugs.freedesktop.org/show_bug.cgi?id=103009 Signed-off-by: Simon McVittie <smcv@collabora.com> Reviewed-by: Philip Withnall <withnall@endlessm.com>
* Bump GLib dependency for tests to 2.40Simon McVittie2017-06-121-8/+0
| | | | | | | | | | | | | | | | | | This is quite old (it's the version in Ubuntu 14.04 LTS, and older than the version in Debian 8) but gives us g_test_skip(), g_test_trap_subprocess() and GVariantDict, all of which will be useful in the regression tests. Remove workarounds for old versions. After this commit we are still using the deprecated g_test_trap_fork(), which will be removed in a subsequent commit. Don't opt-in to the new deprecation warnings from 2.38 and 2.40 yet, because under our recommended settings for dbus developers (-Werror) they would break the build. Signed-off-by: Simon McVittie <smcv@collabora.com> Reviewed-by: Philip Withnall <withnall@endlessm.com> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=101362
* sd-activation test: Exercise transient servicesSimon McVittie2017-02-211-0/+1
| | | | | | | | | | To do this, we have to use the <standard_session_servicedirs/>. A previous commit ensured that those don't provide any service files we don't expect. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=99825 Reviewed-by: Philip Withnall <withnall@endlessm.com> Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
* sd-activation test: Create and destroy a temporary XDG_RUNTIME_DIRSimon McVittie2017-02-211-0/+1
| | | | | | Bug: https://bugs.freedesktop.org/show_bug.cgi?id=99825 Reviewed-by: Philip Withnall <withnall@endlessm.com> Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
* tests: Wrap file-deletion functions to handle EINTRSimon McVittie2017-02-201-0/+3
| | | | | | | | | | | | | | The GLib functions we're using don't, and it seems to be possible to be interrupted during cleanup for our tests. Windows apparently has and uses ENOENT for _unlink(), so just do the same on Windows there; but EINTR is very much a POSIX thing, so ignore that on Windows. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=99825 Reviewed-by: Philip Withnall <withnall@endlessm.com> [smcv: add Windows fixes from a later commit, also reviewed by Philip] Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
* test_get_dbus_daemon: Take a custom XDG_RUNTIME_DIR as an argumentSimon McVittie2017-02-201-0/+1
| | | | | | Bug: https://bugs.freedesktop.org/show_bug.cgi?id=99825 Reviewed-by: Philip Withnall <withnall@endlessm.com> Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
* tests: provide g_test_skip() emulation for older GLibSimon McVittie2015-04-161-0/+8
| | | | | | | | | We don't hard-depend on a new enough GLib to have g_test_skip(); if our GLib is older, fake it using g_test_message() and degrade to reporting it as a pass rather than a skip. Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89846
* tests: avoid noise on stdout when not --verboseSimon McVittie2015-04-161-0/+2
| | | | | | | | | | | This makes life easier for frameworks like LAVA that screen-scrape test results. g_test_message() is not displayed by default, but each test can be run with either --tap or --verbose to get these messages displayed. Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89846
* Add a common test_init() for GLib tests which prevents hanging foreverSimon McVittie2015-02-041-0/+2
| | | | | Bug: https://bugs.freedesktop.org/show_bug.cgi?id=46787 Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
* Treat root as a valid candidate for TEST_USER_MESimon McVittie2015-02-031-4/+3
| | | | | | | | | | | | If spawn_dbus_daemon() can fail for TEST_USER_ME, then we'd have to go through all the tests adding the ability to skip tests after it fails, which is a fairly extensive change. The tests have historically all run as whatever uid is supplied, and if the tests are being run as root for some reason - perhaps in a CI framework for an embedded platform that doesn't have non-root users, or in an environment where you can be root or non-root but not both - there is no particular reason to skip them.
* Add a test for uid-controlled permissionsSimon McVittie2015-02-031-0/+3
| | | | | | | | This is technical debt from mitigating CVE-2014-8148, which should really have had a regression test at the time. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88810 Reviewed-by: Philip Withnall
* Add infrastructure to run bits of tests under an alternative uidSimon McVittie2015-02-031-0/+31
| | | | | Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88810 Reviewed-by: Philip Withnall
* Factor out some utility functions from test/dbus-daemon*Simon McVittie2015-02-031-0/+49
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