1--TEST--
2Test function getservbyport() by calling it more than or less than its expected arguments
3--CREDITS--
4Italian PHP TestFest 2009 Cesena 19-20-21 june
5Fabio Fabbrucci (fabbrucci@grupporetina.com)
6Michele Orselli (mo@ideato.it)
7Simone Gentili (sensorario@gmail.com)
8--SKIPIF--
9<?php
10if(in_array(PHP_OS_FAMILY, ['BSD', 'Darwin', 'Solaris', 'Linux'])){
11    if (!file_exists("/etc/services")) die("skip reason: missing /etc/services");
12}
13if (getenv('SKIP_MSAN')) die('skip msan missing interceptor for getservbyport()');
14?>
15--FILE--
16<?php
17    if (file_exists("/etc/services")) {
18        $file = "/etc/services";
19    }
20    elseif(substr(PHP_OS,0,3) == "WIN") $file = "C:/WINDOWS/system32/drivers/etc/services";
21    else die(PHP_OS. " unsupported");
22
23    if(file_exists($file)){
24        $services = file_get_contents($file);
25                $service = getservbyport( 80, "tcp" );
26                if(preg_match("/$service\s+80\/tcp/", $services)) {
27            echo "PASS\n";
28        }
29    }else{
30        echo "Services file not found in expected location\n";
31    }
32?>
33--EXPECT--
34PASS
35