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

QA - pcntl_getpriority_error.phpt - fix test context information and case #8993

Conversation

juan-morales
Copy link
Contributor

@juan-morales juan-morales commented Jul 13, 2022

I changed an existing test as the information inside it is not accurate with what the test is testing.

Also added on more case for non-existing process id provided, in order to add more coverage also like image below shows

image

@juan-morales juan-morales changed the title QA - pcntl_getpriority_error.phpt - fix test context information QA - pcntl_getpriority_error.phpt - fix test context information and case Jul 13, 2022
@juan-morales
Copy link
Contributor Author

I am confuse at this.

Fails on MACOS like ...

image

But how is this possible? In the test code I am inside a try catch that is working everywhere except in Mac ... bug?

@cmb69
Copy link
Member

cmb69 commented Jul 13, 2022

@juan-morales, the macOS failure is for pcntl_getpriority(-123);, which is not inside a try-catch construct. And obviously, there is a bug in our pcntl_getpriority() implementation; at least the error message makes no sense. From the spec:

[EINVAL]
The value of the which argument was not recognized, or the value of the who argument is not a valid process ID, process group ID, or user ID.

And our pcntl_getpriority() implementation mixes up the parameter names …

@juan-morales
Copy link
Contributor Author

@cmb69 in order to fix this, a change is needed in the C code right? ... if it is lie this ... I will give a try trying to fix it ... but I am new on this field, lets see if I am lucky

@cmb69
Copy link
Member

cmb69 commented Jul 13, 2022

in order to fix this, a change is needed in the C code right?

Yes. The error message needs to be changed:

zend_argument_value_error(2, "must be one of PRIO_PGRP, PRIO_USER, or PRIO_PROCESS");

The only real issue is that we probably can no longer use zend_argument_value_error(), since the problem may be caused by the first parameter. And if it is caused by the first parameter, we shouldn't throw a ValueError at all (because the user is not supposed to know in advance which PIDs are good and which are not). So we probably want to demote to a warning, i.e. basically like the ESRCH case a few lines above.

@juan-morales
Copy link
Contributor Author

juan-morales commented Jul 13, 2022

in order to fix this, a change is needed in the C code right?

Yes. The error message needs to be changed:

zend_argument_value_error(2, "must be one of PRIO_PGRP, PRIO_USER, or PRIO_PROCESS");

The only real issue is that we probably can no longer use zend_argument_value_error(), since the problem may be caused by the first parameter. And if it is caused by the first parameter, we shouldn't throw a ValueError at all (because the user is not supposed to know in advance which PIDs are good and which are not). So we probably want to demote to a warning, i.e. basically like the ESRCH case a few lines above.

I am open to do my best and try to work on this, but I dont know exactly the procedure to follow, in terms of ... how to propose such a change (warning instead of error, etc.).

Any kind of advice is super welcome.

@cmb69
Copy link
Member

cmb69 commented Jul 13, 2022

You can "just" file a pull request. :)

@juan-morales
Copy link
Contributor Author

@cmb69 I have an idea regarding this (and also setpriority() ) after reading documentation. I think I CAN handle this.

I Will have a PR ready soon this days.

@juan-morales
Copy link
Contributor Author

will be fix in another PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants