1--TEST-- 2Test usleep() function 3--SKIPIF-- 4<?php 5if (getenv("SKIP_SLOW_TESTS")) die("skip slow test"); 6?> 7--FILE-- 8<?php 9set_time_limit(20); 10 11echo "*** Testing usleep() : basic functionality ***\n"; 12 13$sleeptime = 1000000; // == 1 seconds 14// Test passes if sleeps for at least 98% of specified time 15$sleeplow = $sleeptime - ($sleeptime * 2 /100); 16 17$time_start = microtime(true); 18 19// Sleep for a while 20usleep($sleeptime); 21 22$time_end = microtime(true); 23$time = ($time_end - $time_start) * 1000 * 1000; 24 25$summary = "Thread slept for " . $time . " micro-seconds\n"; 26 27if ($time >= $sleeplow) { 28 echo "TEST PASSED: $summary"; 29} else { 30 echo "TEST FAILED: $summary"; 31} 32?> 33--EXPECTF-- 34*** Testing usleep() : basic functionality *** 35TEST PASSED: Thread slept for %f micro-seconds 36