]>
git.saurik.com Git - apple/libc.git/blob - tests/stdio.c
5 #include <sys/resource.h>
7 #include <darwintest.h>
11 T_DECL(PR_22813396
, "STREAM_MAX is affected by changes to RLIMIT_NOFILE")
13 struct rlimit theLimit
;
14 getrlimit( RLIMIT_NOFILE
, &theLimit
);
15 theLimit
.rlim_cur
= FILE_LIMIT
;
16 setrlimit( RLIMIT_NOFILE
, &theLimit
);
18 long stream_max
= sysconf(_SC_STREAM_MAX
);
19 T_EXPECT_EQ_LONG(stream_max
, (long)FILE_LIMIT
, "stream_max = FILE_LIMIT");
22 for(int i
= 3; i
< stream_max
; i
++) {
23 if((f
= fdopen(0, "r")) == NULL
) {
24 T_FAIL("Failed after %d streams", i
);
29 T_EXPECT_NULL(f
, "fdopen fail after stream_max streams");
31 theLimit
.rlim_cur
= FILE_LIMIT
+ 1;
32 setrlimit( RLIMIT_NOFILE
, &theLimit
);
35 T_EXPECT_NOTNULL(f
, "fdopen succeed after RLIMIT_NOFILE increased");