diff options
| author | Ondřej Surý <ondrej@sury.org> | 2010-01-07 13:31:53 +0100 |
|---|---|---|
| committer | Ondřej Surý <ondrej@sury.org> | 2010-01-07 13:31:53 +0100 |
| commit | 0fab6db7cac8d2be99579dd049f812a8ff98e74f (patch) | |
| tree | 91f01b0d06916c78262404096bfd466b8e95e5b5 /ext/standard/tests/general_functions/sleep_basic.phpt | |
| parent | d3a8757891280dc6650ca7eead67830c794b0e7b (diff) | |
| download | php-upstream/5.3.1.tar.gz | |
Imported Upstream version 5.3.1upstream/5.3.1
Diffstat (limited to 'ext/standard/tests/general_functions/sleep_basic.phpt')
| -rw-r--r-- | ext/standard/tests/general_functions/sleep_basic.phpt | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/ext/standard/tests/general_functions/sleep_basic.phpt b/ext/standard/tests/general_functions/sleep_basic.phpt new file mode 100644 index 000000000..cfc00c6ea --- /dev/null +++ b/ext/standard/tests/general_functions/sleep_basic.phpt @@ -0,0 +1,40 @@ +--TEST-- +Test sleep() function : basic functionality +--FILE-- +<?php +/* Prototype : int sleep ( int $seconds ) + * Description: Delays the program execution for the given number of seconds . + * Source code: ext/standard/basic_functions.c + */ + +echo "*** Testing sleep() : basic functionality ***\n"; + +$sleeptime = 5; // sleep for 5 seconds + +set_time_limit(20); + +$time_start = microtime(true); + +// Sleep for a while +sleep($sleeptime); + +// Test passes if sleeps for at least 98% of specified time +$sleeplow = $sleeptime - ($sleeptime * 2 /100); + +$time_end = microtime(true); +$time = $time_end - $time_start; + +echo "Thread slept for " . $time . " seconds\n"; + +if ($time >= $sleeplow) { + echo "TEST PASSED\n"; +} else { + echo "TEST FAILED - time is ${time} secs and sleep was ${sleeptime} secs\n"; +} +?> +===DONE=== +--EXPECTF-- +*** Testing sleep() : basic functionality *** +Thread slept for %f seconds +TEST PASSED +===DONE=== |
