aboutsummaryrefslogtreecommitdiff
path: root/tests/libtest/lib518.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/libtest/lib518.c')
-rw-r--r--tests/libtest/lib518.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/tests/libtest/lib518.c b/tests/libtest/lib518.c
index 47cea8244..368b902ae 100644
--- a/tests/libtest/lib518.c
+++ b/tests/libtest/lib518.c
@@ -360,16 +360,31 @@ static int rlimit(int keep_open)
* with an indication that select limit would be exceeded.
*/
- sprintf(strbuff2, fmt, num_open.rlim_max);
- sprintf(strbuff, "fds open %s > select limit %d",
- strbuff2, FD_SETSIZE);
- store_errmsg(strbuff, 0);
- fprintf(stderr, "%s\n", msgbuff);
- close_file_descriptors();
- free(memchunk);
- return -10;
+ num_open.rlim_cur = FD_SETSIZE - SAFETY_MARGIN;
+ if (num_open.rlim_max > num_open.rlim_cur) {
+ sprintf(strbuff, "select limit is FD_SETSIZE %d", FD_SETSIZE);
+ store_errmsg(strbuff, 0);
+ fprintf(stderr, "%s\n", msgbuff);
+ close_file_descriptors();
+ free(memchunk);
+ return -10;
+ }
-#endif
+ num_open.rlim_cur = FD_SETSIZE - SAFETY_MARGIN;
+ for (rl.rlim_cur = 0;
+ rl.rlim_cur < num_open.rlim_max;
+ rl.rlim_cur++) {
+ if (fd[rl.rlim_cur] > num_open.rlim_cur) {
+ sprintf(strbuff, "select limit is FD_SETSIZE %d", FD_SETSIZE);
+ store_errmsg(strbuff, 0);
+ fprintf(stderr, "%s\n", msgbuff);
+ close_file_descriptors();
+ free(memchunk);
+ return -11;
+ }
+ }
+
+#endif /* using a FD_SETSIZE bound select() */
/* free the chunk of memory we were reserving so that it
becomes becomes available to the test */