]> 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)
committerAlan Coopersmith <alan.coopersmith@oracle.com>
Sun, 13 Oct 2024 19:37:32 +0000 (12:37 -0700)
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>
test/fdpass.c

index 664fd1363e66943680b93bdc0e0420c83721e1ff..46f0b7ebfaeed0efa30eed49f1b9d52a08f936cf 100644 (file)
@@ -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