Improve the error message in timeout tests

Closes GH-4818.
This commit is contained in:
Fabien Villepinte 2019-10-20 10:55:27 +02:00
parent 4b3e041f5b
commit 62b053a3be
8 changed files with 29 additions and 1 deletions

View File

@ -14,7 +14,10 @@ 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");

View File

@ -16,9 +16,13 @@ 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--

View File

@ -13,7 +13,10 @@ 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);');

View File

@ -13,7 +13,10 @@ 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);

View File

@ -13,8 +13,10 @@ set_time_limit($t);
function f($t) {
echo "call";
$startTime = microtime(true);
busy_wait($t*2);
throw new Exception("never reached here");
$diff = microtime(true) - $startTime;
throw new Exception("never reached here (time spent waiting: $diff)");
}
f($t);

View File

@ -11,10 +11,15 @@ include __DIR__ . DIRECTORY_SEPARATOR . "timeout_config.inc";
set_time_limit($t);
$startTime = microtime(true);
for ($i = 0; $i < 42; $i++) {
busy_wait(1);
}
$diff = microtime(true) - $startTime;
echo "time spent waiting: $diff\n";
?>
never reached here
--EXPECTF--

View File

@ -11,10 +11,15 @@ include __DIR__ . DIRECTORY_SEPARATOR . "timeout_config.inc";
set_time_limit($t);
$startTime = microtime(true);
foreach (range(0, 42) as $i) {
busy_wait(1);
}
$diff = microtime(true) - $startTime;
echo "time spent waiting: $diff\n";
?>
never reached here
--EXPECTF--

View File

@ -14,7 +14,10 @@ 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");