summaryrefslogtreecommitdiff
path: root/tests/basic/timeout_variation_8.phpt
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-12-05 09:13:57 +0100
committerNikita Popov <nikita.ppv@gmail.com>2019-12-05 11:19:23 +0100
commite760d94f4bb4d0802e89af0927cecfb479cba024 (patch)
tree82b272b399fbbb183a3246e1a97636370e58374a /tests/basic/timeout_variation_8.phpt
parent6b7cb4a8d70cd3a4f153e5097f9c9caea3ed0b4d (diff)
downloadphp-git-e760d94f4bb4d0802e89af0927cecfb479cba024.tar.gz
Fix timeout tests
After taking a more detailed look at our commonly failing timeout tests... turns out that most of them are useless as written and don't test what they're supposed to. This PR has a couple of changes: * Tests for timeout in while/for/foreach should just have the loop as an infinite loop. Calling into something like busy_wait means that we just end up always testing whatever busy_wait does. * Tests for timeouts in calls need to be based on something like sleep, otherwise we'd have to introduce a loop, and we'd end up testing timeout of the looping structure instead. Using sleep only works on Windows, because that's the only system where sleep counts towards the timeout. As such, many of those tests are now Windows only. * Removed some tests where I don't see a good way to test what they're supposed to test. E.g. how can we test a timeout in eval() specifically? The shutdown function tests are marked as XFAIL, as we are currently missing a timeout check in call_user_function. I believe that's a legitimate issue. Closes GH-4969.
Diffstat (limited to 'tests/basic/timeout_variation_8.phpt')
-rw-r--r--tests/basic/timeout_variation_8.phpt16
1 files changed, 4 insertions, 12 deletions
diff --git a/tests/basic/timeout_variation_8.phpt b/tests/basic/timeout_variation_8.phpt
index 51022250f0..16e2567e66 100644
--- a/tests/basic/timeout_variation_8.phpt
+++ b/tests/basic/timeout_variation_8.phpt
@@ -2,25 +2,17 @@
Timeout within foreach loop
--SKIPIF--
<?php
- if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
+if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
?>
--FILE--
<?php
-include __DIR__ . DIRECTORY_SEPARATOR . "timeout_config.inc";
+set_time_limit(1);
-set_time_limit($t);
-
-$startTime = microtime(true);
-
-foreach (range(0, 42) as $i) {
- busy_wait(1);
+foreach (new InfiniteIterator(new ArrayIterator([1])) as $i) {
}
-$diff = microtime(true) - $startTime;
-echo "time spent waiting: $diff\n";
-
?>
never reached here
--EXPECTF--
-Fatal error: Maximum execution time of 3 seconds exceeded in %s on line %d
+Fatal error: Maximum execution time of 1 second exceeded in %s on line %d