8059070: [TESTBUG] java/lang/invoke/LFCaching/LFMultiThreadCachingTest.java failed - timeout

Reviewed-by: psandoz, vlivanov
This commit is contained in:
Konstantin Shefov 2014-11-25 14:16:55 +04:00
parent 3469175a63
commit 758644082b
5 changed files with 21 additions and 3 deletions

View file

@ -31,7 +31,7 @@
* @build TestMethods * @build TestMethods
* @build LambdaFormTestCase * @build LambdaFormTestCase
* @build LFGarbageCollectedTest * @build LFGarbageCollectedTest
* @run main/othervm/timeout=600 -DtestLimit=150 LFGarbageCollectedTest * @run main/othervm LFGarbageCollectedTest
*/ */
import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandle;

View file

@ -31,7 +31,7 @@
* @build LambdaFormTestCase * @build LambdaFormTestCase
* @build LFCachingTestCase * @build LFCachingTestCase
* @build LFMultiThreadCachingTest * @build LFMultiThreadCachingTest
* @run main/othervm/timeout=300 LFMultiThreadCachingTest * @run main/othervm LFMultiThreadCachingTest
*/ */
import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandle;

View file

@ -31,7 +31,7 @@
* @build LambdaFormTestCase * @build LambdaFormTestCase
* @build LFCachingTestCase * @build LFCachingTestCase
* @build LFSingleThreadCachingTest * @build LFSingleThreadCachingTest
* @run main/othervm/timeout=300 LFSingleThreadCachingTest * @run main/othervm LFSingleThreadCachingTest
*/ */
import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandle;

View file

@ -27,6 +27,7 @@ import java.lang.management.ManagementFactory;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.Collection; import java.util.Collection;
import java.util.function.Function; import java.util.function.Function;
import jdk.testlibrary.Utils;
/** /**
* Lambda forms caching test case class. Contains all necessary test routines to * Lambda forms caching test case class. Contains all necessary test routines to
@ -41,6 +42,7 @@ public abstract class LambdaFormTestCase {
private final static String INTERNAL_FORM_METHOD_NAME = "internalForm"; private final static String INTERNAL_FORM_METHOD_NAME = "internalForm";
private static final double ITERATIONS_TO_CODE_CACHE_SIZE_RATIO private static final double ITERATIONS_TO_CODE_CACHE_SIZE_RATIO
= 45 / (128.0 * 1024 * 1024); = 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 * Reflection link to {@code j.l.i.MethodHandle.internalForm} method. It is
@ -120,6 +122,7 @@ public abstract class LambdaFormTestCase {
System.out.printf("Number of iterations is set to %d (%d cases)%n", System.out.printf("Number of iterations is set to %d (%d cases)%n",
iterations, iterations * testCaseNum); iterations, iterations * testCaseNum);
System.out.flush(); System.out.flush();
long startTime = System.currentTimeMillis();
for (long i = 0; i < iterations; i++) { for (long i = 0; i < iterations; i++) {
System.err.println(String.format("Iteration %d:", i)); System.err.println(String.format("Iteration %d:", i));
for (TestMethods testMethod : testMethods) { for (TestMethods testMethod : testMethods) {
@ -137,6 +140,14 @@ public abstract class LambdaFormTestCase {
} }
testCounter++; 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) { if (!passed) {
throw new Error(String.format("%d of %d test cases FAILED! %n" throw new Error(String.format("%d of %d test cases FAILED! %n"

View file

@ -38,6 +38,7 @@ import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.concurrent.TimeUnit;
/** /**
* Common library for various test helper functions. * Common library for various test helper functions.
@ -69,6 +70,12 @@ public final class Utils {
TIMEOUT_FACTOR = Double.parseDouble(toFactor); 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 Utils() {
// Private constructor to prevent class instantiation // Private constructor to prevent class instantiation
} }