1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

test fixes + added skipif for slow tests

This commit is contained in:
Anatol Belski
2015-03-16 13:55:40 -07:00
parent 042dd8602e
commit fd51bd4a9e
12 changed files with 63 additions and 26 deletions

View File

@@ -2,10 +2,10 @@
$t = 3;
function busy_sleep($how_long)
function busy_wait($how_long)
{
$now = time();
$until = time() + $how_long;
while($now + $how_long > time());
while ($until > time());
}

View File

@@ -1,19 +1,22 @@
--TEST--
Timeout within while loop
--SKIPIF--
<?php
if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
?>
--FILE--
<?php
include dirname(__FILE__) . DIRECTORY_SEPARATOR . "timeout_config.inc";
$t = 3;
set_time_limit($t);
while(1) {
echo 1;
busy_sleep(1);
while (1) {
busy_wait(1);
}
?>
never reached here
--EXPECTF--
111
Fatal error: Maximum execution time of 3 seconds exceeded in %s on line %d

View File

@@ -1,5 +1,9 @@
--TEST--
Timeout within function
--SKIPIF--
<?php
if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
?>
--FILE--
<?php
@@ -10,7 +14,7 @@ set_time_limit($t);
function hello ($t) {
echo "call";
busy_sleep($t*2);
busy_wait($t*2);
}
hello($t);

View File

@@ -1,5 +1,9 @@
--TEST--
Timeout within shutdown function, variation
--SKIPIF--
<?php
if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
?>
--FILE--
<?php
@@ -11,7 +15,7 @@ set_time_limit($t);
function f()
{
echo "call";
busy_sleep(4);
busy_wait(4);
}
register_shutdown_function("f");

View File

@@ -1,5 +1,9 @@
--TEST--
Timeout within array_walk
--SKIPIF--
<?php
if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
?>
--FILE--
<?php
@@ -10,8 +14,7 @@ set_time_limit($t);
function cb(&$i, $k, $p)
{
echo 1;
busy_sleep(1);
busy_wait(1);
}
$a = array(1 => 1, 2 => 1, 3 => 1, 4 => 1, 5 => 1, 6 => 1, 7 => 1);
@@ -20,5 +23,4 @@ array_walk($a, "cb", "junk");
?>
never reached here
--EXPECTF--
111
Fatal error: Maximum execution time of 3 seconds exceeded in %s on line %d

View File

@@ -1,5 +1,9 @@
--TEST--
Timeout within eval
--SKIPIF--
<?php
if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
?>
--FILE--
<?php
@@ -10,7 +14,7 @@ set_time_limit($t);
function hello ($t) {
echo "call", PHP_EOL;
busy_sleep($t*2);
busy_wait($t*2);
}
eval('hello($t);');

View File

@@ -1,5 +1,9 @@
--TEST--
Timeout within call_user_func
--SKIPIF--
<?php
if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
?>
--FILE--
<?php
@@ -10,7 +14,7 @@ set_time_limit($t);
function hello ($t) {
echo "call", PHP_EOL;
busy_sleep($t*2);
busy_wait($t*2);
}
call_user_func('hello', $t);

View File

@@ -1,5 +1,9 @@
--TEST--
Timeout within function containing exteption
--SKIPIF--
<?php
if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
?>
--FILE--
<?php
@@ -10,7 +14,7 @@ set_time_limit($t);
function f($t) {
echo "call";
busy_sleep($t*2);
busy_wait($t*2);
throw new Exception("never reached here");
}

View File

@@ -1,5 +1,9 @@
--TEST--
Timeout within function trowing exteption before timeout reached
--SKIPIF--
<?php
if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
?>
--FILE--
<?php
@@ -10,7 +14,7 @@ set_time_limit($t);
function f($t) {
echo "call";
busy_sleep($t-1);
busy_wait($t-1);
throw new Exception("exception before timeout");
}

View File

@@ -1,5 +1,9 @@
--TEST--
Timeout within for loop
--SKIPIF--
<?php
if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
?>
--FILE--
<?php
@@ -8,13 +12,11 @@ include dirname(__FILE__) . DIRECTORY_SEPARATOR . "timeout_config.inc";
$t = 3;
set_time_limit($t);
for($i = 0; $i < 42; $i++) {
echo 1;
busy_sleep(1);
for ($i = 0; $i < 42; $i++) {
busy_wait(1);
}
?>
never reached here
--EXPECTF--
111
Fatal error: Maximum execution time of 3 seconds exceeded in %s on line %d

View File

@@ -1,20 +1,22 @@
--TEST--
Timeout within foreach loop
--SKIPIF--
<?php
if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
?>
--FILE--
<?php
$t = 3;
include dirname(__FILE__) . DIRECTORY_SEPARATOR . "timeout_config.inc";
$t = 3;
set_time_limit($t);
foreach(range(0, 42) as $i) {
echo 1;
busy_sleep(1);
foreach (range(0, 42) as $i) {
busy_wait(1);
}
?>
never reached here
--EXPECTF--
111
Fatal error: Maximum execution time of 3 seconds exceeded in %s on line %d

View File

@@ -1,5 +1,9 @@
--TEST--
Timeout within shutdown function
--SKIPIF--
<?php
if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
?>
--FILE--
<?php
@@ -11,7 +15,7 @@ set_time_limit($t);
function f()
{
echo "call";
busy_sleep(4);
busy_wait(4);
}
register_shutdown_function("f");