Fix GH-12077: Check lsof functionality in socket on close test

Closes GH-12084
This commit is contained in:
Jakub Zelenka 2023-08-30 13:18:28 +01:00
parent 02b3fb1f6b
commit fe30c5098f
No known key found for this signature in database
GPG key ID: 1C0779DC5C0A9DE4
3 changed files with 21 additions and 5 deletions

4
NEWS
View file

@ -5,6 +5,10 @@ PHP NEWS
- Core: - Core:
. Fixed GH-11847 (DTrace enabled build is broken). (Filip Zrůst) . Fixed GH-11847 (DTrace enabled build is broken). (Filip Zrůst)
- FPM:
. Fixed GH-12077 (PHP 8.3.0RC1 borked socket-close-on-exec.phpt).
(Jakub Zelenka)
31 Aug 2023, PHP 8.3.0RC1 31 Aug 2023, PHP 8.3.0RC1
- Core: - Core:

View file

@ -3,7 +3,7 @@ FPM: Set CLOEXEC on the listen and connection socket
--SKIPIF-- --SKIPIF--
<?php <?php
require_once "skipif.inc"; require_once "skipif.inc";
FPM\Tester::skipIfShellCommandFails('lsof -v 2> /dev/null'); FPM\Tester::skipIfShellCommandFails('lsof -v', 'lsof-org/lsof');
?> ?>
--FILE-- --FILE--
<?php <?php

View file

@ -342,12 +342,24 @@ class Tester
* Skip test if supplied shell command fails. * Skip test if supplied shell command fails.
* *
* @param string $command * @param string $command
* @param string|null $expectedPartOfOutput
*/ */
static public function skipIfShellCommandFails($command) static public function skipIfShellCommandFails(string $command, string $expectedPartOfOutput = null)
{ {
$output = system($command, $code); $result = exec("$command 2>&1", $output, $code);
if ($code) { if ($result === false || $code) {
die("skip command '$command' faield with code $code and output: $output"); die("skip command '$command' faieled with code $code");
}
if (!is_null($expectedPartOfOutput)) {
if (is_array($output)) {
foreach ($output as $line) {
if (str_contains($line, $expectedPartOfOutput)) {
// string found so no need to skip
return;
}
}
}
die("skip command '$command' did not contain output '$expectedPartOfOutput'");
} }
} }