diff options
author | Simon McVittie <smcv@debian.org> | 2015-02-19 13:35:29 +0000 |
---|---|---|
committer | Simon McVittie <smcv@debian.org> | 2015-02-19 13:35:29 +0000 |
commit | 5a676818770d64c5508f5cf28e22228f68b325aa (patch) | |
tree | acfbf8e52304dce6a8450ad3c390cdf874a6fd3e /test/fdpass.c | |
parent | 8fd2c8098849695fce037fa3731a916ac5354e91 (diff) | |
parent | 87fe648a5c883d1f790a5d40abfd4a68aff0784c (diff) | |
download | dbus-5a676818770d64c5508f5cf28e22228f68b325aa.tar.gz |
Imported Upstream version 1.9.12upstream/1.9.12
Diffstat (limited to 'test/fdpass.c')
-rw-r--r-- | test/fdpass.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/test/fdpass.c b/test/fdpass.c index fa958da8..96f9427f 100644 --- a/test/fdpass.c +++ b/test/fdpass.c @@ -57,9 +57,11 @@ _DBUS_STATIC_ASSERT (MAX_MESSAGE_UNIX_FDS <= 253); /* Arbitrary; included here to avoid relying on the default. */ #define MAX_INCOMING_UNIX_FDS (MAX_MESSAGE_UNIX_FDS * 4) -/* 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. */ +_DBUS_STATIC_ASSERT (MAX_MESSAGE_UNIX_FDS * SOME_MESSAGES > 256); /* 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); +#ifdef HAVE_GETRLIMIT + { + 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. */ + lim.rlim_cur < 2 * MAX_MESSAGE_UNIX_FDS * SOME_MESSAGES) + { + g_message ("not enough RLIMIT_NOFILE to run this test"); + /* Autotools exit code for "all skipped" */ + return 77; + } + } +#endif + g_test_add ("/relay", Fixture, NULL, setup, test_relay, teardown); g_test_add ("/limit", Fixture, NULL, setup, |