]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
test: Move fd limit check into test_flood
authorAlan Coopersmith <alan.coopersmith@oracle.com>
Sun, 13 Oct 2024 19:33:06 +0000 (12:33 -0700)
committerSimon McVittie <smcv@collabora.com>
Mon, 28 Oct 2024 16:47:41 +0000 (16:47 +0000)
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 <alan.coopersmith@oracle.com>
(cherry picked from commit 72642d7ff6c2ed64de736b0128b887865034d45f)

test/fdpass.c

index bea208e0e190d9ff4ba7fd60e7f9862eec648613..1dd7814866e2903d2d8b2806e6d5a7dcd923015a 100644 (file)
@@ -673,10 +673,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++)
@@ -909,16 +926,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