summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2015-03-16 13:21:33 -0700
committerAnatol Belski <ab@php.net>2015-03-16 13:21:33 -0700
commit042dd8602e114253bddbd10a6df6c7bf24b3d7e5 (patch)
tree0c604a3195462330b1351ffc4ff2075870bcc223
parent59a2a900a527f15b5a481bdb59b7af2db9d110b3 (diff)
downloadphp-git-042dd8602e114253bddbd10a6df6c7bf24b3d7e5.tar.gz
use busy sleep instead of sleep() for timeout tests
-rw-r--r--tests/basic/timeout_config.inc11
-rw-r--r--tests/basic/timeout_variation_0.phpt5
-rw-r--r--tests/basic/timeout_variation_1.phpt4
-rw-r--r--tests/basic/timeout_variation_10.phpt4
-rw-r--r--tests/basic/timeout_variation_2.phpt4
-rw-r--r--tests/basic/timeout_variation_3.phpt4
-rw-r--r--tests/basic/timeout_variation_4.phpt4
-rw-r--r--tests/basic/timeout_variation_5.phpt4
-rw-r--r--tests/basic/timeout_variation_6.phpt4
-rw-r--r--tests/basic/timeout_variation_7.phpt4
-rw-r--r--tests/basic/timeout_variation_8.phpt4
-rw-r--r--tests/basic/timeout_variation_9.phpt4
12 files changed, 44 insertions, 12 deletions
diff --git a/tests/basic/timeout_config.inc b/tests/basic/timeout_config.inc
new file mode 100644
index 0000000000..e9a6c60e08
--- /dev/null
+++ b/tests/basic/timeout_config.inc
@@ -0,0 +1,11 @@
+<?php
+
+$t = 3;
+
+function busy_sleep($how_long)
+{
+ $now = time();
+
+ while($now + $how_long > time());
+}
+
diff --git a/tests/basic/timeout_variation_0.phpt b/tests/basic/timeout_variation_0.phpt
index 31c878dbe6..51670d5208 100644
--- a/tests/basic/timeout_variation_0.phpt
+++ b/tests/basic/timeout_variation_0.phpt
@@ -3,12 +3,13 @@ Timeout within while loop
--FILE--
<?php
-$t = 3;
+include dirname(__FILE__) . DIRECTORY_SEPARATOR . "timeout_config.inc";
+
set_time_limit($t);
while(1) {
echo 1;
- sleep(1);
+ busy_sleep(1);
}
?>
diff --git a/tests/basic/timeout_variation_1.phpt b/tests/basic/timeout_variation_1.phpt
index 63c641d757..3f2d238d02 100644
--- a/tests/basic/timeout_variation_1.phpt
+++ b/tests/basic/timeout_variation_1.phpt
@@ -3,12 +3,14 @@ Timeout within function
--FILE--
<?php
+include dirname(__FILE__) . DIRECTORY_SEPARATOR . "timeout_config.inc";
+
$t = 3;
set_time_limit($t);
function hello ($t) {
echo "call";
- sleep($t*2);
+ busy_sleep($t*2);
}
hello($t);
diff --git a/tests/basic/timeout_variation_10.phpt b/tests/basic/timeout_variation_10.phpt
index e945bbb0ef..edfb7127a6 100644
--- a/tests/basic/timeout_variation_10.phpt
+++ b/tests/basic/timeout_variation_10.phpt
@@ -3,13 +3,15 @@ Timeout within shutdown function, variation
--FILE--
<?php
+include dirname(__FILE__) . DIRECTORY_SEPARATOR . "timeout_config.inc";
+
$t = 3;
set_time_limit($t);
function f()
{
echo "call";
- sleep(4);
+ busy_sleep(4);
}
register_shutdown_function("f");
diff --git a/tests/basic/timeout_variation_2.phpt b/tests/basic/timeout_variation_2.phpt
index b374e9c684..74da955d7b 100644
--- a/tests/basic/timeout_variation_2.phpt
+++ b/tests/basic/timeout_variation_2.phpt
@@ -3,13 +3,15 @@ Timeout within array_walk
--FILE--
<?php
+include dirname(__FILE__) . DIRECTORY_SEPARATOR . "timeout_config.inc";
+
$t = 3;
set_time_limit($t);
function cb(&$i, $k, $p)
{
echo 1;
- sleep(1);
+ busy_sleep(1);
}
$a = array(1 => 1, 2 => 1, 3 => 1, 4 => 1, 5 => 1, 6 => 1, 7 => 1);
diff --git a/tests/basic/timeout_variation_3.phpt b/tests/basic/timeout_variation_3.phpt
index 0de46963d8..0c4b9e8e71 100644
--- a/tests/basic/timeout_variation_3.phpt
+++ b/tests/basic/timeout_variation_3.phpt
@@ -3,12 +3,14 @@ Timeout within eval
--FILE--
<?php
+include dirname(__FILE__) . DIRECTORY_SEPARATOR . "timeout_config.inc";
+
$t = 3;
set_time_limit($t);
function hello ($t) {
echo "call", PHP_EOL;
- sleep($t*2);
+ busy_sleep($t*2);
}
eval('hello($t);');
diff --git a/tests/basic/timeout_variation_4.phpt b/tests/basic/timeout_variation_4.phpt
index 053a33af4d..102b92afa6 100644
--- a/tests/basic/timeout_variation_4.phpt
+++ b/tests/basic/timeout_variation_4.phpt
@@ -3,12 +3,14 @@ Timeout within call_user_func
--FILE--
<?php
+include dirname(__FILE__) . DIRECTORY_SEPARATOR . "timeout_config.inc";
+
$t = 3;
set_time_limit($t);
function hello ($t) {
echo "call", PHP_EOL;
- sleep($t*2);
+ busy_sleep($t*2);
}
call_user_func('hello', $t);
diff --git a/tests/basic/timeout_variation_5.phpt b/tests/basic/timeout_variation_5.phpt
index e4ccfffa58..38dde0d759 100644
--- a/tests/basic/timeout_variation_5.phpt
+++ b/tests/basic/timeout_variation_5.phpt
@@ -3,12 +3,14 @@ Timeout within function containing exteption
--FILE--
<?php
+include dirname(__FILE__) . DIRECTORY_SEPARATOR . "timeout_config.inc";
+
$t = 3;
set_time_limit($t);
function f($t) {
echo "call";
- sleep($t*2);
+ busy_sleep($t*2);
throw new Exception("never reached here");
}
diff --git a/tests/basic/timeout_variation_6.phpt b/tests/basic/timeout_variation_6.phpt
index 387a358fc8..355354fa1a 100644
--- a/tests/basic/timeout_variation_6.phpt
+++ b/tests/basic/timeout_variation_6.phpt
@@ -3,12 +3,14 @@ Timeout within function trowing exteption before timeout reached
--FILE--
<?php
+include dirname(__FILE__) . DIRECTORY_SEPARATOR . "timeout_config.inc";
+
$t = 3;
set_time_limit($t);
function f($t) {
echo "call";
- sleep($t-1);
+ busy_sleep($t-1);
throw new Exception("exception before timeout");
}
diff --git a/tests/basic/timeout_variation_7.phpt b/tests/basic/timeout_variation_7.phpt
index 35852e7495..5ae8e07a0d 100644
--- a/tests/basic/timeout_variation_7.phpt
+++ b/tests/basic/timeout_variation_7.phpt
@@ -3,12 +3,14 @@ Timeout within for loop
--FILE--
<?php
+include dirname(__FILE__) . DIRECTORY_SEPARATOR . "timeout_config.inc";
+
$t = 3;
set_time_limit($t);
for($i = 0; $i < 42; $i++) {
echo 1;
- sleep(1);
+ busy_sleep(1);
}
?>
diff --git a/tests/basic/timeout_variation_8.phpt b/tests/basic/timeout_variation_8.phpt
index dfb2d2e69e..25a208cca7 100644
--- a/tests/basic/timeout_variation_8.phpt
+++ b/tests/basic/timeout_variation_8.phpt
@@ -3,12 +3,14 @@ Timeout within foreach loop
--FILE--
<?php
+include dirname(__FILE__) . DIRECTORY_SEPARATOR . "timeout_config.inc";
+
$t = 3;
set_time_limit($t);
foreach(range(0, 42) as $i) {
echo 1;
- sleep(1);
+ busy_sleep(1);
}
?>
diff --git a/tests/basic/timeout_variation_9.phpt b/tests/basic/timeout_variation_9.phpt
index f51c439eea..520b0ee35d 100644
--- a/tests/basic/timeout_variation_9.phpt
+++ b/tests/basic/timeout_variation_9.phpt
@@ -3,13 +3,15 @@ Timeout within shutdown function
--FILE--
<?php
+include dirname(__FILE__) . DIRECTORY_SEPARATOR . "timeout_config.inc";
+
$t = 3;
set_time_limit($t);
function f()
{
echo "call";
- sleep(4);
+ busy_sleep(4);
}
register_shutdown_function("f");