Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix detecting closed socket pipes on PHP 8 #90

Merged
merged 2 commits into from
Oct 11, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Improve test suite to skip FD test when hitting memory limit
  • Loading branch information
clue committed Oct 7, 2021
commit 8c9117f60174dd8fde7c45f16eeef03db12682e6
21 changes: 20 additions & 1 deletion tests/AbstractProcessTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,28 @@ public function testStartWithExcessiveNumberOfFileDescriptorsWillThrow()
$this->markTestSkipped('Unable to determine limit of open files (ulimit not available?)');
}

// create 70% (usually ~700) dummy file handles in this parent
$limit = (int) ($ulimit * 0.7);

$memory = ini_get('memory_limit');
if ($memory === '-1') {
$memory = PHP_INT_MAX;
} elseif (preg_match('/^\d+G$/i', $memory)) {
$memory = ((int) $memory) * 1024 * 1024 * 1024;
} elseif (preg_match('/^\d+M$/i', $memory)) {
$memory = ((int) $memory) * 1024 * 1024;
} elseif (preg_match('/^\d+K$/i', $memory)) {
$memory = ((int) $memory) * 1024;
}

// each file descriptor takes ~600 bytes of memory, so skip test if this would exceed memory_limit
if ($limit * 600 > $memory) {
$this->markTestSkipped('Test requires ~' . round($limit * 600 / 1024 / 1024) . '/' . round($memory / 1024 / 1024) . ' MiB memory with ' . $ulimit . ' file descriptors');
}

$loop = $this->createLoop();

// create 70% (usually ~700) dummy file handles in this parent dummy
// create ~700 dummy file handles in this parent
$limit = (int) ($ulimit * 0.7);
$fds = array();
for ($i = 0; $i < $limit; ++$i) {
Expand Down