Skip to content

Fix #80137: skip getprotobyname() and getprotobynumber() tests on *nix if there is no /etc/protocols file #6193

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ext/standard/tests/network/getprotobyname_basic.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
getprotobyname function basic test
--CREDITS--
edgarsandi - <[email protected]>
--SKIPIF--
<?php
if(in_array(PHP_OS_FAMILY, ['BSD', 'Darwin', 'Solaris', 'Linux'])){
Copy link
Contributor

Choose a reason for hiding this comment

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

couldn't you just do the feature detect without this OS whitelist?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added the OS whitelist to prevent the test from being skipped on Windows and others (PHP_OS_FAMILY=Unknown). As far as I know only *nix has the /etc/protocols file which is read by C getprotobyname / getprotobynumber.

if (!file_exists("/etc/protocols")) die("skip reason: missing /etc/protocols");
}
?>
--FILE--
<?php
var_dump(getprotobyname('tcp'));
Expand Down
6 changes: 6 additions & 0 deletions ext/standard/tests/network/getprotobynumber_basic.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
getprotobynumber function basic test
--CREDITS--
edgarsandi - <[email protected]>
--SKIPIF--
<?php
if(in_array(PHP_OS_FAMILY, ['BSD', 'Darwin', 'Solaris', 'Linux'])){
if (!file_exists("/etc/protocols")) die("skip reason: missing /etc/protocols");
}
?>
--FILE--
<?php
var_dump(getprotobynumber(6));
Expand Down