Skip to content

ext/sockets/tests/mcast_ipv6_*.phpt: suppress no-ipv6 warning #11651

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

Merged
merged 1 commit into from
Jul 10, 2023

Conversation

orlitzky
Copy link
Contributor

@orlitzky orlitzky commented Jul 9, 2023

These three tests try to create an ipv6 socket with socket_create() to determine if they should be skipped. On certain systems lacking ipv6 support, however, the call to socket_create() itself raises a warning:

BORK Warning: socket_create(): Unable to create socket [97]: Address
family not supported by protocol in ...

The output is "borked" because the return value (false) is expected but the text of the warning is not. This commit uses the error control operator (@) to hide the warning. Afterwards the tests are skipped normally on such a system.

Copy link
Member

@iluuu1994 iluuu1994 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

$s = socket_create(AF_INET6, SOCK_DGRAM, SOL_UDP);
// hide the output from socket_create() because it can raise
// a warning if (for example) the linux kernel is lacking ipv6
@$s = socket_create(AF_INET6, SOCK_DGRAM, SOL_UDP);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@$s = socket_create(AF_INET6, SOCK_DGRAM, SOL_UDP);
$s = @socket_create(AF_INET6, SOCK_DGRAM, SOL_UDP);

Nit, same in the other files.

// a warning if (for example) the linux kernel is lacking ipv6
@$s = socket_create(AF_INET6, SOCK_DGRAM, SOL_UDP);
if ($s === false) {
die("skip unable to create socket");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
die("skip unable to create socket");
die("skip unable to create socket");

Nit. Yes, I see the existing code above uses 2 but we still use 4 everywhere else 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem, fixed, thanks!

@orlitzky orlitzky force-pushed the hide-ipv6-socket-create-warning branch from 945b34b to f70cb96 Compare July 10, 2023 14:05
These three tests try to create an ipv6 socket with socket_create() to
determine if they should be skipped. On certain systems lacking ipv6
support, however, the call to socket_create() itself raises a warning:

  BORK Warning: socket_create(): Unable to create socket [97]: Address
  family not supported by protocol in ...

The output is "borked" because the return value (false) is expected
but the text of the warning is not. This commit uses the error control
operator (@) to hide the warning. Afterwards the tests are skipped
normally on such a system.
@orlitzky orlitzky force-pushed the hide-ipv6-socket-create-warning branch from f70cb96 to 8841bb0 Compare July 10, 2023 14:06
@iluuu1994 iluuu1994 merged commit ce8c07e into php:master Jul 10, 2023
@iluuu1994
Copy link
Member

Thank you @orlitzky!

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