Annotation of embedaddon/php/ext/standard/tests/general_functions/sleep_basic.phpt, revision 1.1.1.1

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>