com php-src: make timing check more forgiving in these tests: ext/pdo_pgsql/tests/getnotify.phpt ext/standard/tests/mis c/time_sleep_until_basic.phpt
| From: | Anatol Belski | Date: | Thu, 15 Dec 2016 11:20:37 +0000 |
| Subject: | com php-src: make timing check more forgiving in these tests: ext/pdo_pgsql/tests/getnotify.phpt ext/standard/tests/mis c/time_sleep_until_basic.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-96337@lists.php.net to get a copy of this message | ||
Commit: 8bc3f179cef87e675cb06872b8eeec22591e20be
Author: Anatol Belski <ab@php.net> Thu, 15 Dec 2016 12:20:37 +0100
Parents: 7c696fa886c51d556c5d15419df5a04e179b4534
Branches: PHP-7.0 PHP-7.1 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=8bc3f179cef87e675cb06872b8eeec22591e20be
Log:
make timing check more forgiving in these tests
Particularly on slower VMs, the sporadic fails can still happen.
The timing is kept in an uncritical range, but allows the tests
pass there. Mayby, it'd make sense to introduce a new group for
this kind of tests, so tests requiring exact time measurement
can be avoided on unsuitable environments.
Changed paths:
M ext/pdo_pgsql/tests/getnotify.phpt
M ext/standard/tests/misc/time_sleep_until_basic.phpt
Diff:
diff --git a/ext/pdo_pgsql/tests/getnotify.phpt b/ext/pdo_pgsql/tests/getnotify.phpt
index c54a316..27eef9d 100644
--- a/ext/pdo_pgsql/tests/getnotify.phpt
+++ b/ext/pdo_pgsql/tests/getnotify.phpt
@@ -71,7 +71,7 @@ var_dump($db->pgsqlGetNotify());
$t = microtime(1);
$notify = $db->pgsqlGetNotify(PDO::FETCH_ASSOC, 1000);
$diff = microtime(1) - $t;
-var_dump($diff >= 1 || 1 - abs($diff) < .01);
+var_dump($diff >= 1 || 1 - abs($diff) < .05);
var_dump($notify);
// Test second parameter, should return immediately because a notify is queued
@@ -79,7 +79,7 @@ $db->exec("NOTIFY notifies_phpt");
$t = microtime(1);
$notify = $db->pgsqlGetNotify(PDO::FETCH_ASSOC, 5000);
$diff = microtime(1) - $t;
-var_dump($diff < 1 || abs(1 - abs($diff)) < .01);
+var_dump($diff < 1 || abs(1 - abs($diff)) < .05);
var_dump(count($notify));
?>
diff --git a/ext/standard/tests/misc/time_sleep_until_basic.phpt
b/ext/standard/tests/misc/time_sleep_until_basic.phpt
index 05cc0e6..2be972a 100644
--- a/ext/standard/tests/misc/time_sleep_until_basic.phpt
+++ b/ext/standard/tests/misc/time_sleep_until_basic.phpt
@@ -23,7 +23,9 @@ Michele Orselli mo@ideato.it
// passes for up to .5 milliseconds less, fails for more than .5 milliseconds
// should be fine since time_sleep_until() on Windows is accurate to the
// millisecond(.5 rounded up is 1 millisecond)
- $now = round($now, 3);
+ // 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);
?>