From: Alan Coopersmith Date: Sun, 13 Oct 2024 19:33:06 +0000 (-0700) Subject: test: Move fd limit check into test_flood X-Git-Tag: dbus-1.15.12~8^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=72642d7ff6c2ed64de736b0128b887865034d45f;p=thirdparty%2Fdbus.git test: Move fd limit check into test_flood Other tests have different requirements for fds (and already check for them), so move this check into the specific test (mirroring what those other tests already do) instead of blocking the whole test program, incorrectly using autoconf test return codes instead of TAP protocol, as discussed in #176. Signed-off-by: Alan Coopersmith --- diff --git a/test/fdpass.c b/test/fdpass.c index 664fd1363..46f0b7ebf 100644 --- a/test/fdpass.c +++ b/test/fdpass.c @@ -674,10 +674,27 @@ test_flood (Fixture *f, unsigned int i, j; DBusMessage *outgoing[SOME_MESSAGES]; dbus_uint32_t serial; +#ifdef HAVE_GETRLIMIT + struct rlimit lim; +#endif if (f->skip) return; +#ifdef HAVE_GETRLIMIT + if (getrlimit (RLIMIT_NOFILE, &lim) == 0) + { + 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_test_skip ("not enough RLIMIT_NOFILE to run this test"); + return; + } + } +#endif + test_connect (f, TRUE); for (j = 0; j < SOME_MESSAGES; j++) @@ -919,16 +936,6 @@ main (int argc, g_error ("Failed to set RLIMIT_NOFILE limit to %ld: %s", (long) lim.rlim_cur, 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