support running testsuite with negative niceness (#11481)

* support running testsuite with negative niceness

a bug in the regex would break getNice() if the current niceness was negative, which would make the whole test fail.

Previously:
this would fail:
time sudo nice --adjustment=-19 ./php run-tests.php -j$(nproc) -x --offline ext/standard/tests/general_functions/proc_nice_basic.phpt --color --show-all

and this would work: 
time sudo ./php run-tests.php -j$(nproc) -x --offline ext/standard/tests/general_functions/proc_nice_basic.phpt --color --show-all

* Update ext/standard/tests/general_functions/proc_nice_basic.phpt

Co-authored-by: Michael Voříšek <mvorisek@mvorisek.cz>

---------

Co-authored-by: Michael Voříšek <mvorisek@mvorisek.cz>
This commit is contained in:
divinity76 2023-06-21 20:16:26 +02:00 committed by Ilija Tovilo
parent 181598d403
commit 4f044e9238
No known key found for this signature in database
GPG key ID: A4F5D403F118200A

View file

@ -19,7 +19,7 @@ if ($exit_code !== 0) {
function getNice($id)
{
$res = shell_exec('ps -p ' . $id .' -o "pid,nice"');
preg_match('/^\s*\w+\s+\w+\s*(\d+)\s+(\d+)/m', $res, $matches);
preg_match('/^\s*\w+\s+\w+\s*(\d+)\s+(-?\d+)/m', $res, $matches);
if (count($matches) > 2)
return $matches[2];
else