-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix get/set priority - error handling for MacOS and extra tests
Closes GH-9044.
- Loading branch information
Showing
7 changed files
with
179 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--TEST-- | ||
pcntl_getpriority() - Wrong mode passed and also for non existing process id provided | ||
--EXTENSIONS-- | ||
pcntl | ||
--SKIPIF-- | ||
<?php | ||
|
||
if (!function_exists('pcntl_getpriority')) { | ||
die('skip pcntl_getpriority doesn\'t exist'); | ||
} | ||
|
||
if (PHP_OS !== "Darwin") { | ||
die("skip This test only runs on Darwin"); | ||
} | ||
|
||
?> | ||
--FILE-- | ||
<?php | ||
|
||
try { | ||
pcntl_getpriority(null, (PRIO_PGRP + PRIO_USER + PRIO_PROCESS + 10)); | ||
} catch (ValueError $exception) { | ||
echo $exception->getMessage() . "\n"; | ||
} | ||
|
||
try { | ||
pcntl_getpriority(-1, PRIO_DARWIN_THREAD); | ||
} catch (ValueError $exception) { | ||
echo $exception->getMessage() . "\n"; | ||
} | ||
|
||
try { | ||
// Different behavior in MacOS than rest of operating systems | ||
pcntl_getpriority(-1, PRIO_PROCESS); | ||
} catch (ValueError $exception) { | ||
echo $exception->getMessage() . "\n"; | ||
} | ||
|
||
?> | ||
--EXPECT-- | ||
pcntl_getpriority(): Argument #2 ($mode) must be one of PRIO_PGRP, PRIO_USER, PRIO_PROCESS or PRIO_DARWIN_THREAD | ||
pcntl_getpriority(): Argument #1 ($process_id) must be 0 (zero) if PRIO_DARWIN_THREAD is provided as second parameter | ||
pcntl_getpriority(): Argument #1 ($process_id) is not a valid process, process group, or user ID |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
--TEST-- | ||
pcntl_setpriority() - Check for errors | ||
--EXTENSIONS-- | ||
pcntl | ||
--SKIPIF-- | ||
<?php | ||
|
||
if (!function_exists('pcntl_setpriority')) { | ||
die('skip pcntl_setpriority doesn\'t exist'); | ||
} | ||
|
||
if (PHP_OS !== "Darwin") { | ||
die("skip This test only runs on Darwin"); | ||
} | ||
|
||
?> | ||
--FILE-- | ||
<?php | ||
|
||
try { | ||
pcntl_setpriority(0, null, (PRIO_PGRP + PRIO_USER + PRIO_PROCESS + 10)); | ||
} catch (ValueError $exception) { | ||
echo $exception->getMessage() . "\n"; | ||
} | ||
|
||
try { | ||
pcntl_setpriority(0, -1, PRIO_DARWIN_THREAD); | ||
} catch (ValueError $exception) { | ||
echo $exception->getMessage() . "\n"; | ||
} | ||
|
||
try { | ||
pcntl_setpriority(0, -123); | ||
} catch (ValueError $exception) { | ||
echo $exception->getMessage() . "\n"; | ||
} | ||
|
||
pcntl_setpriority(-1000, 1); | ||
|
||
?> | ||
--EXPECTF-- | ||
pcntl_setpriority(): Argument #3 ($mode) must be one of PRIO_PGRP, PRIO_USER, PRIO_PROCESS or PRIO_DARWIN_THREAD | ||
pcntl_setpriority(): Argument #2 ($process_id) must be 0 (zero) if PRIO_DARWIN_THREAD is provided as second parameter | ||
pcntl_setpriority(): Argument #2 ($process_id) is not a valid process, process group, or user ID | ||
|
||
Warning: pcntl_setpriority(): Error 1: A process was located, but neither its effective nor real user ID matched the effective user ID of the caller in %s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--TEST-- | ||
pcntl_setpriority() - Check for errors | ||
--EXTENSIONS-- | ||
pcntl | ||
--SKIPIF-- | ||
<?php | ||
|
||
if (!function_exists('pcntl_setpriority')) { | ||
die('skip pcntl_setpriority doesn\'t exist'); | ||
} | ||
|
||
if (PHP_OS !== "Linux") { | ||
die("skip This test only runs on Linux"); | ||
} | ||
|
||
?> | ||
--FILE-- | ||
<?php | ||
|
||
pcntl_setpriority(-1000, 1); | ||
pcntl_setpriority(-1000, 0); | ||
|
||
?> | ||
--EXPECTF-- | ||
Warning: pcntl_setpriority(): Error 1: A process was located, but neither its effective nor real user ID matched the effective user ID of the caller in %s | ||
|
||
Warning: pcntl_setpriority(): Error 13: Only a super user may attempt to increase the process priority in %s on line %d |
520bb2e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this change, we cannot build php8.2-beta2. See fossar/nix-phps#134
It seems that the issue comes from the new test introduced in
pcntl_setpriority_error_linux.phpt
.520bb2e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please provide the diff of the test (passing
--show-diff
to the test runner might be sufficient to get it).520bb2e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make test --show-diff
?520bb2e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not quite. If you're now doing
make test
, then you'd need to domake test TESTS=--show-diff
.520bb2e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you go, the full build log of the pcntl extension.
test.log
The diff is:
520bb2e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! So the diff is basically:
Looks like we need to fix the test case (the same issue is likely to happen, if we stop running CI as root).
@juan-morales, any ideas how to solve this?
520bb2e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am looking on this @cmb69 @drupol
520bb2e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@drupol can you tell me under which user is your CI running?
I tried all kind of ideas trying to replicate your output but I could not.
Locally for me works as expected, using latest version of php's repo and also using tag php-8.2.0beta2 (used by you as far as I saw), and works as expected.
According to your output ...
Did you try running the CI as non-root user? if user is not root, how about the privileges used? sudo? I will be waiting for your response.
regards!
520bb2e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi,
Thanks for investigating!
After further investigations on our side, we noticed that the variable '$USER` was empty while running the tests. Then @jtojnar had the idea to turn the sandboxing mechanism off in the Nix build system, and it worked.
I guess the issue is on our side now, unless you need more details.
520bb2e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very happy to know that there is a solution for this.
Have a good day.
520bb2e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question:
Do you think it would be possible to skip tests in environments that doesn't meet the requirements?
520bb2e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my side... No problem at all, I can write the code, then is up to the main contributors to approve it or not.
I will write it tomorrow because now I Am travelling
520bb2e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent news. Looking forward to testing the patch and the next
beta3
:)