diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2019-06-22 10:19:49 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-06-22 10:19:49 +0200 |
commit | df27bfe58bb7bc0b2cb8f182a94347d36e2cb6b6 (patch) | |
tree | e15bb1e37e9821a63ba965b5d18e5a8effa37e35 | |
parent | d3112adf7f22a6eede0c90218ffd1badcaaad1a0 (diff) | |
download | php-git-df27bfe58bb7bc0b2cb8f182a94347d36e2cb6b6.tar.gz |
Add debugging code to time_sleep_until test
-rw-r--r-- | ext/standard/tests/misc/time_sleep_until_basic.phpt | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/ext/standard/tests/misc/time_sleep_until_basic.phpt b/ext/standard/tests/misc/time_sleep_until_basic.phpt index cac7133e95..25c17ab9a7 100644 --- a/ext/standard/tests/misc/time_sleep_until_basic.phpt +++ b/ext/standard/tests/misc/time_sleep_until_basic.phpt @@ -11,10 +11,11 @@ Michele Orselli mo@ideato.it #PHPTestFest Cesena Italia on 2009-06-20 --FILE-- <?php - $time = microtime(true) + 2; - var_dump(time_sleep_until( (int)$time )); - $now = microtime(true); - if(substr(PHP_OS, 0, 3) == 'WIN' ) { +$time = microtime(true) + 2; +$sleepUntil = (int) $time; +var_dump(time_sleep_until($sleepUntil)); +$now = microtime(true); +if (substr(PHP_OS, 0, 3) == 'WIN') { // on windows, time_sleep_until has millisecond accuracy while microtime() is accurate // to 10th of a second. this means there can be up to a .9 millisecond difference // which will fail this test. this test randomly fails on Windows and this is the cause. @@ -26,9 +27,17 @@ Michele Orselli mo@ideato.it // In practice, on slower machines even that can fail, so giving yet 50ms or more. $tmp = round($now, 3); $now = $tmp >= (int)$time ? $tmp : $tmp + .05; - } - var_dump($now >= (int)$time); +} + +if ($now >= $sleepUntil) { + echo "Success\n"; +} else { + echo "Sleep until (before truncation): ", $time, "\n"; + echo "Sleep until: ", $sleepUntil, "\n"; + echo "Now: ", $now, "\n"; +} + ?> --EXPECT-- bool(true) -bool(true) +Success |