+++ /dev/null
-<?php
-
-$t = 3;
-
-function busy_wait($how_long) {
- $until = microtime(true) + $how_long;
- do {
- for ($i = 0; $i < 1000000; $i++);
- } while ($until > microtime(true));
-}
Timeout within while loop
--SKIPIF--
<?php
- if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
+if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
?>
--FILE--
<?php
-include __DIR__ . DIRECTORY_SEPARATOR . "timeout_config.inc";
+set_time_limit(1);
-set_time_limit($t);
-
-while (1) {
- busy_wait(1);
+$x = true;
+$y = 0;
+while ($x) {
+ $y++;
}
?>
never reached here
--EXPECTF--
-Fatal error: Maximum execution time of 3 seconds exceeded in %s on line %d
+Fatal error: Maximum execution time of 1 second exceeded in %s on line %d
Timeout within function
--SKIPIF--
<?php
- if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
+if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
+if (PHP_OS_FAMILY !== "Windows") die("skip Windows only test");
?>
--FILE--
<?php
-include __DIR__ . DIRECTORY_SEPARATOR . "timeout_config.inc";
-
-set_time_limit($t);
-
-function hello ($t) {
- echo "call";
- busy_wait($t*2);
-}
-
-hello($t);
+set_time_limit(1);
+sleep(1);
+sleep(1);
?>
never reached here
--EXPECTF--
-call
-Fatal error: Maximum execution time of 3 seconds exceeded in %s on line %d
+Fatal error: Maximum execution time of 1 second exceeded in %s on line %d
Timeout within shutdown function, variation
--SKIPIF--
<?php
- if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
+if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
+if (PHP_OS_FAMILY !== "Windows") die("skip Windows only test");
?>
+--XFAIL--
+Missing timeout check in call_user_function
--FILE--
<?php
-include __DIR__ . DIRECTORY_SEPARATOR . "timeout_config.inc";
+set_time_limit(1);
-set_time_limit($t);
+register_shutdown_function("sleep", 1);
+register_shutdown_function("sleep", 1);
-function f()
-{
- echo "call";
- $startTime = microtime(true);
- busy_wait(5);
- $diff = microtime(true) - $startTime;
- echo "\ntime spent waiting: $diff\n";
-}
-
-register_shutdown_function("f");
?>
shutdown happens after here
--EXPECTF--
shutdown happens after here
-call
-Fatal error: Maximum execution time of 3 seconds exceeded in %s on line %d
+Fatal error: Maximum execution time of 1 second exceeded in %s on line %d
--TEST--
-Timeout within array_walk
+Timeout within array_map
--SKIPIF--
<?php
- if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
+if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
+if (PHP_OS_FAMILY !== "Windows") die("skip Windows only test");
?>
--FILE--
<?php
-include __DIR__ . DIRECTORY_SEPARATOR . "timeout_config.inc";
+set_time_limit(1);
-set_time_limit($t);
+$a = array(1, 1);
+array_map("sleep", $a);
-function cb(&$i, $k, $p)
-{
- busy_wait(1);
-}
-
-$startTime = microtime(true);
-
-$a = array(1 => 1, 2 => 1, 3 => 1, 4 => 1, 5 => 1, 6 => 1, 7 => 1);
-array_walk($a, "cb", "junk");
-
-$diff = microtime(true) - $startTime;
-echo "time spent waiting: $diff\n";
?>
never reached here
--EXPECTF--
-Fatal error: Maximum execution time of 3 seconds exceeded in %s on line %d
+Fatal error: Maximum execution time of 1 second exceeded in %s on line %d
+++ /dev/null
---TEST--
-Timeout within eval
---SKIPIF--
-<?php
- if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
-?>
---FILE--
-<?php
-
-include __DIR__ . DIRECTORY_SEPARATOR . "timeout_config.inc";
-
-set_time_limit($t);
-
-function hello ($t) {
- echo "call", PHP_EOL;
- $startTime = microtime(true);
- busy_wait($t*2);
- $diff = microtime(true) - $startTime;
- echo "time spent waiting: $diff\n";
-}
-
-eval('hello($t);');
-?>
-never reached here
---EXPECTF--
-call
-
-Fatal error: Maximum execution time of 3 seconds exceeded in %s on line %d
Timeout within call_user_func
--SKIPIF--
<?php
- if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
+if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
+if (PHP_OS_FAMILY !== "Windows") die("skip Windows only test");
?>
--FILE--
<?php
-include __DIR__ . DIRECTORY_SEPARATOR . "timeout_config.inc";
+set_time_limit(1);
-set_time_limit($t);
-
-function hello ($t) {
- echo "call", PHP_EOL;
- $startTime = microtime(true);
- busy_wait($t*2);
- $diff = microtime(true) - $startTime;
- echo "time spent waiting: $diff\n";
-}
-
-call_user_func('hello', $t);
+call_user_func('sleep', 1);
+call_user_func('sleep', 1);
?>
never reached here
--EXPECTF--
-call
-
-Fatal error: Maximum execution time of 3 seconds exceeded in %s on line %d
+Fatal error: Maximum execution time of 1 second exceeded in %s on line %d
+++ /dev/null
---TEST--
-Timeout within function containing exception
---SKIPIF--
-<?php
- if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
-?>
---FILE--
-<?php
-
-include __DIR__ . DIRECTORY_SEPARATOR . "timeout_config.inc";
-
-set_time_limit($t);
-
-function f($t) {
- echo "call";
- $startTime = microtime(true);
- busy_wait($t*2);
- $diff = microtime(true) - $startTime;
- throw new Exception("never reached here (time spent waiting: $diff)");
-}
-
-f($t);
-?>
-never reached here
---EXPECTF--
-call
-Fatal error: Maximum execution time of 3 seconds exceeded in %s on line %d
+++ /dev/null
---TEST--
-Timeout within function trowing exception before timeout reached
---SKIPIF--
-<?php
- if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
-?>
---FILE--
-<?php
-
-include __DIR__ . DIRECTORY_SEPARATOR . "timeout_config.inc";
-
-set_time_limit($t);
-
-function f($t) {
- echo "call";
- busy_wait($t-1);
- throw new Exception("exception before timeout");
-}
-
-f($t);
-?>
-never reached here
---EXPECTF--
-call
-Fatal error: Uncaught Exception: exception before timeout in %s:%d
-Stack trace:
-#0 %s(%d): f(%d)
-#1 {main}
- thrown in %s on line %d
Timeout within for loop
--SKIPIF--
<?php
- if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
+if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
?>
--FILE--
<?php
-include __DIR__ . DIRECTORY_SEPARATOR . "timeout_config.inc";
+set_time_limit(1);
-set_time_limit($t);
-
-$startTime = microtime(true);
-
-for ($i = 0; $i < 42; $i++) {
- busy_wait(1);
+$y = 0;
+for ($i = 0; $i < INF; $i++) {
+ $y++;
}
-$diff = microtime(true) - $startTime;
-echo "time spent waiting: $diff\n";
-
?>
never reached here
--EXPECTF--
-Fatal error: Maximum execution time of 3 seconds exceeded in %s on line %d
+Fatal error: Maximum execution time of 1 second exceeded in %s on line %d
Timeout within foreach loop
--SKIPIF--
<?php
- if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
+if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
?>
--FILE--
<?php
-include __DIR__ . DIRECTORY_SEPARATOR . "timeout_config.inc";
+set_time_limit(1);
-set_time_limit($t);
-
-$startTime = microtime(true);
-
-foreach (range(0, 42) as $i) {
- busy_wait(1);
+foreach (new InfiniteIterator(new ArrayIterator([1])) as $i) {
}
-$diff = microtime(true) - $startTime;
-echo "time spent waiting: $diff\n";
-
?>
never reached here
--EXPECTF--
-Fatal error: Maximum execution time of 3 seconds exceeded in %s on line %d
+Fatal error: Maximum execution time of 1 second exceeded in %s on line %d
Timeout within shutdown function
--SKIPIF--
<?php
- if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
+if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
+if (PHP_OS_FAMILY !== "Windows") die("skip Windows only test");
?>
+--XFAIL--
+Missing timeout check in call_user_function
--FILE--
<?php
-include __DIR__ . DIRECTORY_SEPARATOR . "timeout_config.inc";
+set_time_limit(1);
+register_shutdown_function("sleep", 1);
+register_shutdown_function("sleep", 1);
-set_time_limit($t);
-
-function f()
-{
- echo "call";
- $startTime = microtime(true);
- busy_wait(5);
- $diff = microtime(true) - $startTime;
- echo "\ntime spent waiting: $diff\n";
-}
-
-register_shutdown_function("f");
exit(0);
?>
never reached here
--EXPECTF--
-call
-Fatal error: Maximum execution time of 3 seconds exceeded in %s on line %d
+Fatal error: Maximum execution time of 1 second exceeded in %s on line %d