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 522431 c673e6572713ed725b687ef7bab2febed077e106
parent 522430 e76df98e1ed41f7ebd15d6e7e237e7e6a438111c
child 522432 9af6b8db40bd483d631ba7535aa16a3de3ae345f
push id10871
push usercbrindusan@mozilla.com
push dateMon, 18 Mar 2019 15:49:32 +0000
treeherdermozilla-beta@018abdd16060 [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)