changeset 7583:db035d4ba1bd

8066473: Port timeout utils from jdk test library into hotspot Reviewed-by: kvn, iignatyev Contributed-by: pavel.chistyakov@oracle.com
author iignatyev
date Sat, 13 Dec 2014 01:24:10 +0300
parents 2c17ba977ff0
children a733dad6fc1e
files test/testlibrary/com/oracle/java/testlibrary/Utils.java
diffstat 1 files changed, 17 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/test/testlibrary/com/oracle/java/testlibrary/Utils.java	Sat Dec 13 01:24:07 2014 +0300
+++ b/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);
+    }
 }