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

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

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