File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed
Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -156,9 +156,28 @@ public function testStartWithExcessiveNumberOfFileDescriptorsWillThrow()
156156 $ this ->markTestSkipped ('Unable to determine limit of open files (ulimit not available?) ' );
157157 }
158158
159+ // create 70% (usually ~700) dummy file handles in this parent
160+ $ limit = (int ) ($ ulimit * 0.7 );
161+
162+ $ memory = ini_get ('memory_limit ' );
163+ if ($ memory === '-1 ' ) {
164+ $ memory = PHP_INT_MAX ;
165+ } elseif (preg_match ('/^\d+G$/i ' , $ memory )) {
166+ $ memory = ((int ) $ memory ) * 1024 * 1024 * 1024 ;
167+ } elseif (preg_match ('/^\d+M$/i ' , $ memory )) {
168+ $ memory = ((int ) $ memory ) * 1024 * 1024 ;
169+ } elseif (preg_match ('/^\d+K$/i ' , $ memory )) {
170+ $ memory = ((int ) $ memory ) * 1024 ;
171+ }
172+
173+ // each file descriptor takes ~600 bytes of memory, so skip test if this would exceed memory_limit
174+ if ($ limit * 600 > $ memory ) {
175+ $ this ->markTestSkipped ('Test requires ~ ' . round ($ limit * 600 / 1024 / 1024 ) . '/ ' . round ($ memory / 1024 / 1024 ) . ' MiB memory with ' . $ ulimit . ' file descriptors ' );
176+ }
177+
159178 $ loop = $ this ->createLoop ();
160179
161- // create 70% (usually ~700) dummy file handles in this parent dummy
180+ // create ~700 dummy file handles in this parent
162181 $ limit = (int ) ($ ulimit * 0.7 );
163182 $ fds = array ();
164183 for ($ i = 0 ; $ i < $ limit ; ++$ i ) {
You can’t perform that action at this time.
0 commit comments