8059070: [TESTBUG] java/lang/invoke/LFCaching/LFMultiThreadCachingTest.java failed - timeout
Reviewed-by: psandoz, vlivanov
--- a/jdk/test/java/lang/invoke/LFCaching/LFGarbageCollectedTest.java Mon Nov 24 18:11:25 2014 +0000
+++ b/jdk/test/java/lang/invoke/LFCaching/LFGarbageCollectedTest.java Tue Nov 25 14:16:55 2014 +0400
@@ -31,7 +31,7 @@
* @build TestMethods
* @build LambdaFormTestCase
* @build LFGarbageCollectedTest
- * @run main/othervm/timeout=600 -DtestLimit=150 LFGarbageCollectedTest
+ * @run main/othervm LFGarbageCollectedTest
*/
import java.lang.invoke.MethodHandle;
--- a/jdk/test/java/lang/invoke/LFCaching/LFMultiThreadCachingTest.java Mon Nov 24 18:11:25 2014 +0000
+++ b/jdk/test/java/lang/invoke/LFCaching/LFMultiThreadCachingTest.java Tue Nov 25 14:16:55 2014 +0400
@@ -31,7 +31,7 @@
* @build LambdaFormTestCase
* @build LFCachingTestCase
* @build LFMultiThreadCachingTest
- * @run main/othervm/timeout=300 LFMultiThreadCachingTest
+ * @run main/othervm LFMultiThreadCachingTest
*/
import java.lang.invoke.MethodHandle;
--- a/jdk/test/java/lang/invoke/LFCaching/LFSingleThreadCachingTest.java Mon Nov 24 18:11:25 2014 +0000
+++ b/jdk/test/java/lang/invoke/LFCaching/LFSingleThreadCachingTest.java Tue Nov 25 14:16:55 2014 +0400
@@ -31,7 +31,7 @@
* @build LambdaFormTestCase
* @build LFCachingTestCase
* @build LFSingleThreadCachingTest
- * @run main/othervm/timeout=300 LFSingleThreadCachingTest
+ * @run main/othervm LFSingleThreadCachingTest
*/
import java.lang.invoke.MethodHandle;
--- a/jdk/test/java/lang/invoke/LFCaching/LambdaFormTestCase.java Mon Nov 24 18:11:25 2014 +0000
+++ b/jdk/test/java/lang/invoke/LFCaching/LambdaFormTestCase.java Tue Nov 25 14:16:55 2014 +0400
@@ -27,6 +27,7 @@
import java.lang.reflect.Method;
import java.util.Collection;
import java.util.function.Function;
+import jdk.testlibrary.Utils;
/**
* Lambda forms caching test case class. Contains all necessary test routines to
@@ -41,6 +42,7 @@
private final static String INTERNAL_FORM_METHOD_NAME = "internalForm";
private static final double ITERATIONS_TO_CODE_CACHE_SIZE_RATIO
= 45 / (128.0 * 1024 * 1024);
+ private static final long TIMEOUT = Utils.adjustTimeout(Utils.DEFAULT_TEST_TIMEOUT);
/**
* Reflection link to {@code j.l.i.MethodHandle.internalForm} method. It is
@@ -120,6 +122,7 @@
System.out.printf("Number of iterations is set to %d (%d cases)%n",
iterations, iterations * testCaseNum);
System.out.flush();
+ long startTime = System.currentTimeMillis();
for (long i = 0; i < iterations; i++) {
System.err.println(String.format("Iteration %d:", i));
for (TestMethods testMethod : testMethods) {
@@ -137,6 +140,14 @@
}
testCounter++;
}
+ long passedTime = System.currentTimeMillis() - startTime;
+ long avgIterTime = passedTime / (i + 1);
+ long remainTime = TIMEOUT - passedTime;
+ if (avgIterTime > 2 * remainTime) {
+ System.err.printf("Stopping iterations because of lack of time.%n"
+ + "Increase timeout factor for more iterations.%n");
+ break;
+ }
}
if (!passed) {
throw new Error(String.format("%d of %d test cases FAILED! %n"
--- a/jdk/test/lib/testlibrary/jdk/testlibrary/Utils.java Mon Nov 24 18:11:25 2014 +0000
+++ b/jdk/test/lib/testlibrary/jdk/testlibrary/Utils.java Tue Nov 25 14:16:55 2014 +0400
@@ -38,6 +38,7 @@
import java.util.Collections;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
+import java.util.concurrent.TimeUnit;
/**
* Common library for various test helper functions.
@@ -69,6 +70,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
}