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