diff options
author | Simon McVittie <smcv@collabora.com> | 2019-01-25 11:49:56 +0000 |
---|---|---|
committer | Simon McVittie <smcv@collabora.com> | 2019-01-25 11:49:56 +0000 |
commit | 02e3c4fdfa71cff414bd963866658733c8698074 (patch) | |
tree | 83d68f139a01cfa9ff993f3aa61d8981e4edf732 /test/test-utils.c | |
parent | 8747c9b5a06209b22d6b5c89c6ef44d88a74197f (diff) | |
download | dbus-02e3c4fdfa71cff414bd963866658733c8698074.tar.gz |
_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>
Diffstat (limited to 'test/test-utils.c')
-rw-r--r-- | test/test-utils.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/test-utils.c b/test/test-utils.c index d3616504..51471db7 100644 --- a/test/test-utils.c +++ b/test/test-utils.c @@ -519,6 +519,23 @@ _dbus_test_main (int argc, else specific_test = strdup0_or_die (_dbus_getenv ("DBUS_TEST_ONLY")); + /* Some NSS modules like those for sssd and LDAP might allocate fds + * on a one-per-process basis. 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. */ + { + DBusString username; + dbus_uid_t ignored_uid = DBUS_UID_UNSET; + + _dbus_string_init_const (&username, "dbus-no-user-with-this-name"); + /* We use a username that almost certainly doesn't exist, because + * if we used something like root it might get handled early in the + * NSS search order, before we get as far as asking sssd or LDAP. */ + _dbus_parse_unix_user_from_config (&username, &ignored_uid); + _dbus_test_check_memleaks ("initial nss query"); + } + for (i = 0; i < n_tests; i++) { long before, after; |