Bug 1528023 [wpt PR 15375] - ensure sleep_at_least is guaranteed to sleep for the requested duration, a=testonly
authorErik Anderson <Erik.Anderson@microsoft.com>
Tue, 05 Mar 2019 12:13:21 +0000
changeset 525150 78d3aefc44182764ee01790175826e4d800a29d8
parent 525149 48f705e0ae7ecb8b9af4d91516c8920532a279e4
child 525151 629c2a5b9013de68ac0e96f3792d0959803db9c8
push id2032
push userffxbld-merge
push dateMon, 13 May 2019 09:36:57 +0000
treeherdermozilla-release@455c1065dcbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1528023, 15375, 1469655, 631969
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1528023 [wpt PR 15375] - ensure sleep_at_least is guaranteed to sleep for the requested duration, a=testonly Automatic update from web-platform-tests ensure sleep_at_least is guaranteed to sleep for the requested duration Microsoft runs tests in a Hyper-V VM. The test external/wpt/resource-timing/resource-timing-level1.sub.html leverages wptserve's SyntheticResponse.py to request that each step of a response is delayed by 250ms. In our environment, even with the extra 15ms "padding" in sleep.py, we're seeing the timer return 5ms early which in turn causes the test to fail. This change updates the sleep_at_least function to, in a loop, explicitly check that it slept long enough and, if not, sleep again for a short interval. Change-Id: I2dbd8e6bd586dc661b45f94454d3b6b4613db1a5 Reviewed-on: https://chromium-review.googlesource.com/c/1469655 Reviewed-by: Robert Ma <robertma@chromium.org> Reviewed-by: Yoav Weiss <yoavweiss@chromium.org> Commit-Queue: Erik Anderson <Erik.Anderson@microsoft.com> Cr-Commit-Position: refs/heads/master@{#631969} -- wpt-commits: 8f7ccae78b9a0e36aca3618f62e5bf558f4775d4 wpt-pr: 15375
testing/web-platform/tests/common/sleep.py
--- a/testing/web-platform/tests/common/sleep.py
+++ b/testing/web-platform/tests/common/sleep.py
@@ -1,8 +1,12 @@
 import time
 
 # sleep can be lower than requested value in some platforms: https://bugs.python.org/issue31539
 # We add padding here to compensate for that.
 sleep_padding = 15.0
 
 def sleep_at_least(sleep_in_ms):
-    time.sleep((sleep_in_ms + sleep_padding) / 1E3);
+    sleep_until = time.time() + (sleep_in_ms / 1E3)
+    time.sleep((sleep_in_ms + sleep_padding) / 1E3)
+    # Check if the padding was sufficient; if not, sleep again.
+    while time.time() < sleep_until:
+        time.sleep(sleep_padding / 1E3)