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:
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);');
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user