Fix 053-wait-some time bounds
Require that we wait at least as long as specified, except allow
1 millisecond slop to accomodate some old kernels that seem to
wake up slightly early. But allow for additional scheduling
delays by increasing the upper time bound.
Test: Treehugger
Bug: 175435088
Change-Id: Ib374fbf9e03c6862273c6cd0b0883c73d052ae9d
diff --git a/test/053-wait-some/src/Main.java b/test/053-wait-some/src/Main.java
index b8e6dfe..3fcaa82 100644
--- a/test/053-wait-some/src/Main.java
+++ b/test/053-wait-some/src/Main.java
@@ -57,15 +57,15 @@
boolean showTime = timing;
if (! timing) {
- long epsilon = delay / 10;
- if (epsilon > 50) {
- epsilon = 50;
- }
-
- long min = delay - epsilon;
+ // Allow a random scheduling delay of at least 100 msecs.
+ final long epsilon = Math.max(delay / 20, 100);
+ long min = delay - 1;
long max = delay + epsilon;
if (elapsed < min) {
+ // This can legitimately happen due to premature wake-ups.
+ // This seems rare and unexpected enough in practice that we should
+ // still report.
System.out.println(" Elapsed time was too short");
showTime = true;
} else if (elapsed > max) {