]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
test: raise fd limit to maximum before running fdpass tests
authorAlan Coopersmith <alan.coopersmith@oracle.com>
Sun, 13 Oct 2024 19:24:09 +0000 (12:24 -0700)
committerSimon McVittie <smcv@collabora.com>
Mon, 28 Oct 2024 16:47:41 +0000 (16:47 +0000)
Many of these tests require more than the default fd limit on some systems,
so raise the limit, if we can, to give them a better chance of being able
to run.

Closes #176
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
(cherry picked from commit f851484bf5aa0ef40eca1c34a215be5346095b2f)

test/fdpass.c

index abd415044250bea680174be5977cb1ce6f971413..bea208e0e190d9ff4ba7fd60e7f9862eec648613 100644 (file)
@@ -900,6 +900,16 @@ main (int argc,
       if (getrlimit (RLIMIT_NOFILE, &lim) < 0)
         g_error ("Failed to get RLIMIT_NOFILE limit: %s", g_strerror (errno));
 
+      if ((lim.rlim_cur != RLIM_INFINITY) && (lim.rlim_cur < lim.rlim_max))
+        {
+          /* Many test require large number of file descriptors,
+           * so max out what they can use */
+          lim.rlim_cur = lim.rlim_max;
+          if (setrlimit (RLIMIT_NOFILE, &lim) < 0)
+            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. */