]> granicus.if.org Git - php/commitdiff
test fixes + added skipif for slow tests
authorAnatol Belski <ab@php.net>
Mon, 16 Mar 2015 20:55:40 +0000 (13:55 -0700)
committerAnatol Belski <ab@php.net>
Mon, 16 Mar 2015 20:55:40 +0000 (13:55 -0700)
12 files changed:
tests/basic/timeout_config.inc
tests/basic/timeout_variation_0.phpt
tests/basic/timeout_variation_1.phpt
tests/basic/timeout_variation_10.phpt
tests/basic/timeout_variation_2.phpt
tests/basic/timeout_variation_3.phpt
tests/basic/timeout_variation_4.phpt
tests/basic/timeout_variation_5.phpt
tests/basic/timeout_variation_6.phpt
tests/basic/timeout_variation_7.phpt
tests/basic/timeout_variation_8.phpt
tests/basic/timeout_variation_9.phpt

index e9a6c60e089ef547d50acfff30026be848914956..18a00b2c485e3f8ed20df45c8ac8690963ae76d6 100644 (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());
 }
 
index 51670d5208121bb769fc04ea914a51568869dde3..6e7ef15ebc0d80a21092782e9be86d689f73964a 100644 (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
index 3f2d238d02f70d10d46ce301e722912d3db9f47b..4245d0b01bd83ca2fcf350c9ab16e00abfc00a30 100644 (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);
index edfb7127a628a60d6a19499f2adf3ace6545f80e..b3d533d4dd5f2305e78cfb24c26e90ae7e7374db 100644 (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");
index 74da955d7b88f79439153d672b2333e508a34527..e591fc5bb343bc36a8e03c24bac83df4b6ad42bd 100644 (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
index 0c4b9e8e71521fb2e4ee2171ffde59a0dc9ff433..7bff09680e48356d317c38653e01585116ec7beb 100644 (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);');
index 102b92afa684578e32121223e26bf3ae006715d4..6fccce87a41578ab22630759512b72ab84fb4c4e 100644 (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);
index 38dde0d759a599d2daa93bc732565d4b93549719..493c31c1515a62a6465537b9a3ebf3ba450d641c 100644 (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");
 }
 
index 355354fa1a690f7dc2287d68baced185228c46d6..70c83945ccde15b533cefc116a56ab9afa2a37e0 100644 (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");
 }
 
index 5ae8e07a0d1bb4b5446190eda832d475027de4a2..9dfed2083b04bc9939b975ff45c119cc12bfd438 100644 (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
index 25a208cca7d5469e10e762ebfc0e0c3ecebaea84..ab3724edb731b1813528323264dd937dc7e044e2 100644 (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
index 520b0ee35d74ea7797e6653fd5a8ddf142ef7a9d..003cd05bf8429d1696de697b73d53dd5c77f3ea5 100644 (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");