8066473: Port timeout utils from jdk test library into hotspot

Reviewed-by: kvn, iignatyev
This commit is contained in:
Pavel Chistyakov 2014-12-13 01:24:10 +03:00 committed by Igor Ignatyev
parent c39c3b01be
commit ca033e9cde

View file

@ -37,6 +37,7 @@ import java.util.Arrays;
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 @@ public final class Utils {
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 @@ public final class Utils {
}
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);
}
}