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 10 if(in_array(PHP_OS_FAMILY, ['BSD', 'Darwin', 'Solaris', 'Linux'])){ 11 if (!file_exists("/etc/services")) die("skip reason: missing /etc/services"); 12 } 13?> 14--FILE-- 15<?php 16 if (file_exists("/etc/services")) { 17 $file = "/etc/services"; 18 } 19 elseif(substr(PHP_OS,0,3) == "WIN") $file = "C:/WINDOWS/system32/drivers/etc/services"; 20 else die(PHP_OS. " unsupported"); 21 22 if(file_exists($file)){ 23 $services = file_get_contents($file); 24 $service = getservbyport( 80, "tcp" ); 25 if(preg_match("/$service\s+80\/tcp/", $services)) { 26 echo "PASS\n"; 27 } 28 }else{ 29 echo "Services file not found in expected location\n"; 30 } 31?> 32--EXPECT-- 33PASS 34