Commit e3873312 authored by Simon McVittie's avatar Simon McVittie
Browse files

Reduce the number of fds the fdpass test uses

It was relying on a higher-than-default fd limit; cut it down to
more than 256 but rather less than 1024, since the default Linux
limit is 1024 fds per user.

Also automatically skip this test if our rlimit is too small.


Reviewed-by: Philip Withnall's avatarPhilip Withnall <>
parent 4a394397
......@@ -57,9 +57,11 @@ _DBUS_STATIC_ASSERT (MAX_MESSAGE_UNIX_FDS <= 253);
/* Arbitrary; included here to avoid relying on the default. */
/* Arbitrary, except that MAX_MESSAGE_UNIX_FDS * SOME_MESSAGES must be
/* Arbitrary, except that MAX_MESSAGE_UNIX_FDS * SOME_MESSAGES should be
* less than the process's file descriptor limit. */
#define SOME_MESSAGES 50
#define SOME_MESSAGES 20
/* To cover some situations on Linux we want this to be true. */
/* Linux won't allow more than 253 fds per sendmsg(). */
#define TOO_MANY_FDS 255
......@@ -809,6 +811,25 @@ main (int argc,
test_init (&argc, &argv);
struct rlimit lim;
if (getrlimit (RLIMIT_NOFILE, &lim) < 0)
g_error ("Failed to get RLIMIT_NOFILE limit: %s", g_strerror (errno));
if (lim.rlim_cur != RLIM_INFINITY &&
/* only run if we have a fairly generous margin of error
* for stdout, stderr, duplicates, the D-Bus connection, etc. */
g_message ("not enough RLIMIT_NOFILE to run this test");
/* Autotools exit code for "all skipped" */
return 77;
g_test_add ("/relay", Fixture, NULL, setup,
test_relay, teardown);
g_test_add ("/limit", Fixture, NULL, setup,
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment