8066473: Port timeout utils from jdk test library into hotspot
Reviewed-by: kvn, iignatyev
Contributed-by: pavel.chistyakov@oracle.com
--- a/hotspot/test/testlibrary/com/oracle/java/testlibrary/Utils.java Sat Dec 13 01:24:07 2014 +0300
+++ b/hotspot/test/testlibrary/com/oracle/java/testlibrary/Utils.java Sat Dec 13 01:24:10 2014 +0300
@@ -37,6 +37,7 @@
import java.util.Collections;
import java.util.List;
import java.util.Random;
+import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import sun.misc.Unsafe;
@@ -88,6 +89,12 @@
TIMEOUT_FACTOR = Double.parseDouble(toFactor);
}
+ /**
+ * Returns the value of JTREG default test timeout in milliseconds
+ * converted to {@code long}.
+ */
+ public static final long DEFAULT_TEST_TIMEOUT = TimeUnit.SECONDS.toMillis(120);
+
private Utils() {
// Private constructor to prevent class instantiation
}
@@ -396,4 +403,14 @@
}
return RANDOM_GENERATOR;
}
+
+ /**
+ * Adjusts the provided timeout value for the TIMEOUT_FACTOR
+ * @param tOut the timeout value to be adjusted
+ * @return The timeout value adjusted for the value of "test.timeout.factor"
+ * system property
+ */
+ public static long adjustTimeout(long tOut) {
+ return Math.round(tOut * Utils.TIMEOUT_FACTOR);
+ }
}